Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 715eca9

Browse files
committed
Use PyErr_WarnExplicit() to warn about hex/oct constants, so the
correct filename and line number are reported.
1 parent 7a1703d commit 715eca9

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

Python/compile.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,10 +1157,15 @@ parsenumber(struct compiling *co, char *s)
11571157
if (s[0] == '0') {
11581158
x = (long) PyOS_strtoul(s, &end, 0);
11591159
if (x < 0 && errno == 0) {
1160-
if (PyErr_Warn(PyExc_DeprecationWarning,
1161-
"hex/oct constants > sys.maxint "
1162-
"will return positive values "
1163-
"in Python 2.4 and up") < 0)
1160+
if (PyErr_WarnExplicit(
1161+
PyExc_DeprecationWarning,
1162+
"hex/oct constants > sys.maxint "
1163+
"will return positive values "
1164+
"in Python 2.4 and up",
1165+
co->c_filename,
1166+
co->c_lineno,
1167+
NULL,
1168+
NULL) < 0)
11641169
return NULL;
11651170
errno = 0; /* Might be changed by PyErr_Warn() */
11661171
}

0 commit comments

Comments
 (0)