summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/whatsnew/3.5.rst5
-rw-r--r--Misc/NEWS6
-rw-r--r--Objects/typeobject.c6
3 files changed, 17 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst
index 2a77729..8027fa3 100644
--- a/Doc/whatsnew/3.5.rst
+++ b/Doc/whatsnew/3.5.rst
@@ -561,3 +561,8 @@ Changes in the C API
* 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 --git a/Misc/NEWS b/Misc/NEWS
index d62e695..1c6a90c 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -88,6 +88,12 @@ Build
- 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 --git a/Objects/typeobject.c b/Objects/typeobject.c
index f0ad7fd..d59108e 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2808,6 +2808,12 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
_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;