Skip to content

test_netrc fails on non-UTF-8 locale #91915

Closed
@serhiy-storchaka

Description

@serhiy-storchaka
$ LC_ALL=uk_UA.koi8u ./python -m test -vuall test_netrc -m test_token_value_non_ascii
== CPython 3.11.0a7+ (heads/re-group-name:5026649f98, Apr 24 2022, 22:45:28) [GCC 9.4.0]
== Linux-5.4.0-109-generic-x86_64-with-glibc2.31 little-endian
== cwd: /home/serhiy/py/cpython/build/test_python_197535�
== CPU count: 8
== encodings: locale=KOI8-U, FS=koi8-u
0:00:00 load avg: 1.16 Run tests sequentially
0:00:00 load avg: 1.16 [1/1] test_netrc
test_token_value_non_ascii (test.test_netrc.NetrcTestCase.test_token_value_non_ascii) ... ERROR

======================================================================
ERROR: test_token_value_non_ascii (test.test_netrc.NetrcTestCase.test_token_value_non_ascii)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/test/test_netrc.py", line 144, in test_token_value_non_ascii
    self._test_token_x("""\
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/serhiy/py/cpython/Lib/test/test_netrc.py", line 93, in _test_token_x
    nrc = self.make_nrc(nrc)
          ^^^^^^^^^^^^^^^^^^
  File "/home/serhiy/py/cpython/Lib/test/test_netrc.py", line 14, in make_nrc
    fp.write(test_data)
    ^^^^^^^^^^^^^^^^^^^
  File "/home/serhiy/py/cpython/Lib/encodings/koi8_u.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode characters in position 30-31: character maps to <undefined>

----------------------------------------------------------------------
Ran 1 test in 0.004s

FAILED (errors=1)
Warning -- files was modified by test_netrc
Warning --   Before: []
Warning --   After:  ['@test_197535_tmp�'] 
test test_netrc failed
test_netrc failed (1 error)

== Tests result: FAILURE ==

1 test failed:
    test_netrc

Total duration: 82 ms
Tests result: FAILURE

Metadata

Metadata

Labels

3.10only security fixes3.11only security fixestestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions