Commit 4084a3ff authored by Alexandre Vassalotti's avatar Alexandre Vassalotti

Issue #6477: Keep PyNotImplemented_Type and PyNone_Type private.

parent eb2bce5d
...@@ -831,8 +831,8 @@ they can have object code that is not dependent on Python compilation flags. ...@@ -831,8 +831,8 @@ they can have object code that is not dependent on Python compilation flags.
PyAPI_FUNC(void) Py_IncRef(PyObject *); PyAPI_FUNC(void) Py_IncRef(PyObject *);
PyAPI_FUNC(void) Py_DecRef(PyObject *); PyAPI_FUNC(void) Py_DecRef(PyObject *);
PyAPI_DATA(PyTypeObject) PyNone_Type; PyAPI_DATA(PyTypeObject) _PyNone_Type;
PyAPI_DATA(PyTypeObject) PyNotImplemented_Type; PyAPI_DATA(PyTypeObject) _PyNotImplemented_Type;
/* /*
_Py_NoneStruct is an object of undefined type which can be used in contexts _Py_NoneStruct is an object of undefined type which can be used in contexts
......
...@@ -2853,13 +2853,13 @@ save_singleton_type(PicklerObject *self, PyObject *obj, PyObject *singleton) ...@@ -2853,13 +2853,13 @@ save_singleton_type(PicklerObject *self, PyObject *obj, PyObject *singleton)
static int static int
save_type(PicklerObject *self, PyObject *obj) save_type(PicklerObject *self, PyObject *obj)
{ {
if (obj == (PyObject *)&PyNone_Type) { if (obj == (PyObject *)&_PyNone_Type) {
return save_singleton_type(self, obj, Py_None); return save_singleton_type(self, obj, Py_None);
} }
else if (obj == (PyObject *)&PyEllipsis_Type) { else if (obj == (PyObject *)&PyEllipsis_Type) {
return save_singleton_type(self, obj, Py_Ellipsis); 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_singleton_type(self, obj, Py_NotImplemented);
} }
return save_global(self, obj, NULL); return save_global(self, obj, NULL);
......
...@@ -1459,7 +1459,7 @@ static PyNumberMethods none_as_number = { ...@@ -1459,7 +1459,7 @@ static PyNumberMethods none_as_number = {
0, /* nb_index */ 0, /* nb_index */
}; };
PyTypeObject PyNone_Type = { PyTypeObject _PyNone_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0) PyVarObject_HEAD_INIT(&PyType_Type, 0)
"NoneType", "NoneType",
0, 0,
...@@ -1502,7 +1502,7 @@ PyTypeObject PyNone_Type = { ...@@ -1502,7 +1502,7 @@ PyTypeObject PyNone_Type = {
PyObject _Py_NoneStruct = { PyObject _Py_NoneStruct = {
_PyObject_EXTRA_INIT _PyObject_EXTRA_INIT
1, &PyNone_Type 1, &_PyNone_Type
}; };
/* NotImplemented is an object that can be used to signal that an /* NotImplemented is an object that can be used to signal that an
...@@ -1524,7 +1524,7 @@ notimplemented_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) ...@@ -1524,7 +1524,7 @@ notimplemented_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
Py_RETURN_NOTIMPLEMENTED; Py_RETURN_NOTIMPLEMENTED;
} }
PyTypeObject PyNotImplemented_Type = { PyTypeObject _PyNotImplemented_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0) PyVarObject_HEAD_INIT(&PyType_Type, 0)
"NotImplementedType", "NotImplementedType",
0, 0,
...@@ -1567,7 +1567,7 @@ PyTypeObject PyNotImplemented_Type = { ...@@ -1567,7 +1567,7 @@ PyTypeObject PyNotImplemented_Type = {
PyObject _Py_NotImplementedStruct = { PyObject _Py_NotImplementedStruct = {
_PyObject_EXTRA_INIT _PyObject_EXTRA_INIT
1, &PyNotImplemented_Type 1, &_PyNotImplemented_Type
}; };
void void
...@@ -1597,10 +1597,10 @@ _Py_ReadyTypes(void) ...@@ -1597,10 +1597,10 @@ _Py_ReadyTypes(void)
if (PyType_Ready(&PyList_Type) < 0) if (PyType_Ready(&PyList_Type) < 0)
Py_FatalError("Can't initialize list type"); 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"); 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"); Py_FatalError("Can't initialize NotImplemented type");
if (PyType_Ready(&PyTraceBack_Type) < 0) if (PyType_Ready(&PyTraceBack_Type) < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment