bpo-31904: Only UTF-8 encoding is supported on VxWorks by hliu0 · Pull Request #13486 · python/cpython

hliu0

@hliu0

vstinner

Choose a reason for hiding this comment

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

Your doc is wrong: getpreferredencoding() isn't hardcoded to UTF-8 on VxWorks.

You have to hack Lib/_bootlocale.py and Lib/locale.py using sys.platform == "vxworks" to make this effective.

I guess that you can just replace if hasattr(sys, 'getandroidapilevel'): with if hasattr(sys, 'getandroidapilevel') and sys.platform == "vxworks":, and update the related comments.

@@ -331,6 +331,8 @@ The :mod:`locale` module defines the following exception and functions:
The function now always returns ``UTF-8`` on Android or if the UTF-8 mode
is enabled.

On VxWorks, always return ``'UTF-8'``, the locale and the *do_setlocale*
argument are ignored.

Choose a reason for hiding this comment

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

argument are ignored.
argument is ignored.

Choose a reason for hiding this comment

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

"are" is used for "the locale" and "the do_setlocale argument".

This line is mostly the same as comment for Android at line 328:

On Android or in the UTF-8 mode (:option:-X utf8 option), always
return 'UTF-8', the locale and the do_setlocale argument are ignored.

@bedevere-bot

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@hliu0

Your doc is wrong: getpreferredencoding() isn't hardcoded to UTF-8 on VxWorks.

You have to hack Lib/_bootlocale.py and Lib/locale.py using sys.platform == "vxworks" to make this effective.

I guess that you can just replace if hasattr(sys, 'getandroidapilevel'): with if hasattr(sys, 'getandroidapilevel') and sys.platform == "vxworks":, and update the related comments.

On VxWorks, always return "UTF-8" with sys.flags.utf8_mode is True in both locale.py&_bootlocale.py:
if sys.flags.utf8_mode:
return 'UTF-8'
So it does't need to add judgement with sys.platform == "vxworks".

@hliu0

I have made the requested changes; please review again.

@bedevere-bot

Thanks for making the requested changes!

@vstinner: please review the changes made to this pull request.

@pxinwr

The author of this PR has quit the job. A new PR #19448 was created to replace this one. Please anyone helps to close this PR.

@corona10

@pxinwr Thank you for letting me know

@pxinwr pxinwr deleted the fix-issue-31904-hliu0 branch

July 12, 2021 09:42