mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
bpo-47000: Make io.text_encoding() respects UTF-8 mode (GH-32003)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
This commit is contained in:
parent
6db2db91b9
commit
4216dce04b
10 changed files with 52 additions and 17 deletions
|
|
@ -4289,6 +4289,17 @@ class MiscIOTest(unittest.TestCase):
|
|||
self.assertTrue(
|
||||
warnings[1].startswith(b"<string>:8: EncodingWarning: "))
|
||||
|
||||
def test_text_encoding(self):
|
||||
# PEP 597, bpo-47000. io.text_encoding() returns "locale" or "utf-8"
|
||||
# based on sys.flags.utf8_mode
|
||||
code = "import io; print(io.text_encoding(None))"
|
||||
|
||||
proc = assert_python_ok('-X', 'utf8=0', '-c', code)
|
||||
self.assertEqual(b"locale", proc.out.strip())
|
||||
|
||||
proc = assert_python_ok('-X', 'utf8=1', '-c', code)
|
||||
self.assertEqual(b"utf-8", proc.out.strip())
|
||||
|
||||
@support.cpython_only
|
||||
# Depending if OpenWrapper was already created or not, the warning is
|
||||
# emitted or not. For example, the attribute is already created when this
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue