]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #9992: Remove PYTHONFSENCODING environment variable.
authorVictor Stinner <victor.stinner@haypocalc.com>
Wed, 13 Oct 2010 22:02:27 +0000 (22:02 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Wed, 13 Oct 2010 22:02:27 +0000 (22:02 +0000)
Doc/using/cmdline.rst
Doc/whatsnew/3.2.rst
Lib/test/test_os.py
Lib/test/test_subprocess.py
Lib/test/test_sys.py
Misc/NEWS
Modules/main.c
Python/pythonrun.c

index 28df51de7baad9799949be03a41cf8ce46ee089f..7da1954b25a81341c0fcabaea4a5080c5509830c 100644 (file)
@@ -442,18 +442,6 @@ These environment variables influence Python's behavior.
    import of source modules.
 
 
-.. envvar:: PYTHONFSENCODING
-
-   If this is set before running the interpreter, it overrides the encoding used
-   for the filesystem encoding (see :func:`sys.getfilesystemencoding`).
-
-   This variable is not available (ignored) on Windows and Mac OS X: the
-   filesystem encoding is pinned to ``'mbcs'`` on Windows and ``'utf-8'`` on
-   Mac OS X.
-
-   .. versionadded:: 3.2
-
-
 .. envvar:: PYTHONIOENCODING
 
    If this is set before running the interpreter, it overrides the encoding used
index e5d79b628050c5613965b3e57c9ba0835ab08aa2..9ac966d64d161d79e70d1bd355c1b03e6867b8fa 100644 (file)
@@ -569,12 +569,6 @@ A number of small performance enhancements have been added:
 Filenames and Unicode
 =====================
 
-The filesystem encoding can be specified by setting the
-:envvar:`PYTHONFSENCODING` environment variable before running the interpreter.
-The value is an encoding name, e.g. ``iso-8859-1``. This variable is not
-available (ignored) on Windows and Mac OS X: the filesystem encoding is pinned
-to ``'mbcs'`` on Windows and ``'utf-8'`` on Mac OS X.
-
 The :mod:`os` module has two new functions: :func:`~os.fsencode` and
 :func:`~os.fsdecode`.
 
index 342dadabe50aaa4f2f5c11fb3d52a1b965eb07fd..768814c105530af138b60e82b654f6fa6878ed83 100644 (file)
@@ -1172,36 +1172,6 @@ class FSEncodingTests(unittest.TestCase):
                 continue
             self.assertEquals(os.fsdecode(bytesfn), fn)
 
-    def get_output(self, fs_encoding, func):
-        env = os.environ.copy()
-        env['PYTHONIOENCODING'] = 'utf-8'
-        env['PYTHONFSENCODING'] = fs_encoding
-        code = 'import os; print(%s, end="")' % func
-        process = subprocess.Popen(
-            [sys.executable, "-c", code],
-            stdout=subprocess.PIPE, env=env)
-        stdout, stderr = process.communicate()
-        self.assertEqual(process.returncode, 0)
-        return stdout.decode('utf-8')
-
-    @unittest.skipIf(sys.platform in ('win32', 'darwin'),
-                     'PYTHONFSENCODING is ignored on Windows and Mac OS X')
-    def test_encodings(self):
-        def check(encoding, bytesfn, unicodefn):
-            encoded = self.get_output(encoding, 'repr(os.fsencode(%a))' % unicodefn)
-            self.assertEqual(encoded, repr(bytesfn))
-
-            decoded = self.get_output(encoding, 'repr(os.fsdecode(%a))' % bytesfn)
-            self.assertEqual(decoded, repr(unicodefn))
-
-        check('utf-8', b'\xc3\xa9\x80', '\xe9\udc80')
-
-        # Raise SkipTest() if sys.executable is not encodable to ascii
-        support.workaroundIssue8611()
-
-        check('ascii', b'abc\xff', 'abc\udcff')
-        check('iso-8859-15', b'\xef\xa4', '\xef\u20ac')
-
 
 class PidTests(unittest.TestCase):
     @unittest.skipUnless(hasattr(os, 'getppid'), "test needs os.getppid")
index fef0ed852548bd93c2e82c2ef6b77086d50a25e9..6eff9e2bf3cbcb8e02c27f2659e24cc7bffe3fed 100644 (file)
@@ -885,10 +885,6 @@ class POSIXProcessTestCase(BaseTestCase):
             script = "import os; print(ascii(os.getenv(%s)))" % repr(key)
             env = os.environ.copy()
             env[key] = value
-            # Force surrogate-escaping of \xFF in the child process;
-            # otherwise it can be decoded as-is if the default locale
-            # is latin-1.
-            env['PYTHONFSENCODING'] = 'ascii'
             stdout = subprocess.check_output(
                 [sys.executable, "-c", script],
                 env=env)
index 639c9b0a60e3ce4cdc6f224e835a16cc2cee4e66..6e8aa254d73791a18d59a144a204939005112507 100644 (file)
@@ -602,35 +602,6 @@ class SysModuleTest(unittest.TestCase):
             expected = None
         self.check_fsencoding(fs_encoding, expected)
 
-    @unittest.skipIf(sys.platform in ('win32', 'darwin'),
-                     'PYTHONFSENCODING is ignored on Windows and Mac OS X')
-    def test_pythonfsencoding(self):
-        def get_fsencoding(env):
-            output = subprocess.check_output(
-                [sys.executable, "-c",
-                 "import sys; print(sys.getfilesystemencoding())"],
-                env=env)
-            return output.rstrip().decode('ascii')
-
-        # Raise SkipTest() if sys.executable is not encodable to ascii
-        test.support.workaroundIssue8611()
-
-        # Use C locale to get ascii for the locale encoding
-        env = os.environ.copy()
-        env['LC_ALL'] = 'C'
-        try:
-            del env['PYTHONFSENCODING']
-        except KeyError:
-            pass
-        self.check_fsencoding(get_fsencoding(env), 'ascii')
-
-        # Filesystem encoding is hardcoded on Windows and Mac OS X
-        for encoding in ('ascii', 'cp850', 'iso8859-1', 'utf-8'):
-            env = os.environ.copy()
-            env['PYTHONFSENCODING'] = encoding
-            self.check_fsencoding(get_fsencoding(env), encoding)
-
-
 
 class SizeofTest(unittest.TestCase):
 
index 5666c3e3cb17bf32326762ae0f82dcca1b82720c..142c9fc34ef64742ea556420875def9b9eacfb7e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,8 @@ What's New in Python 3.2 Beta 1?
 Core and Builtins
 -----------------
 
+- Issue #9992: Remove PYTHONFSENCODING environment variable.
+
 Library
 -------
 
index 4a10d939c0458446084b3081099d4b5ebfab0386..c9499ac51b3fd3eab22005eb22e739a128351682 100644 (file)
@@ -99,9 +99,6 @@ static char *usage_5 =
 "               The default module search path uses %s.\n"
 "PYTHONCASEOK : ignore case in 'import' statements (Windows).\n"
 "PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n"
-#if !(defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)) && !defined(__APPLE__)
-"PYTHONFSENCODING: Encoding used for the filesystem.\n"
-#endif
 ;
 
 static int
index a888a19f2012eb7aad41e16fc6be61d4817089c5..012c1b85f2346986f196d1e38fa66457473574da 100644 (file)
@@ -980,22 +980,12 @@ initfsencoding(void)
     char *codeset = NULL;
 
     if (Py_FileSystemDefaultEncoding == NULL) {
-        const char *env_encoding = Py_GETENV("PYTHONFSENCODING");
-        if (env_encoding != NULL) {
-            codeset = get_codec_name(env_encoding);
-            if (!codeset) {
-                fprintf(stderr, "PYTHONFSENCODING is not a valid encoding:\n");
-                PyErr_Print();
-            }
-        }
-        if (!codeset) {
-            /* On Unix, set the file system encoding according to the
-               user's preference, if the CODESET names a well-known
-               Python codec, and Py_FileSystemDefaultEncoding isn't
-               initialized by other means. Also set the encoding of
-               stdin and stdout if these are terminals.  */
-            codeset = get_codeset();
-        }
+        /* On Unix, set the file system encoding according to the
+           user's preference, if the CODESET names a well-known
+           Python codec, and Py_FileSystemDefaultEncoding isn't
+           initialized by other means. Also set the encoding of
+           stdin and stdout if these are terminals.  */
+        codeset = get_codeset();
         if (codeset != NULL) {
             if (redecode_filenames(codeset))
                 Py_FatalError("Py_Initialize: can't redecode filenames");