summaryrefslogtreecommitdiffstats
path: root/Parser/tokenizer.c
diff options
context:
space:
mode:
authorMarc-André Lemburg <mal@egenix.com>2003-02-17 18:31:57 (GMT)
committerMarc-André Lemburg <mal@egenix.com>2003-02-17 18:31:57 (GMT)
commit1fb1400d0819b2bebf17bf5810fa3f05af7235b4 (patch)
tree728867439998e1418defb204b395d650630bb367 /Parser/tokenizer.c
parent08ea61ad45928e26da9ef2dade7776e61dbfbff2 (diff)
downloadcpython-1fb1400d0819b2bebf17bf5810fa3f05af7235b4.zip
cpython-1fb1400d0819b2bebf17bf5810fa3f05af7235b4.tar.gz
cpython-1fb1400d0819b2bebf17bf5810fa3f05af7235b4.tar.bz2
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.
Diffstat (limited to 'Parser/tokenizer.c')
-rw-r--r--Parser/tokenizer.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 4952a3c..a97720c 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -462,14 +462,20 @@ decoding_fgets(char *s, int size, struct tok_state *tok)
}
}
if (badchar) {
- char buf[200];
- sprintf(buf, "Non-ASCII character '\\x%.2x', "
- "but no declared encoding", badchar);
+ char buf[500];
/* Need to add 1 to the line number, since this line
has not been counted, yet. */
- PyErr_WarnExplicit(PyExc_DeprecationWarning,
- buf, tok->filename, tok->lineno + 1,
- NULL, NULL);
+ sprintf(buf,
+ "Non-ASCII character '\\x%.2x' "
+ "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;
}
#endif