Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-91954: Emit EncodingWarning from locale and subprocess#91977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
methane merged 8 commits intopython:mainfrommethane:encodingwarning
Apr 30, 2022

Conversation

@methane
Copy link
Member

Fix:#91954

locale.getpreferredencoding() and subprocess.Popen() emit EncodingWarning
@methanemethane merged commit354ace8 intopython:mainApr 30, 2022
@methanemethane deleted the encodingwarning branchApril 30, 2022 06:53
@sweeneyde
Copy link
Member

I think this may have caused the following failure on recent Windows ARM64 buildbots:

======================================================================FAIL: test_encoding_warning (test.test_subprocess.RunFuncTestCase.test_encoding_warning)----------------------------------------------------------------------Traceback (most recent call last):  File "C:\Workspace\buildarea\3.x.linaro-win-arm64.nondebug\build\Lib\test\test_subprocess.py", line 1746, in test_encoding_warning    self.assertEqual(len(lines), 2)    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^AssertionError: 13 != 2----------------------------------------------------------------------

@sweeneyde
Copy link
Member

I opened#92090 and ran buildbots to find out what the output is:

<string>:3: EncodingWarning: 'encoding' argument not specified.Traceback (most recent call last):  File "<string>", line 3, in <module>  File "C:\Workspace\buildarea\pull_request.linaro-win-arm64.nondebug\build\Lib\subprocess.py", line 533, in run    with Popen(*popenargs, **kwargs) as process:         ^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Workspace\buildarea\pull_request.linaro-win-arm64.nondebug\build\Lib\subprocess.py", line 998, in __init__           self._execute_child(args, executable, preexec_fn, close_fds,    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Workspace\buildarea\pull_request.linaro-win-arm64.nondebug\build\Lib\subprocess.py", line 1467, in _execute_child    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^FileNotFoundError: [WinError 2] The system cannot find the file specified

@sweeneyde
Copy link
Member

deftest_encoding_warning(self):
code=textwrap.dedent("""\
from subprocess import *
args = ["echo", "hello"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Notice how the majority of the tests in this file use a child process of[sys.executable, "-c", "print('hello')"] to avoid the platform problems. Depending on a shell command working across platforms always causes future problems. See also the above test which simply skips windows because it relies on sleep 3 instead of using the above idiom. ;)

I'm not going to suggest yet another followup PR as if things are stable, lets just let it be. But the modern idiom in test_subprocess is to not launch things other than sys.executable based processes to avoid depending upon the external execution environment.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@gpsheadgpsheadgpshead left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

PEP 686: Emit EncodingWarning in more places.

4 participants

@methane@sweeneyde@gpshead@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp