mirror of
https://github.com/python/cpython.git
synced 2025-07-17 16:25:18 +00:00
Issue #9548: Add a minimal "_bootlocale" module that is imported by the _io module instead of the full locale module.
This commit is contained in:
parent
73abc527eb
commit
fd4722cacf
6 changed files with 49 additions and 22 deletions
|
@ -883,8 +883,9 @@ class ProcessTestCase(BaseTestCase):
|
|||
#
|
||||
# UTF-16 and UTF-32-BE are sufficient to check both with BOM and
|
||||
# without, and UTF-16 and UTF-32.
|
||||
import _bootlocale
|
||||
for encoding in ['utf-16', 'utf-32-be']:
|
||||
old_getpreferredencoding = locale.getpreferredencoding
|
||||
old_getpreferredencoding = _bootlocale.getpreferredencoding
|
||||
# Indirectly via io.TextIOWrapper, Popen() defaults to
|
||||
# locale.getpreferredencoding(False) and earlier in Python 3.2 to
|
||||
# locale.getpreferredencoding().
|
||||
|
@ -895,7 +896,7 @@ class ProcessTestCase(BaseTestCase):
|
|||
encoding)
|
||||
args = [sys.executable, '-c', code]
|
||||
try:
|
||||
locale.getpreferredencoding = getpreferredencoding
|
||||
_bootlocale.getpreferredencoding = getpreferredencoding
|
||||
# We set stdin to be non-None because, as of this writing,
|
||||
# a different code path is used when the number of pipes is
|
||||
# zero or one.
|
||||
|
@ -904,7 +905,7 @@ class ProcessTestCase(BaseTestCase):
|
|||
stdout=subprocess.PIPE)
|
||||
stdout, stderr = popen.communicate(input='')
|
||||
finally:
|
||||
locale.getpreferredencoding = old_getpreferredencoding
|
||||
_bootlocale.getpreferredencoding = old_getpreferredencoding
|
||||
self.assertEqual(stdout, '1\n2\n3\n4')
|
||||
|
||||
def test_no_leaking(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue