As discussed on python-dev, add a mechanism to indicate features

that are in the process of deprecation (PendingDeprecationWarning).
Docs could be improved.
This commit is contained in:
Neal Norwitz 2002-05-29 15:54:55 +00:00
parent e85ee8d815
commit d68f5171eb
7 changed files with 48 additions and 16 deletions

View file

@ -376,6 +376,10 @@ Base class for warnings generated by user code.
Base class for warnings about deprecated features. Base class for warnings about deprecated features.
\end{excdesc} \end{excdesc}
\begin{excdesc}{PendingDeprecationWarning}
Base class for warnings about features which will be deprecated in the future.
\end{excdesc}
\begin{excdesc}{SyntaxWarning} \begin{excdesc}{SyntaxWarning}
Base class for warnings about dubious syntax Base class for warnings about dubious syntax
\end{excdesc} \end{excdesc}
@ -423,6 +427,7 @@ The class hierarchy for built-in exceptions is:
+---Warning +---Warning
+-- UserWarning +-- UserWarning
+-- DeprecationWarning +-- DeprecationWarning
+-- PendingDeprecationWarning
+-- SyntaxWarning +-- SyntaxWarning
+-- OverflowWarning +-- OverflowWarning
+-- RuntimeWarning +-- RuntimeWarning

View file

@ -2453,25 +2453,26 @@ standard module \module{__builtin__}\refbimodindex{__builtin__}:
>>> dir(__builtin__) >>> dir(__builtin__)
['ArithmeticError', 'AssertionError', 'AttributeError', ['ArithmeticError', 'AssertionError', 'AttributeError',
'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError',
'Exception', 'FloatingPointError', 'IOError', 'ImportError', 'Exception', 'False', 'FloatingPointError', 'IOError', 'ImportError',
'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt',
'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented', 'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented',
'NotImplementedError', 'OSError', 'OverflowError', 'OverflowWarning', 'NotImplementedError', 'OSError', 'OverflowError', 'OverflowWarning',
'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'PendingDeprecationWarning', 'ReferenceError',
'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration',
'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError',
'UnicodeError', 'UserWarning', 'ValueError', 'Warning', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeError', 'UserWarning',
'ZeroDivisionError', '_', '__debug__', '__doc__', '__import__', 'ValueError', 'Warning', 'ZeroDivisionError', '__debug__', '__doc__',
'__name__', 'abs', 'apply', 'buffer', 'callable', 'chr', 'classmethod', '__import__', '__name__', 'abs', 'apply', 'bool', 'buffer',
'cmp', 'coerce', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile', 'complex',
'dict', 'dir', 'divmod', 'eval', 'execfile', 'exit', 'file', 'filter', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod',
'float', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float',
'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter', 'len', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id',
'license', 'list', 'locals', 'long', 'map', 'max', 'min', 'object', 'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter',
'oct', 'open', 'ord', 'pow', 'property', 'quit', 'range', 'raw_input', 'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min',
'reduce', 'reload', 'repr', 'round', 'setattr', 'slice', 'staticmethod', 'object', 'oct', 'open', 'ord', 'pow', 'property', 'quit',
'str', 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'range', 'raw_input', 'reduce', 'reload', 'repr', 'round',
'zip'] 'setattr', 'slice', 'staticmethod', 'str', 'string', 'super',
'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip']
\end{verbatim} \end{verbatim}

View file

@ -342,6 +342,15 @@ strings \samp{True} and \samp{False} instead of \samp{1} and \samp{0}.
%\end{itemize} %\end{itemize}
%\begin{PendingDeprecationWarning}
A new warning PendingDeprecationWarning was added to provide
direction on features which are in the process of being deprecated.
The warning will not be printed by default. To see the pending
deprecations, use -Walways::PendingDeprecationWarning:: on the command line
or warnings.filterwarnings().
%\end{PendingDeprecationWarning}
%====================================================================== %======================================================================
\section{Specialized Object Allocator (pymalloc)\label{section-pymalloc}} \section{Specialized Object Allocator (pymalloc)\label{section-pymalloc}}

View file

