[Python-checkins] r85430 - in python/branches/py3k: 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

victor.stinner python-checkins at python.org
Thu Oct 14 00:02:27 CEST 2010


Author: victor.stinner
Date: Thu Oct 14 00:02:27 2010
New Revision: 85430

Log:
Issue #9992: Remove PYTHONFSENCODING environment variable.


Modified:
   python/branches/py3k/Doc/using/cmdline.rst
   python/branches/py3k/Doc/whatsnew/3.2.rst
   python/branches/py3k/Lib/test/test_os.py
   python/branches/py3k/Lib/test/test_subprocess.py
   python/branches/py3k/Lib/test/test_sys.py
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Modules/main.c
   python/branches/py3k/Python/pythonrun.c

Modified: python/branches/py3k/Doc/using/cmdline.rst
==============================================================================
--- python/branches/py3k/Doc/using/cmdline.rst	(original)
+++ python/branches/py3k/Doc/using/cmdline.rst	Thu Oct 14 00:02:27 2010
@@ -442,18 +442,6 @@
    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

Modified: python/branches/py3k/Doc/whatsnew/3.2.rst
==============================================================================
--- python/branches/py3k/Doc/whatsnew/3.2.rst	(original)
+++ python/branches/py3k/Doc/whatsnew/3.2.rst	Thu Oct 14 00:02:27 2010
@@ -569,12 +569,6 @@
 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`.
 

Modified: python/branches/py3k/Lib/test/test_os.py
==============================================================================
--- python/branches/py3k/Lib/test/test_os.py	(original)
+++ python/branches/py3k/Lib/test/test_os.py	Thu Oct 14 00:02:27 2010
@@ -1172,36 +1172,6 @@
                 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")

Modified: python/branches/py3k/Lib/test/test_subprocess.py
==============================================================================
--- python/branches/py3k/Lib/test/test_subprocess.py	(original)
+++ python/branches/py3k/Lib/test/test_subprocess.py	Thu Oct 14 00:02:27 2010
@@ -885,10 +885,6 @@
             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)

Modified: python/branches/py3k/Lib/test/test_sys.py
==============================================================================
--- python/branches/py3k/Lib/test/test_sys.py	(original)
+++ python/branches/py3k/Lib/test/test_sys.py	Thu Oct 14 00:02:27 2010
@@ -602,35 +602,6 @@
             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):
 

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Thu Oct 14 00:02:27 2010
@@ -10,6 +10,8 @@
 Core and Builtins
 -----------------
 
+- Issue #9992: Remove PYTHONFSENCODING environment variable.
+
 Library
 -------
 

Modified: python/branches/py3k/Modules/main.c
==============================================================================
--- python/branches/py3k/Modules/main.c	(original)
+++ python/branches/py3k/Modules/main.c	Thu Oct 14 00:02:27 2010
@@ -99,9 +99,6 @@
 "               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

Modified: python/branches/py3k/Python/pythonrun.c
==============================================================================
--- python/branches/py3k/Python/pythonrun.c	(original)
+++ python/branches/py3k/Python/pythonrun.c	Thu Oct 14 00:02:27 2010
@@ -980,22 +980,12 @@
     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");


More information about the Python-checkins mailing list