[Python-checkins] cpython (3.3): Issue #6477: Keep PyNotImplemented_Type and PyNone_Type private.

alexandre.vassalotti python-checkins at python.org
Sun Dec 1 03:04:48 CET 2013


http://hg.python.org/cpython/rev/9fcba15d7685
changeset:   87670:9fcba15d7685
branch:      3.3
parent:      87665:16eba94d3cfe
user:        Alexandre Vassalotti <alexandre at peadrop.com>
date:        Sat Nov 30 17:55:48 2013 -0800
summary:
  Issue #6477: Keep PyNotImplemented_Type and PyNone_Type private.

files:
  Include/object.h  |   4 ++--
  Modules/_pickle.c |   4 ++--
  Objects/object.c  |  12 ++++++------
  3 files changed, 10 insertions(+), 10 deletions(-)


diff --git a/Include/object.h b/Include/object.h
--- a/Include/object.h
+++ b/Include/object.h
@@ -831,8 +831,8 @@
 PyAPI_FUNC(void) Py_IncRef(PyObject *);
 PyAPI_FUNC(void) Py_DecRef(PyObject *);
 
-PyAPI_DATA(PyTypeObject) PyNone_Type;
-PyAPI_DATA(PyTypeObject) PyNotImplemented_Type;
+PyAPI_DATA(PyTypeObject) _PyNone_Type;
+PyAPI_DATA(PyTypeObject) _PyNotImplemented_Type;
 
 /*
 _Py_NoneStruct is an object of undefined type which can be used in contexts
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -2853,13 +2853,13 @@
 static int
 save_type(PicklerObject *self, PyObject *obj)
 {
-    if (obj == (PyObject *)&PyNone_Type) {
+    if (obj == (PyObject *)&_PyNone_Type) {
         return save_singleton_type(self, obj, Py_None);
     }
     else if (obj == (PyObject *)&PyEllipsis_Type) {
         return save_singleton_type(self, obj, Py_Ellipsis);
     }
-    else if (obj == (PyObject *)&PyNotImplemented_Type) {
+    else if (obj == (PyObject *)&_PyNotImplemented_Type) {
         return save_singleton_type(self, obj, Py_NotImplemented);
     }
     return save_global(self, obj, NULL);
diff --git a/Objects/object.c b/Objects/object.c
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1459,7 +1459,7 @@
     0,                          /* nb_index */
 };
 
-PyTypeObject PyNone_Type = {
+PyTypeObject _PyNone_Type = {
     PyVarObject_HEAD_INIT(&PyType_Type, 0)
     "NoneType",
     0,
@@ -1502,7 +1502,7 @@
 
 PyObject _Py_NoneStruct = {
   _PyObject_EXTRA_INIT
-  1, &PyNone_Type
+  1, &_PyNone_Type
 };
 
 /* NotImplemented is an object that can be used to signal that an
@@ -1524,7 +1524,7 @@
     Py_RETURN_NOTIMPLEMENTED;
 }
 
-PyTypeObject PyNotImplemented_Type = {
+PyTypeObject _PyNotImplemented_Type = {
     PyVarObject_HEAD_INIT(&PyType_Type, 0)
     "NotImplementedType",
     0,
@@ -1567,7 +1567,7 @@
 
 PyObject _Py_NotImplementedStruct = {
     _PyObject_EXTRA_INIT
-    1, &PyNotImplemented_Type
+    1, &_PyNotImplemented_Type
 };
 
 void
@@ -1597,10 +1597,10 @@
     if (PyType_Ready(&PyList_Type) < 0)
         Py_FatalError("Can't initialize list type");
 
-    if (PyType_Ready(&PyNone_Type) < 0)
+    if (PyType_Ready(&_PyNone_Type) < 0)
         Py_FatalError("Can't initialize None type");
 
-    if (PyType_Ready(&PyNotImplemented_Type) < 0)
+    if (PyType_Ready(&_PyNotImplemented_Type) < 0)
         Py_FatalError("Can't initialize NotImplemented type");
 
     if (PyType_Ready(&PyTraceBack_Type) < 0)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list