Skip to content

Commit 35e650e

Browse files
authored
Merge pull request #33 from nanjekyejoannah/fix_regression
Fix regression
2 parents 5ab74fb + db5a6a0 commit 35e650e

11 files changed

Lines changed: 48 additions & 7 deletions

File tree

Doc/c-api/exceptions.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,7 @@ the variables:
690690
single: PyExc_SyntaxWarning
691691
single: PyExc_UnicodeWarning
692692
single: PyExc_UserWarning
693+
single: PyExc_Py3xWarning
693694
694695
+------------------------------------------+---------------------------------+----------+
695696
| C Name | Python Name | Notes |
@@ -714,6 +715,8 @@ the variables:
714715
+------------------------------------------+---------------------------------+----------+
715716
| :c:data:`PyExc_UserWarning` | :exc:`UserWarning` | |
716717
+------------------------------------------+---------------------------------+----------+
718+
| :c:data:`PyExc_3xWarning` | :exc:`Py3xWarning` | |
719+
+------------------------------------------+---------------------------------+----------+
717720
718721
Notes:
719722

Doc/library/exceptions.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,10 @@ module for more information.
530530

531531
.. versionadded:: 2.6
532532

533+
.. exception:: Py3xWarning
534+
535+
Base class for warnings about 3.x compatibility.
536+
533537

534538
Exception hierarchy
535539
-------------------

Doc/library/warnings.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ following warnings category classes are currently defined:
9494
| :exc:`BytesWarning` | Base category for warnings related to |
9595
| | bytes and bytearray. |
9696
+----------------------------------+-----------------------------------------------+
97+
| :exc:`Py3xWarning` | Base class for warnings about 3.x |
98+
| compatibility | |
99+
+----------------------------------+-----------------------------------------------+
97100

98101
While these are technically built-in exceptions, they are documented here,
99102
because conceptually they belong to the warnings mechanism.

Include/pyerrors.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ PyAPI_DATA(PyObject *) PyExc_FutureWarning;
177177
PyAPI_DATA(PyObject *) PyExc_ImportWarning;
178178
PyAPI_DATA(PyObject *) PyExc_UnicodeWarning;
179179
PyAPI_DATA(PyObject *) PyExc_BytesWarning;
180+
PyAPI_DATA(PyObject *) PyExc_Py3xWarning;
180181

181182

182183
/* Convenience functions */

Lib/test/exception_hierarchy.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ BaseException
4545
+-- SyntaxWarning
4646
+-- UserWarning
4747
+-- FutureWarning
48+
+-- Py3xWarning
4849
+-- ImportWarning
4950
+-- UnicodeWarning
5051
+-- BytesWarning

Lib/test/test_ast.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,12 @@ def test_literal_eval_issue4907(self):
494494

495495

496496
def test_main():
497-
with test_support.check_py3k_warnings(("backquote not supported",
498-
SyntaxWarning)):
497+
deprecations = []
498+
if sys.py3kwarning:
499+
deprecations += [
500+
("backquote not supported", SyntaxWarning),
501+
("the L suffix is not supported in 3.x; drop the suffix", SyntaxWarning)]
502+
with test_support.check_warnings(*deprecations):
499503
test_support.run_unittest(AST_Tests, ASTHelpers_Test)
500504

501505
def main():

Lib/test/test_optparse.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,15 @@ def test_numeric_options(self):
16541654
self.assertParseFail(["-l", "0x12x"],
16551655
"option -l: invalid long integer value: '0x12x'")
16561656

1657+
def test_parse_num_3k_warnings(self):
1658+
expected = 'the L suffix is not supported in 3.x; drop the suffix'
1659+
with test_support.check_warnings():
1660+
x = 10L
1661+
y = 8L
1662+
z = x + y
1663+
a = x * y
1664+
b = x - y
1665+
16571666

16581667
def test_main():
16591668
test_support.run_unittest(__name__)

Misc/Vim/python.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ if exists("python_highlight_exceptions")
9292
syn keyword pythonException ReferenceError RuntimeError RuntimeWarning
9393
syn keyword pythonException StandardError StopIteration SyntaxError
9494
syn keyword pythonException SyntaxWarning SystemError SystemExit TabError
95+
syn keyword pythonException Py3xWarning SystemError SystemExit Warning
9596
syn keyword pythonException TypeError UnboundLocalError UnicodeDecodeError
9697
syn keyword pythonException UnicodeEncodeError UnicodeError
9798
syn keyword pythonException UnicodeTranslateError UnicodeWarning

Objects/exceptions.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,6 +1981,13 @@ SimpleExtendsException(PyExc_Warning, SyntaxWarning,
19811981
"Base class for warnings about dubious syntax.");
19821982

19831983

1984+
/*
1985+
* 3xWarning extends Warning
1986+
*/
1987+
SimpleExtendsException(PyExc_Warning, Py3xWarning,
1988+
"Base class for warnings about 3.x compatibility.");
1989+
1990+
19841991
/*
19851992
* RuntimeWarning extends Warning
19861993
*/
@@ -2104,6 +2111,7 @@ _PyExc_Init(void)
21042111
PRE_INIT(ImportWarning)
21052112
PRE_INIT(UnicodeWarning)
21062113
PRE_INIT(BytesWarning)
2114+
PRE_INIT(Py3xWarning)
21072115

21082116
m = Py_InitModule4("exceptions", functions, exceptions_doc,
21092117
(PyObject *)NULL, PYTHON_API_VERSION);
@@ -2173,6 +2181,7 @@ _PyExc_Init(void)
21732181
POST_INIT(ImportWarning)
21742182
POST_INIT(UnicodeWarning)
21752183
POST_INIT(BytesWarning)
2184+
POST_INIT(Py3xWarning)
21762185

21772186
PyExc_MemoryErrorInst = BaseException_new(&_PyExc_MemoryError, NULL, NULL);
21782187
if (!PyExc_MemoryErrorInst)

PC/os2emx/python27.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,7 @@ EXPORTS
819819
"PyExc_DeprecationWarning"
820820
"PyExc_PendingDeprecationWarning"
821821
"PyExc_SyntaxWarning"
822+
"PyExc_Py3xWarning"
822823
"PyExc_RuntimeWarning"
823824
"PyExc_FutureWarning"
824825
"PyExc_ImportWarning"

0 commit comments

Comments
 (0)