Skip to content

test_invalid_utf8_arg fails in non-UTF-8 multibyte locales #154582

Description

@serhiy-storchaka

Bug report

test.test_cmd_line.CmdLineTest.test_invalid_utf8_arg fails in a non-UTF-8 multibyte locale such as ja_JP.eucjp:

$ LC_ALL=ja_JP.eucjp ./python -m test test_cmd_line -m test_invalid_utf8_arg
...
AssertionError: '' != "b'\\xff\\xc3\\xff...'"

The test passes arbitrary bytes as argv and checks they round-trip via os.fsencode(sys.argv[1]). But that round-trip is only lossless for UTF-8 and single-byte encodings; in a stateful multibyte encoding like EUC-JP it isn't (and Py_DecodeLocale()'s C decoder diverges from the Python codec anyway), so the run_default and run_no_utf8_mode variants — which use the filesystem / locale encoding — fail.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixes3.15pre-release feature fixes, bugs and security fixes3.16new features, bugs and 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