MAINT: specify encoding in numpy/testing/_private/utils.py#31553
Merged
Conversation
Several open() and subprocess.run() calls in numpy/testing/_private/utils.py omit the encoding argument, which triggers EncodingWarning under PYTHONWARNDEFAULTENCODING=1 (Python 3.10+) -- for example when downstream projects run their test suites with that flag set (the most recent report on numpygh-24115 points at the subprocess.run call here). These calls read ASCII data from /proc and the output of `lscpu`, so utf-8 is the correct explicit encoding. Addresses the numpy/testing portion of numpygh-24115. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
seberg
approved these changes
Jun 3, 2026
Contributor
Author
|
Sounds good, thanks for the response! If you think its worth the merge then lets do it otherwise no hard feelings. Excited to contribute to the project and look forward to contributing more in the future! As for the circleci idk whats going on there it was giving me trouble too. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR summary
Several
open()andsubprocess.run(..., text=True)calls innumpy/testing/_private/utils.pyomit an explicitencoding, which triggersEncodingWarningunderPYTHONWARNDEFAULTENCODING=1/python -X warn_default_encodingon Python 3.10+.The most recent report in gh-24115 points at the
subprocess.run(cmd, capture_output=True, text=True)call in this module. This PR also covers nearbyopen()calls that read/proc/<pid>/statand/proc/meminfo.All affected call sites read Linux pseudo-files or tool output that is plain ASCII, so
encoding="utf-8"preserves the existing decoded result while making the behavior independent of the process locale.This is a scoped maintenance change toward gh-24115 for the
numpy/testingarea. It is intended to be mechanical only, with no behavior change.First time committer introduction
Hi, I’m Lawson. I use NumPy through research I conduct in school and other side projects. I have been looking for more OSS projects to contribute to in the machine learning space. This is my first NumPy contribution, so I tried to keep the change small and focused.
AI Disclosure
AI assisted with this PR. Tools: Claude Code (Anthropic) and OpenAI Codex. They helped identify the un-encoded
open()/subprocess.run()call sites and draft the PR text. I reviewed and verified the change, understand it, and can explain it.Thanks @jorenham reopening with the template filled in, including the AI disclosure. Apologies again for missing it the first time.