Index: Python/sysmodule.c =================================================================== --- Python/sysmodule.c (révision 84171) +++ Python/sysmodule.c (copie de travail) @@ -217,25 +217,6 @@ ); static PyObject * -sys_setfilesystemencoding(PyObject *self, PyObject *args) -{ - PyObject *new_encoding; - if (!PyArg_ParseTuple(args, "U:setfilesystemencoding", &new_encoding)) - return NULL; - if (_Py_SetFileSystemEncoding(new_encoding)) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(setfilesystemencoding_doc, -"setfilesystemencoding(string) -> None\n\ -\n\ -Set the encoding used to convert Unicode filenames in\n\ -operating system filenames." -); - -static PyObject * sys_intern(PyObject *self, PyObject *args) { PyObject *s; @@ -1032,8 +1013,6 @@ #endif {"setdefaultencoding", sys_setdefaultencoding, METH_VARARGS, setdefaultencoding_doc}, - {"setfilesystemencoding", sys_setfilesystemencoding, METH_VARARGS, - setfilesystemencoding_doc}, {"setcheckinterval", sys_setcheckinterval, METH_VARARGS, setcheckinterval_doc}, {"getcheckinterval", sys_getcheckinterval, METH_NOARGS, Index: Misc/NEWS =================================================================== --- Misc/NEWS (révision 84171) +++ Misc/NEWS (copie de travail) @@ -102,6 +102,11 @@ Library ------- +- Issue #9632: Remove sys.setfilesystemencoding() function: use + PYTHONFSENCODING environment variable to set the filesystem encoding at + Python startup. sys.setfilesystemencoding() is unable to reencode all + filenames in all objects and so creates inconsistencies. + - Issue #3488: Provide convenient shorthand functions ``gzip.compress`` and ``gzip.decompress``. Original patch by Anand B. Pillai. Index: Doc/library/sys.rst =================================================================== --- Doc/library/sys.rst (révision 84171) +++ Doc/library/sys.rst (copie de travail) @@ -736,15 +736,6 @@ :file:`/usr/include/dlfcn.h` using the :program:`h2py` script. Availability: Unix. -.. function:: setfilesystemencoding(enc) - - Set the encoding used when converting Python strings to file names to *enc*. - By default, Python tries to determine the encoding it should use automatically - on Unix; on Windows, it avoids such conversion completely. This function can - be used when Python's determination of the encoding needs to be overwritten, - e.g. when not all file names on disk can be decoded using the encoding that - Python had chosen. - .. function:: setprofile(profilefunc) .. index:: Index: Lib/test/test_sys.py =================================================================== --- Lib/test/test_sys.py (révision 84171) +++ Lib/test/test_sys.py (copie de travail) @@ -889,17 +889,6 @@ fs_encoding = output.rstrip().decode('ascii') check_fsencoding(fs_encoding) - def test_setfilesystemencoding(self): - old = sys.getfilesystemencoding() - try: - sys.setfilesystemencoding("iso-8859-1") - self.assertEqual(sys.getfilesystemencoding(), "iso-8859-1") - finally: - sys.setfilesystemencoding(old) - try: - self.assertRaises(LookupError, sys.setfilesystemencoding, "xxx") - finally: - sys.setfilesystemencoding(old) def test_main(): test.support.run_unittest(SysModuleTest, SizeofTest)