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

Skip to content

Commit 9f00739

Browse files
committed
Added a FutureWarning for constructs that will change semantically in
the future. Changed PEP 237 hex constant warnings from DeprecationWarning to FutureWarning. Updated the documentation.
1 parent 31d2df5 commit 9f00739

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

Include/pyerrors.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning;
7070
PyAPI_DATA(PyObject *) PyExc_SyntaxWarning;
7171
PyAPI_DATA(PyObject *) PyExc_OverflowWarning;
7272
PyAPI_DATA(PyObject *) PyExc_RuntimeWarning;
73+
PyAPI_DATA(PyObject *) PyExc_FutureWarning;
7374

7475

7576
/* Convenience functions */

Python/compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ parsenumber(struct compiling *co, char *s)
11581158
x = (long) PyOS_strtoul(s, &end, 0);
11591159
if (x < 0 && errno == 0) {
11601160
if (PyErr_WarnExplicit(
1161-
PyExc_DeprecationWarning,
1161+
PyExc_FutureWarning,
11621162
"hex/oct constants > sys.maxint "
11631163
"will return positive values "
11641164
"in Python 2.4 and up",

Python/exceptions.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ Exception\n\
112112
+-- PendingDeprecationWarning\n\
113113
+-- SyntaxWarning\n\
114114
+-- OverflowWarning\n\
115-
+-- RuntimeWarning"
115+
+-- RuntimeWarning\n\
116+
+-- FutureWarning"
116117
);
117118

118119

@@ -902,6 +903,10 @@ PyDoc_STRVAR(OverflowWarning__doc__,
902903
PyDoc_STRVAR(RuntimeWarning__doc__,
903904
"Base class for warnings about dubious runtime behavior.");
904905

906+
PyDoc_STRVAR(FutureWarning__doc__,
907+
"Base class for warnings about constructs that will change semantically "
908+
"in the future.");
909+
905910

906911

907912
/* module global functions */
@@ -964,6 +969,7 @@ PyObject *PyExc_PendingDeprecationWarning;
964969
PyObject *PyExc_SyntaxWarning;
965970
PyObject *PyExc_OverflowWarning;
966971
PyObject *PyExc_RuntimeWarning;
972+
PyObject *PyExc_FutureWarning;
967973

968974

969975

@@ -1044,6 +1050,8 @@ static struct {
10441050
OverflowWarning__doc__},
10451051
{"RuntimeWarning", &PyExc_RuntimeWarning, &PyExc_Warning,
10461052
RuntimeWarning__doc__},
1053+
{"FutureWarning", &PyExc_FutureWarning, &PyExc_Warning,
1054+
FutureWarning__doc__},
10471055
/* Sentinel */
10481056
{NULL}
10491057
};

0 commit comments

Comments
 (0)