diff --git a/Doc/c-api/concrete.rst b/Doc/c-api/concrete.rst --- a/Doc/c-api/concrete.rst +++ b/Doc/c-api/concrete.rst @@ -106,3 +106,21 @@ gen.rst datetime.rst code.rst + +SimpleNamespace Objects +----------------------- + +.. sectionauthor:: Eric Snow + +A :class:`~types.SimpleNamespace` object is a basic subclass of :class:`object` +that supports a writable namespace by virtue of having a :attr:`__dict__` +attribute. It also provides a helpful repr. + +.. c:function:: PyObject* PyNamespace_New(PyObject *kwds) + + Return a new :class:`types.SimpleNamespace` object on success or *NULL* on + failure. If *kwds* is NULL, the new ``SimpleNamespace`` object will be + empty. Otherwise, it is populated with the contents of *kwds*. *kwds* + may be anything that :func:`PyDict_Update` accepts. + + .. versionadded:: 3.3 diff --git a/Include/namespaceobject.h b/Include/namespaceobject.h --- a/Include/namespaceobject.h +++ b/Include/namespaceobject.h @@ -7,9 +7,9 @@ extern "C" { #endif -PyAPI_DATA(PyTypeObject) _PyNamespace_Type; +PyTypeObject _PyNamespace_Type; -PyAPI_FUNC(PyObject *) _PyNamespace_New(PyObject *kwds); +PyAPI_FUNC(PyObject *) PyNamespace_New(PyObject *kwds); #ifdef __cplusplus } diff --git a/Modules/timemodule.c b/Modules/timemodule.c --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -1226,7 +1226,7 @@ goto error; Py_CLEAR(obj); - ns = _PyNamespace_New(dict); + ns = PyNamespace_New(dict); Py_DECREF(dict); return ns; diff --git a/Objects/namespaceobject.c b/Objects/namespaceobject.c --- a/Objects/namespaceobject.c +++ b/Objects/namespaceobject.c @@ -208,7 +208,7 @@ PyObject * -_PyNamespace_New(PyObject *kwds) +PyNamespace_New(PyObject *kwds) { PyObject *ns = namespace_new(&_PyNamespace_Type, NULL, NULL); if (ns == NULL) diff --git a/Python/sysmodule.c b/Python/sysmodule.c --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1532,7 +1532,7 @@ /* dict ready */ - ns = _PyNamespace_New(impl_info); + ns = PyNamespace_New(impl_info); Py_DECREF(impl_info); return ns;