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

Skip to content

Commit d68f517

Browse files
committed
As discussed on python-dev, add a mechanism to indicate features
that are in the process of deprecation (PendingDeprecationWarning). Docs could be improved.
1 parent e85ee8d commit d68f517

7 files changed

Lines changed: 48 additions & 16 deletions

File tree

Doc/lib/libexcs.tex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@ \section{Built-in Exceptions}
376376
Base class for warnings about deprecated features.
377377
\end{excdesc}
378378

379+
\begin{excdesc}{PendingDeprecationWarning}
380+
Base class for warnings about features which will be deprecated in the future.
381+
\end{excdesc}
382+
379383
\begin{excdesc}{SyntaxWarning}
380384
Base class for warnings about dubious syntax
381385
\end{excdesc}
@@ -423,6 +427,7 @@ \section{Built-in Exceptions}
423427
+---Warning
424428
+-- UserWarning
425429
+-- DeprecationWarning
430+
+-- PendingDeprecationWarning
426431
+-- SyntaxWarning
427432
+-- OverflowWarning
428433
+-- RuntimeWarning

Doc/tut/tut.tex

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2453,25 +2453,26 @@ \section{The \function{dir()} Function \label{dir}}
24532453
>>> dir(__builtin__)
24542454
['ArithmeticError', 'AssertionError', 'AttributeError',
24552455
'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError',
2456-
'Exception', 'FloatingPointError', 'IOError', 'ImportError',
2456+
'Exception', 'False', 'FloatingPointError', 'IOError', 'ImportError',
24572457
'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt',
24582458
'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented',
24592459
'NotImplementedError', 'OSError', 'OverflowError', 'OverflowWarning',
2460-
'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError',
2461-
'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError',
2462-
'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError',
2463-
'UnicodeError', 'UserWarning', 'ValueError', 'Warning',
2464-
'ZeroDivisionError', '_', '__debug__', '__doc__', '__import__',
2465-
'__name__', 'abs', 'apply', 'buffer', 'callable', 'chr', 'classmethod',
2466-
'cmp', 'coerce', 'compile', 'complex', 'copyright', 'credits', 'delattr',
2467-
'dict', 'dir', 'divmod', 'eval', 'execfile', 'exit', 'file', 'filter',
2468-
'float', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id',
2469-
'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter', 'len',
2470-
'license', 'list', 'locals', 'long', 'map', 'max', 'min', 'object',
2471-
'oct', 'open', 'ord', 'pow', 'property', 'quit', 'range', 'raw_input',
2472-
'reduce', 'reload', 'repr', 'round', 'setattr', 'slice', 'staticmethod',
2473-
'str', 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange',
2474-
'zip']
2460+
'PendingDeprecationWarning', 'ReferenceError',
2461+
'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration',
2462+
'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError',
2463+
'True', 'TypeError', 'UnboundLocalError', 'UnicodeError', 'UserWarning',
2464+
'ValueError', 'Warning', 'ZeroDivisionError', '__debug__', '__doc__',
2465+
'__import__', '__name__', 'abs', 'apply', 'bool', 'buffer',
2466+
'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile', 'complex',
2467+
'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod',
2468+
'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float',
2469+
'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id',
2470+
'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter',
2471+
'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min',
2472+
'object', 'oct', 'open', 'ord', 'pow', 'property', 'quit',
2473+
'range', 'raw_input', 'reduce', 'reload', 'repr', 'round',
2474+
'setattr', 'slice', 'staticmethod', 'str', 'string', 'super',
2475+
'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip']
24752476
\end{verbatim}
24762477

24772478

Doc/whatsnew/whatsnew23.tex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,15 @@ \section{PEP 285: The \class{bool} Type\label{section-bool}}
342342
%\end{itemize}
343343

344344

