On 17. 6. 25 20:31, rin...@apache.org wrote:
Author: rinrab
Date: Tue Jun 17 18:31:22 2025
New Revision: 1926510
URL:http://svn.apache.org/viewvc?rev=1926510&view=rev
Log:
On the 'utf8-cmdline-prototype' branch: Add RequireUtf8 decorator and
run the basic_tests#unicode_arguments_test test in UTF8 environment to fix
failure its constant failures on Unix platforms.
I have a Unix platform and this test never fails. :)
By the way: that whole file uses 2-column indents, this change uses
4-column indents, so, consistency FTW!
[...]
@@ -349,3 +349,50 @@ def SkipDumpLoadCrossCheck_deco(cond_fun
# Create a singular alias, for linguistic correctness
Issue_deco = Issues_deco
+
+
+# Determines the name of UTF-8 locale on the system, or returns None if one
+# couldn't be found.
+def _detect_utf8_locale():
+ import locale
It would be better to import this module at the top of the file.
+
+ orig = None
+ try:
+ for name in ('C.UTF-8', 'en_US.UTF-8'):
+ try:
+ orig = locale.setlocale(locale.LC_ALL, name)
+ except locale.Error:
+ continue
+ else:
+ return name
+ finally:
+ if orig is not None:
+ locale.setlocale(locale.LC_ALL, orig)
+
+ return None # utf-8 locale unavailable
+
+_utf8_locale = _detect_utf8_locale() if os.name != 'nt' else False
Too specific ... a better test would be: if os.name == 'posix', as there
are other, non-Windows platforms out there that are also not
POSIX-compliant. Even better, just put this at the top of
_detect_utf8_locale() and don't complicate the assignment:
if os.name != 'posix':
return None
This is correct because, as the Python docs[1] explicitly say:
The|locale|
<https://docs.python.org/3/library/locale.html#module-locale>module
opens access to the POSIX locale database and functionality.
+
+# Decorator that runs the test in UTF-8 environment. If there are no good
+# UTF-8 locales availible on the system, skips the test.
+def RequireUtf8_deco(f):
+
+ import functools
Import this at the top of the file, too.
-- Brane
[1] https://docs.python.org/3/library/locale.html