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
83098a40
Commit
83098a40
authored
Dec 27, 2010
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #10778: decoding_fgets() decodes the filename from the filesystem
encoding instead of UTF-8.
parent
cb428f01
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
Parser/tokenizer.c
Parser/tokenizer.c
+11
-6
No files found.
Parser/tokenizer.c
View file @
83098a40
...
...
@@ -545,6 +545,7 @@ decoding_fgets(char *s, int size, struct tok_state *tok)
{
char
*
line
=
NULL
;
int
badchar
=
0
;
PyObject
*
filename
;
for
(;;)
{
if
(
tok
->
decoding_state
==
STATE_NORMAL
)
{
/* We already have a codec associated with
...
...
@@ -585,12 +586,16 @@ decoding_fgets(char *s, int size, struct tok_state *tok)
if
(
badchar
)
{
/* Need to add 1 to the line number, since this line
has not been counted, yet. */
PyErr_Format
(
PyExc_SyntaxError
,
"Non-UTF-8 code starting with '
\\
x%.2x' "
"in file %.200s on line %i, "
"but no encoding declared; "
"see http://python.org/dev/peps/pep-0263/ for details"
,
badchar
,
tok
->
filename
,
tok
->
lineno
+
1
);
filename
=
PyUnicode_DecodeFSDefault
(
tok
->
filename
);
if
(
filename
!=
NULL
)
{
PyErr_Format
(
PyExc_SyntaxError
,
"Non-UTF-8 code starting with '
\\
x%.2x' "
"in file %.200U on line %i, "
"but no encoding declared; "
"see http://python.org/dev/peps/pep-0263/ for details"
,
badchar
,
filename
,
tok
->
lineno
+
1
);
Py_DECREF
(
filename
);
}
return
error_ret
(
tok
);
}
#endif
...
...
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