Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
8f6b6b0c
Commit
8f6b6b0c
authored
Oct 13, 2010
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #9992: Remove PYTHONFSENCODING environment variable.
parent
aa96592a
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
8 additions
and
100 deletions
+8
-100
Doc/using/cmdline.rst
Doc/using/cmdline.rst
+0
-12
Doc/whatsnew/3.2.rst
Doc/whatsnew/3.2.rst
+0
-6
Lib/test/test_os.py
Lib/test/test_os.py
+0
-30
Lib/test/test_subprocess.py
Lib/test/test_subprocess.py
+0
-4
Lib/test/test_sys.py
Lib/test/test_sys.py
+0
-29
Misc/NEWS
Misc/NEWS
+2
-0
Modules/main.c
Modules/main.c
+0
-3
Python/pythonrun.c
Python/pythonrun.c
+6
-16
No files found.
Doc/using/cmdline.rst
View file @
8f6b6b0c
...
@@ -442,18 +442,6 @@ These environment variables influence Python's behavior.
...
@@ -442,18 +442,6 @@ These environment variables influence Python's behavior.
import of source modules.
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
.. envvar:: PYTHONIOENCODING
If this is set before running the interpreter, it overrides the encoding used
If this is set before running the interpreter, it overrides the encoding used
...
...
Doc/whatsnew/3.2.rst
View file @
8f6b6b0c
...
@@ -569,12 +569,6 @@ A number of small performance enhancements have been added:
...
@@ -569,12 +569,6 @@ A number of small performance enhancements have been added:
Filenames and Unicode
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
The :mod:`os` module has two new functions: :func:`~os.fsencode` and
:func:`~os.fsdecode`.
:func:`~os.fsdecode`.
...
...
Lib/test/test_os.py
View file @
8f6b6b0c
...
@@ -1172,36 +1172,6 @@ class FSEncodingTests(unittest.TestCase):
...
@@ -1172,36 +1172,6 @@ class FSEncodingTests(unittest.TestCase):
continue
continue
self
.
assertEquals
(
os
.
fsdecode
(
bytesfn
),
fn
)
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
):
class
PidTests
(
unittest
.
TestCase
):
@
unittest
.
skipUnless
(
hasattr
(
os
,
'getppid'
),
"test needs os.getppid"
)
@
unittest
.
skipUnless
(
hasattr
(
os
,
'getppid'
),
"test needs os.getppid"
)
...
...
Lib/test/test_subprocess.py
View file @
8f6b6b0c
...
@@ -885,10 +885,6 @@ class POSIXProcessTestCase(BaseTestCase):
...
@@ -885,10 +885,6 @@ class POSIXProcessTestCase(BaseTestCase):
script
=
"import os; print(ascii(os.getenv(%s)))"
%
repr
(
key
)
script
=
"import os; print(ascii(os.getenv(%s)))"
%
repr
(
key
)
env
=
os
.
environ
.
copy
()
env
=
os
.
environ
.
copy
()
env
[
key
]
=
value
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
(
stdout
=
subprocess
.
check_output
(
[
sys
.
executable
,
"-c"
,
script
],
[
sys
.
executable
,
"-c"
,
script
],
env
=
env
)
env
=
env
)
...
...
Lib/test/test_sys.py
View file @
8f6b6b0c
...
@@ -602,35 +602,6 @@ class SysModuleTest(unittest.TestCase):
...
@@ -602,35 +602,6 @@ class SysModuleTest(unittest.TestCase):
expected
=
None
expected
=
None
self
.
check_fsencoding
(
fs_encoding
,
expected
)
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
):
class
SizeofTest
(
unittest
.
TestCase
):
...
...
Misc/NEWS
View file @
8f6b6b0c
...
@@ -10,6 +10,8 @@ What's New in Python 3.2 Beta 1?
...
@@ -10,6 +10,8 @@ What's New in Python 3.2 Beta 1?
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #9992: Remove PYTHONFSENCODING environment variable.
Library
Library
-------
-------
...
...
Modules/main.c
View file @
8f6b6b0c
...
@@ -99,9 +99,6 @@ static char *usage_5 =
...
@@ -99,9 +99,6 @@ static char *usage_5 =
" The default module search path uses %s.
\n
"
" The default module search path uses %s.
\n
"
"PYTHONCASEOK : ignore case in 'import' statements (Windows).
\n
"
"PYTHONCASEOK : ignore case in 'import' statements (Windows).
\n
"
"PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.
\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
static
int
...
...
Python/pythonrun.c
View file @
8f6b6b0c
...
@@ -980,22 +980,12 @@ initfsencoding(void)
...
@@ -980,22 +980,12 @@ initfsencoding(void)
char
*
codeset
=
NULL
;
char
*
codeset
=
NULL
;
if
(
Py_FileSystemDefaultEncoding
==
NULL
)
{
if
(
Py_FileSystemDefaultEncoding
==
NULL
)
{
const
char
*
env_encoding
=
Py_GETENV
(
"PYTHONFSENCODING"
);
/* On Unix, set the file system encoding according to the
if
(
env_encoding
!=
NULL
)
{
user's preference, if the CODESET names a well-known
codeset
=
get_codec_name
(
env_encoding
);
Python codec, and Py_FileSystemDefaultEncoding isn't
if
(
!
codeset
)
{
initialized by other means. Also set the encoding of
fprintf
(
stderr
,
"PYTHONFSENCODING is not a valid encoding:
\n
"
);
stdin and stdout if these are terminals. */
PyErr_Print
();
codeset
=
get_codeset
();
}
}
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
();
}
if
(
codeset
!=
NULL
)
{
if
(
codeset
!=
NULL
)
{
if
(
redecode_filenames
(
codeset
))
if
(
redecode_filenames
(
codeset
))
Py_FatalError
(
"Py_Initialize: can't redecode filenames"
);
Py_FatalError
(
"Py_Initialize: can't redecode filenames"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment