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
6cba2566
Commit
6cba2566
authored
Feb 28, 2006
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change non-ASCII warning into a SyntaxError.
parent
e4d3a72a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
10 deletions
+6
-10
Parser/tokenizer.c
Parser/tokenizer.c
+6
-10
No files found.
Parser/tokenizer.c
View file @
6cba2566
...
...
@@ -127,7 +127,6 @@ tok_new(void)
tok
->
decoding_state
=
0
;
tok
->
decoding_erred
=
0
;
tok
->
read_coding_spec
=
0
;
tok
->
issued_encoding_warning
=
0
;
tok
->
encoding
=
NULL
;
tok
->
cont_line
=
0
;
#ifndef PGEN
...
...
@@ -462,7 +461,7 @@ static char *
decoding_fgets
(
char
*
s
,
int
size
,
struct
tok_state
*
tok
)
{
char
*
line
=
NULL
;
int
warn
=
0
,
badchar
=
0
;
int
badchar
=
0
;
for
(;;)
{
if
(
tok
->
decoding_state
<
0
)
{
/* We already have a codec associated with
...
...
@@ -473,7 +472,6 @@ decoding_fgets(char *s, int size, struct tok_state *tok)
/* We want a 'raw' read. */
line
=
Py_UniversalNewlineFgets
(
s
,
size
,
tok
->
fp
,
NULL
);
warn
=
1
;
break
;
}
else
{
/* We have not yet determined the encoding.
...
...
@@ -490,7 +488,9 @@ decoding_fgets(char *s, int size, struct tok_state *tok)
}
}
#ifndef PGEN
if
(
warn
&&
line
&&
!
tok
->
issued_encoding_warning
&&
!
tok
->
encoding
)
{
/* The default encoding is ASCII, so make sure we don't have any
non-ASCII bytes in it. */
if
(
line
&&
!
tok
->
encoding
)
{
unsigned
char
*
c
;
for
(
c
=
(
unsigned
char
*
)
line
;
*
c
;
c
++
)
if
(
*
c
>
127
)
{
...
...
@@ -508,12 +508,8 @@ decoding_fgets(char *s, int size, struct tok_state *tok)
"but no encoding declared; "
"see http://www.python.org/peps/pep-0263.html for details"
,
badchar
,
tok
->
filename
,
tok
->
lineno
+
1
);
/* We don't use PyErr_WarnExplicit() here because
printing the line in question to e.g. a log file
could result in sensitive information being
exposed. */
PyErr_Warn
(
PyExc_DeprecationWarning
,
buf
);
tok
->
issued_encoding_warning
=
1
;
PyErr_SetString
(
PyExc_SyntaxError
,
buf
);
return
error_ret
(
tok
);
}
#endif
return
line
;
...
...
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