changeset: 94796:d6dff5a5290a user: Serhiy Storchaka date: Sun Mar 01 10:03:02 2015 +0200 files: Doc/whatsnew/3.5.rst Misc/NEWS Objects/typeobject.c description: Issue #20204: Deprecation warning is now raised for builtin type without the __module__ attribute. diff -r 3244142eeafb -r d6dff5a5290a Doc/whatsnew/3.5.rst --- a/Doc/whatsnew/3.5.rst Sun Mar 01 09:07:10 2015 +0200 +++ b/Doc/whatsnew/3.5.rst Sun Mar 01 10:03:02 2015 +0200 @@ -561,3 +561,8 @@ * Removed non-documented macro :c:macro:`PyObject_REPR` which leaked references. Use format character ``%R`` in :c:func:`PyUnicode_FromFormat`-like functions 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`) diff -r 3244142eeafb -r d6dff5a5290a Misc/NEWS --- a/Misc/NEWS Sun Mar 01 09:07:10 2015 +0200 +++ b/Misc/NEWS Sun Mar 01 10:03:02 2015 +0200 @@ -88,6 +88,12 @@ - Issue #23445: pydebug builds now use "gcc -Og" where possible, to make the resulting executable faster. +C API +----- + +- Issue #20204: Deprecation warning is now raised for builtin type without the + __module__ attribute. + Windows ------- diff -r 3244142eeafb -r d6dff5a5290a Objects/typeobject.c --- a/Objects/typeobject.c Sun Mar 01 09:07:10 2015 +0200 +++ b/Objects/typeobject.c Sun Mar 01 10:03:02 2015 +0200 @@ -2808,6 +2808,12 @@ _PyDict_SetItemId(type->tp_dict, &PyId___module__, PyUnicode_FromStringAndSize( 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;