345+
%\begin{PendingDeprecationWarning}
346+
A new warning PendingDeprecationWarning was added to provide
347+
direction on features which are in the process of being deprecated.
348+
The warning will not be printed by default. To see the pending
349+
deprecations, use -Walways::PendingDeprecationWarning:: on the command line
350+
or warnings.filterwarnings().
351+
%\end{PendingDeprecationWarning}
352+
353+
345354
%======================================================================
346355
\section{Specialized Object Allocator (pymalloc)\label{section-pymalloc}}
347356

Include/pyerrors.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ extern DL_IMPORT(PyObject *) PyExc_MemoryErrorInst;
6666
extern DL_IMPORT(PyObject *) PyExc_Warning;
6767
extern DL_IMPORT(PyObject *) PyExc_UserWarning;
6868
extern DL_IMPORT(PyObject *) PyExc_DeprecationWarning;
69+
extern DL_IMPORT(PyObject *) PyExc_PendingDeprecationWarning;
6970
extern DL_IMPORT(PyObject *) PyExc_SyntaxWarning;
7071
extern DL_IMPORT(PyObject *) PyExc_OverflowWarning;
7172
extern DL_IMPORT(PyObject *) PyExc_RuntimeWarning;

Lib/warnings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,4 @@ def _test():
262262
else:
263263
_processoptions(sys.warnoptions)
264264
filterwarnings("ignore", category=OverflowWarning, append=1)
265+
filterwarnings("ignore", category=PendingDeprecationWarning, append=1)

Misc/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ Type/class unification and new-style classes
66

77
Core and builtins
88

9+
- A new warning PendingDeprecationWarning was added to provide
10+
direction on features which are in the process of being deprecated.
11+
The warning will not be printed by default. To see the pending
12+
deprecations, use -Walways::PendingDeprecationWarning::
13+
as a command line option or warnings.filterwarnings() in code.
14+
915
- A new type object, 'string', is added. This is a common base type
1016
for 'str' and 'unicode', and can be used instead of
1117
types.StringTypes, e.g. to test whether something is "a string":

Python/exceptions.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Exception\n\
110110
|\n\
111111
+-- UserWarning\n\
112112
+-- DeprecationWarning\n\
113+
+-- PendingDeprecationWarning\n\
113114
+-- SyntaxWarning\n\
114115
+-- OverflowWarning\n\
115116
+-- RuntimeWarning";
@@ -919,6 +920,11 @@ static char
919920
DeprecationWarning__doc__[] =
920921
"Base class for warnings about deprecated features.";
921922

923+
static char
924+
PendingDeprecationWarning__doc__[] =
925+
"Base class for warnings about features which will be deprecated "
926+
"in the future.";
927+
922928
static char
923929
SyntaxWarning__doc__[] = "Base class for warnings about dubious syntax.";
924930

@@ -987,6 +993,7 @@ PyObject *PyExc_MemoryErrorInst;
987993
PyObject *PyExc_Warning;
988994
PyObject *PyExc_UserWarning;
989995
PyObject *PyExc_DeprecationWarning;
996+
PyObject *PyExc_PendingDeprecationWarning;
990997
PyObject *PyExc_SyntaxWarning;
991998
PyObject *PyExc_OverflowWarning;
992999
PyObject *PyExc_RuntimeWarning;
@@ -1063,6 +1070,8 @@ static struct {
10631070
{"UserWarning", &PyExc_UserWarning, &PyExc_Warning, UserWarning__doc__},
10641071
{"DeprecationWarning", &PyExc_DeprecationWarning, &PyExc_Warning,
10651072
DeprecationWarning__doc__},
1073+
{"PendingDeprecationWarning", &PyExc_PendingDeprecationWarning, &PyExc_Warning,
1074+
PendingDeprecationWarning__doc__},
10661075
{"SyntaxWarning", &PyExc_SyntaxWarning, &PyExc_Warning, SyntaxWarning__doc__},
10671076
{"OverflowWarning", &PyExc_OverflowWarning, &PyExc_Warning,
10681077
OverflowWarning__doc__},

0 commit comments

Comments
 (0)