mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
gh-113993: Don't immortalize in PyUnicode_InternInPlace; keep immortalizing in other API (#121364)
* Switch PyUnicode_InternInPlace to _PyUnicode_InternMortal, clarify docs * Document immortality in some functions that take `const char *` This is PyUnicode_InternFromString; PyDict_SetItemString, PyObject_SetAttrString; PyObject_DelAttrString; PyUnicode_InternFromString; and the PyModule_Add convenience functions. Always point out a non-immortalizing alternative. * Don't immortalize user-provided attr names in _ctypes
This commit is contained in:
parent
d7a099d7ae
commit
b4aedb23ae
6 changed files with 82 additions and 10 deletions
|
@ -206,6 +206,13 @@ Object Protocol
|
|||
If *v* is ``NULL``, the attribute is deleted, but this feature is
|
||||
deprecated in favour of using :c:func:`PyObject_DelAttrString`.
|
||||
|
||||
The number of different attribute names passed to this function
|
||||
should be kept small, usually by using a statically allocated string
|
||||
as *attr_name*.
|
||||
For attribute names that aren't known at compile time, prefer calling
|
||||
:c:func:`PyUnicode_FromString` and :c:func:`PyObject_SetAttr` directly.
|
||||
For more details, see :c:func:`PyUnicode_InternFromString`, which may be
|
||||
used internally to create a key object.
|
||||
|
||||
.. c:function:: int PyObject_GenericSetAttr(PyObject *o, PyObject *name, PyObject *value)
|
||||
|
||||
|
@ -231,6 +238,14 @@ Object Protocol
|
|||
specified as a :c:expr:`const char*` UTF-8 encoded bytes string,
|
||||
rather than a :c:expr:`PyObject*`.
|
||||
|
||||
The number of different attribute names passed to this function
|
||||
should be kept small, usually by using a statically allocated string
|
||||
as *attr_name*.
|
||||
For attribute names that aren't known at compile time, prefer calling
|
||||
:c:func:`PyUnicode_FromString` and :c:func:`PyObject_DelAttr` directly.
|
||||
For more details, see :c:func:`PyUnicode_InternFromString`, which may be
|
||||
used internally to create a key object for lookup.
|
||||
|
||||
|
||||
.. c:function:: PyObject* PyObject_GenericGetDict(PyObject *o, void *context)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue