diff options
| author | Victor Stinner <victor.stinner@gmail.com> | 2013-12-08 23:04:09 (GMT) |
|---|---|---|
| committer | Victor Stinner <victor.stinner@gmail.com> | 2013-12-08 23:04:09 (GMT) |
| commit | 0aba1a2663799a7e6a5582a0d8052df840889016 (patch) | |
| tree | d1bbfa1ff05057a5394fcf7b29a78c2e908de4db /Lib/test/test_platform.py | |
| parent | 7b83b186794cec6e5d12f43f9c1a6f20bfa4e932 (diff) | |
| parent | 620c48b7ea7a1ad3af23725afdac1e6a2b3e6cef (diff) | |
| download | cpython-0aba1a2663799a7e6a5582a0d8052df840889016.zip cpython-0aba1a2663799a7e6a5582a0d8052df840889016.tar.gz cpython-0aba1a2663799a7e6a5582a0d8052df840889016.tar.bz2 | |
(Merge 3.3) Issue #17429: platform.linux_distribution() now decodes files from
the UTF-8 encoding with the surrogateescape error handler, instead of decoding
from the locale encoding in strict mode. It fixes the function on Fedora 19
which is probably the first major distribution release with a non-ASCII name.
Patch written by Toshio Kuratomi.
Diffstat (limited to 'Lib/test/test_platform.py')
| -rw-r--r-- | Lib/test/test_platform.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index 0dcfe05..8a5408e 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -1,7 +1,10 @@ +from unittest import mock +import contextlib import os import platform import subprocess import sys +import tempfile import unittest import warnings @@ -295,6 +298,19 @@ class PlatformTest(unittest.TestCase): returncode = ret >> 8 self.assertEqual(returncode, len(data)) + def test_linux_distribution_encoding(self): + # Issue #17429 + with tempfile.TemporaryDirectory() as tempdir: + filename = os.path.join(tempdir, 'fedora-release') + with open(filename, 'w', encoding='utf-8') as f: + f.write('Fedora release 19 (Schr\xf6dinger\u2019s Cat)\n') + + with mock.patch('platform._UNIXCONFDIR', tempdir): + distname, version, distid = platform.linux_distribution() + + self.assertEqual(distname, 'Fedora') + self.assertEqual(version, '19') + self.assertEqual(distid, 'Schr\xf6dinger\u2019s Cat') def test_main(): support.run_unittest( |