@ -66,6 +66,7 @@ extern DL_IMPORT(PyObject *) PyExc_MemoryErrorInst;
extern DL_IMPORT(PyObject *) PyExc_Warning; extern DL_IMPORT(PyObject *) PyExc_Warning;
extern DL_IMPORT(PyObject *) PyExc_UserWarning; extern DL_IMPORT(PyObject *) PyExc_UserWarning;
extern DL_IMPORT(PyObject *) PyExc_DeprecationWarning; extern DL_IMPORT(PyObject *) PyExc_DeprecationWarning;
extern DL_IMPORT(PyObject *) PyExc_PendingDeprecationWarning;
extern DL_IMPORT(PyObject *) PyExc_SyntaxWarning; extern DL_IMPORT(PyObject *) PyExc_SyntaxWarning;
extern DL_IMPORT(PyObject *) PyExc_OverflowWarning; extern DL_IMPORT(PyObject *) PyExc_OverflowWarning;
extern DL_IMPORT(PyObject *) PyExc_RuntimeWarning; extern DL_IMPORT(PyObject *) PyExc_RuntimeWarning;

View file

@ -262,3 +262,4 @@ if __name__ == "__main__":
else: else:
_processoptions(sys.warnoptions) _processoptions(sys.warnoptions)
filterwarnings("ignore", category=OverflowWarning, append=1) filterwarnings("ignore", category=OverflowWarning, append=1)
filterwarnings("ignore", category=PendingDeprecationWarning, append=1)

View file

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

View file

@ -110,6 +110,7 @@ Exception\n\
|\n\ |\n\
+-- UserWarning\n\ +-- UserWarning\n\
+-- DeprecationWarning\n\ +-- DeprecationWarning\n\
+-- PendingDeprecationWarning\n\
+-- SyntaxWarning\n\ +-- SyntaxWarning\n\
+-- OverflowWarning\n\ +-- OverflowWarning\n\
+-- RuntimeWarning"; +-- RuntimeWarning";
@ -919,6 +920,11 @@ static char
DeprecationWarning__doc__[] = DeprecationWarning__doc__[] =
"Base class for warnings about deprecated features."; "Base class for warnings about deprecated features.";
static char
PendingDeprecationWarning__doc__[] =
"Base class for warnings about features which will be deprecated "
"in the future.";
static char static char
SyntaxWarning__doc__[] = "Base class for warnings about dubious syntax."; SyntaxWarning__doc__[] = "Base class for warnings about dubious syntax.";
@ -987,6 +993,7 @@ PyObject *PyExc_MemoryErrorInst;
PyObject *PyExc_Warning; PyObject *PyExc_Warning;
PyObject *PyExc_UserWarning; PyObject *PyExc_UserWarning;
PyObject *PyExc_DeprecationWarning; PyObject *PyExc_DeprecationWarning;
PyObject *PyExc_PendingDeprecationWarning;
PyObject *PyExc_SyntaxWarning; PyObject *PyExc_SyntaxWarning;
PyObject *PyExc_OverflowWarning; PyObject *PyExc_OverflowWarning;
PyObject *PyExc_RuntimeWarning; PyObject *PyExc_RuntimeWarning;
@ -1063,6 +1070,8 @@ static struct {
{"UserWarning", &PyExc_UserWarning, &PyExc_Warning, UserWarning__doc__}, {"UserWarning", &PyExc_UserWarning, &PyExc_Warning, UserWarning__doc__},
{"DeprecationWarning", &PyExc_DeprecationWarning, &PyExc_Warning, {"DeprecationWarning", &PyExc_DeprecationWarning, &PyExc_Warning,
DeprecationWarning__doc__}, DeprecationWarning__doc__},
{"PendingDeprecationWarning", &PyExc_PendingDeprecationWarning, &PyExc_Warning,
PendingDeprecationWarning__doc__},
{"SyntaxWarning", &PyExc_SyntaxWarning, &PyExc_Warning, SyntaxWarning__doc__}, {"SyntaxWarning", &PyExc_SyntaxWarning, &PyExc_Warning, SyntaxWarning__doc__},
{"OverflowWarning", &PyExc_OverflowWarning, &PyExc_Warning, {"OverflowWarning", &PyExc_OverflowWarning, &PyExc_Warning,
OverflowWarning__doc__}, OverflowWarning__doc__},