diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-02-23 00:21:43 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-02-23 00:21:43 (GMT) |
commit | bd475115c4fb0dda55f3d1f4443bff58abd1203f (patch) | |
tree | 5d8ebf7b06289fe9bbe5e8381185bd308d20bb2a /Doc/c-api/module.rst | |
parent | 501c09a754bc329ed9b3d0c1be0c51ccd6687c6c (diff) | |
download | cpython-bd475115c4fb0dda55f3d1f4443bff58abd1203f.zip cpython-bd475115c4fb0dda55f3d1f4443bff58abd1203f.tar.gz cpython-bd475115c4fb0dda55f3d1f4443bff58abd1203f.tar.bz2 |
Issue #3080: Add PyModule_GetNameObject()
repr(module) uses %R to format module name and filenames, instead of '%s' and
'%U', so surrogates from undecodable bytes in a filename (PEP 383) are escaped.
Diffstat (limited to 'Doc/c-api/module.rst')
-rw-r--r-- | Doc/c-api/module.rst | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/Doc/c-api/module.rst b/Doc/c-api/module.rst index 1a64947..a31046c 100644 --- a/Doc/c-api/module.rst +++ b/Doc/c-api/module.rst @@ -52,7 +52,7 @@ There are only a few functions special to module objects. manipulate a module's :attr:`__dict__`. -.. c:function:: char* PyModule_GetName(PyObject *module) +.. c:function:: PyObject* PyModule_GetNameObject(PyObject *module) .. index:: single: __name__ (module attribute) @@ -61,15 +61,13 @@ There are only a few functions special to module objects. Return *module*'s :attr:`__name__` value. If the module does not provide one, or if it is not a string, :exc:`SystemError` is raised and *NULL* is returned. + .. versionadded:: 3.3 -.. c:function:: char* PyModule_GetFilename(PyObject *module) - Similar to :c:func:`PyModule_GetFilenameObject` but return the filename - encoded to 'utf-8'. +.. c:function:: char* PyModule_GetName(PyObject *module) - .. deprecated:: 3.2 - :c:func:`PyModule_GetFilename` raises :c:type:`UnicodeEncodeError` on - unencodable filenames, use :c:func:`PyModule_GetFilenameObject` instead. + Similar to :c:func:`PyModule_GetNameObject` but return the name encoded to + ``'utf-8'``. .. c:function:: PyObject* PyModule_GetFilenameObject(PyObject *module) @@ -86,6 +84,16 @@ There are only a few functions special to module objects. .. versionadded:: 3.2 +.. c:function:: char* PyModule_GetFilename(PyObject *module) + + Similar to :c:func:`PyModule_GetFilenameObject` but return the filename + encoded to 'utf-8'. + + .. deprecated:: 3.2 + :c:func:`PyModule_GetFilename` raises :c:type:`UnicodeEncodeError` on + unencodable filenames, use :c:func:`PyModule_GetFilenameObject` instead. + + .. c:function:: void* PyModule_GetState(PyObject *module) Return the "state" of the module, that is, a pointer to the block of memory |