Skip to content

bpo-41525: Make the Python program help ASCII-only #21836

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Lib/test/test_cmd_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ def test_site_flag(self):

def test_usage(self):
rc, out, err = assert_python_ok('-h')
self.assertIn(b'usage', out)
lines = out.splitlines()
self.assertIn(b'usage', lines[0])
# The first line contains the program name,
# but the rest should be ASCII-only
b''.join(lines[1:]).decode('ascii')
Copy link
Member

Choose a reason for hiding this comment

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

Would decoding each line separately be faster?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, decoding one large string at once is faster.


def test_version(self):
version = ('Python %d.%d' % sys.version_info[:2]).encode("ascii")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The output of ``python --help`` contains now only ASCII characters.
2 changes: 1 addition & 1 deletion Misc/python.man
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ Set implementation specific option. The following options are available:
nested imports). Note that its output may be broken in multi-threaded
application. Typical usage is python3 -X importtime -c 'import asyncio'

-X dev: enable CPython’s “development mode, introducing additional runtime
-X dev: enable CPython's "development mode", introducing additional runtime
checks which are too expensive to be enabled by default. It will not be
more verbose than the default if the code is correct: new warnings are
only emitted when an issue is detected. Effect of the developer mode:
Expand Down
2 changes: 1 addition & 1 deletion Python/initconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static const char usage_3[] = "\
cumulative time (including nested imports) and self time (excluding\n\
nested imports). Note that its output may be broken in multi-threaded\n\
application. Typical usage is python3 -X importtime -c 'import asyncio'\n\
-X dev: enable CPython’s “development mode, introducing additional runtime\n\
-X dev: enable CPython's \"development mode\", introducing additional runtime\n\
Copy link
Member

Choose a reason for hiding this comment

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

Even though conversion would be a different issue, I am curious whether there is any good reason to not use """ quotes for the string instead of "s and '\n\' and '"'.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is C.

checks which are too expensive to be enabled by default. Effect of the\n\
developer mode:\n\
* Add default warning filter, as -W default\n\
Expand Down