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
120c2122
Commit
120c2122
authored
Mar 25, 2010
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #8226: sys.setfilesystemencoding() raises a LookupError if the encoding
is unknown.
parent
cd4ec0e2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
1 deletion
+9
-1
Lib/test/test_sys.py
Lib/test/test_sys.py
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
Python/bltinmodule.c
Python/bltinmodule.c
+5
-1
No files found.
Lib/test/test_sys.py
View file @
120c2122
...
...
@@ -799,6 +799,7 @@ class SizeofTest(unittest.TestCase):
old
=
sys
.
getfilesystemencoding
()
sys
.
setfilesystemencoding
(
"iso-8859-1"
)
self
.
assertEqual
(
sys
.
getfilesystemencoding
(),
"iso-8859-1"
)
self
.
assertRaises
(
LookupError
,
sys
.
setfilesystemencoding
,
"xxx"
)
sys
.
setfilesystemencoding
(
old
)
def
test_main
():
...
...
Misc/NEWS
View file @
120c2122
...
...
@@ -12,6 +12,9 @@ What's New in Python 3.2 Alpha 1?
Core and Builtins
-----------------
- Issue #8226: sys.setfilesystemencoding() raises a LookupError if the encoding
is unknown
- Issue #1583863: An str subclass can now override the __str__ method
- Issue #8014: Setting a T_UINT or T_PYSSIZET attribute of an object with
...
...
Python/bltinmodule.c
View file @
120c2122
...
...
@@ -29,7 +29,7 @@ int Py_HasFileSystemDefaultEncoding = 0;
int
_Py_SetFileSystemEncoding
(
PyObject
*
s
)
{
PyObject
*
defenc
;
PyObject
*
defenc
,
*
codec
;
if
(
!
PyUnicode_Check
(
s
))
{
PyErr_BadInternalCall
();
return
-
1
;
...
...
@@ -37,6 +37,10 @@ _Py_SetFileSystemEncoding(PyObject *s)
defenc
=
_PyUnicode_AsDefaultEncodedString
(
s
,
NULL
);
if
(
!
defenc
)
return
-
1
;
codec
=
_PyCodec_Lookup
(
PyBytes_AsString
(
defenc
));
if
(
codec
==
NULL
)
return
-
1
;
Py_DECREF
(
codec
);
if
(
!
Py_HasFileSystemDefaultEncoding
&&
Py_FileSystemDefaultEncoding
)
/* A file system encoding was set at run-time */
free
((
char
*
)
Py_FileSystemDefaultEncoding
);
...
...
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