mirror of
https://github.com/python/cpython.git
synced 2025-11-11 22:55:08 +00:00
Add URL for PEP to the source code encoding warning.
Remove the usage of PyErr_WarnExplicit() since this could cause sensitive information from the source files to appear in e.g. log files.
This commit is contained in:
parent
08ea61ad45
commit
1fb1400d08
1 changed files with 12 additions and 6 deletions
|
|
@ -462,14 +462,20 @@ decoding_fgets(char *s, int size, struct tok_state *tok)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (badchar) {
|
if (badchar) {
|
||||||
char buf[200];
|
char buf[500];
|
||||||
sprintf(buf, "Non-ASCII character '\\x%.2x', "
|
|
||||||
"but no declared encoding", badchar);
|
|
||||||
/* Need to add 1 to the line number, since this line
|
/* Need to add 1 to the line number, since this line
|
||||||
has not been counted, yet. */
|
has not been counted, yet. */
|
||||||
PyErr_WarnExplicit(PyExc_DeprecationWarning,
|
sprintf(buf,
|
||||||
buf, tok->filename, tok->lineno + 1,
|
"Non-ASCII character '\\x%.2x' "
|
||||||
NULL, NULL);
|
"in file %.200s on line %i, "
|
||||||
|
"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;
|
tok->issued_encoding_warning = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue