Issue #20204: Deprecation warning is now raised for builtin type without the

__module__ attribute.
This commit is contained in:
Serhiy Storchaka 2015-03-01 10:03:02 +02:00
parent 50adb9fc32
commit 490055a167
3 changed files with 17 additions and 0 deletions

View File

@ -561,3 +561,8 @@ Changes in the C API
* Removed non-documented macro :c:macro:`PyObject_REPR` which leaked references. * Removed non-documented macro :c:macro:`PyObject_REPR` which leaked references.
Use format character ``%R`` in :c:func:`PyUnicode_FromFormat`-like functions Use format character ``%R`` in :c:func:`PyUnicode_FromFormat`-like functions
to format the :func:`repr` of the object. to format the :func:`repr` of the object.
* Because the lack of the :attr:`__module__` attribute breaks pickling and
introspection, a deprecation warning now is raised for builtin type without
the :attr:`__module__` attribute. Would be an AttributeError in future.
(:issue:`20204`)

View File

@ -88,6 +88,12 @@ Build
- Issue #23445: pydebug builds now use "gcc -Og" where possible, to make - Issue #23445: pydebug builds now use "gcc -Og" where possible, to make
the resulting executable faster. the resulting executable faster.
C API
-----
- Issue #20204: Deprecation warning is now raised for builtin type without the
__module__ attribute.
Windows Windows
------- -------

View File

@ -2808,6 +2808,12 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
_PyDict_SetItemId(type->tp_dict, &PyId___module__, _PyDict_SetItemId(type->tp_dict, &PyId___module__,
PyUnicode_FromStringAndSize( PyUnicode_FromStringAndSize(
spec->name, (Py_ssize_t)(s - spec->name))); spec->name, (Py_ssize_t)(s - spec->name)));
else {
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
"builtin type %.200s has no the __module__ attribute",
spec->name))
goto fail;
}
return (PyObject*)res; return (PyObject*)res;