mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
Slightly revised version of patch #1538956:
Replace UnicodeDecodeErrors raised during == and != compares of Unicode and other objects with a new UnicodeWarning. All other comparisons continue to raise exceptions. Exceptions other than UnicodeDecodeErrors are also left untouched.
This commit is contained in:
parent
e6dd31c50b
commit
040f76b79c
11 changed files with 170 additions and 36 deletions
|
@ -1948,6 +1948,14 @@ SimpleExtendsException(PyExc_Warning, ImportWarning,
|
|||
"Base class for warnings about probable mistakes in module imports");
|
||||
|
||||
|
||||
/*
|
||||
* UnicodeWarning extends Warning
|
||||
*/
|
||||
SimpleExtendsException(PyExc_Warning, UnicodeWarning,
|
||||
"Base class for warnings about Unicode related problems, mostly\n"
|
||||
"related to conversion problems.");
|
||||
|
||||
|
||||
/* Pre-computed MemoryError instance. Best to create this as early as
|
||||
* possible and not wait until a MemoryError is actually raised!
|
||||
*/
|
||||
|
@ -2048,6 +2056,7 @@ _PyExc_Init(void)
|
|||
PRE_INIT(RuntimeWarning)
|
||||
PRE_INIT(FutureWarning)
|
||||
PRE_INIT(ImportWarning)
|
||||
PRE_INIT(UnicodeWarning)
|
||||
|
||||
m = Py_InitModule4("exceptions", functions, exceptions_doc,
|
||||
(PyObject *)NULL, PYTHON_API_VERSION);
|
||||
|
@ -2113,6 +2122,7 @@ _PyExc_Init(void)
|
|||
POST_INIT(RuntimeWarning)
|
||||
POST_INIT(FutureWarning)
|
||||
POST_INIT(ImportWarning)
|
||||
POST_INIT(UnicodeWarning)
|
||||
|
||||
PyExc_MemoryErrorInst = BaseException_new(&_PyExc_MemoryError, NULL, NULL);
|
||||
if (!PyExc_MemoryErrorInst)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue