Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
gh-119609: Add PyUnicode_Export() and PyUnicode_Import() functions#119610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
32a373ac42cebc1310b6d1c7810362f459853cd9373a08491a9a90831297c52d8e3d5dda67c89894921af3857d8File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -341,6 +341,72 @@ APIs: | ||
| .. versionadded:: 3.3 | ||
| .. c:function:: const void* PyUnicode_Export(PyObject *unicode, uint32_t requested_formats, Py_ssize_t *nbytes, uint32_t *format) | ||
| Export the contents of the *unicode* string in one of the requested format | ||
| *requested_formats*. | ||
| * On success, set *\*nbytes* and *\*format*, and return the contents. | ||
| * On error, set an exception and return ``NULL``. | ||
| The contents is valid as long as *unicode* is valid. | ||
| The export must be released by :c:func:`PyUnicode_ReleaseExport`. | ||
| The contents of the buffer are valid until they are released. | ||
| The buffer must not be modified. | ||
| *unicode*, *nbytes* and *format* must not be NULL. | ||
| Available formats: | ||
| .. c:namespace:: NULL | ||
| =================================== ======== =========================== | ||
| Constant Identifier Value Description | ||
| =================================== ======== =========================== | ||
| .. c:macro:: PyUnicode_FORMAT_ASCII ``0x01`` ASCII string (``Py_UCS1*``) | ||
| .. c:macro:: PyUnicode_FORMAT_UCS1 ``0x02`` UCS-1 string (``Py_UCS1*``) | ||
| .. c:macro:: PyUnicode_FORMAT_UCS2 ``0x04`` UCS-2 string (``Py_UCS2*``) | ||
| .. c:macro:: PyUnicode_FORMAT_UCS4 ``0x08`` UCS-4 string (``Py_UCS4*``) | ||
| .. c:macro:: PyUnicode_FORMAT_UTF8 ``0x10`` UTF-8 string (``char*``) | ||
| =================================== ======== =========================== | ||
| *requested_formats* can be a single format or a bitwise combination of the | ||
| formats in the table above. | ||
| On success, *\*format* will be set to a single one of the requested flags. | ||
| Note that future versions of Python may introduce additional formats. | ||
| .. versionadded:: 3.14 | ||
| .. c:function:: void PyUnicode_ReleaseExport(PyObject *unicode, const void* data, uint32_t format) | ||
| Release an export created by :c:func:`PyUnicode_Export`. | ||
vstinner marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| Each argument must match the corresponding argument or result of | ||
| a single earlier call to :c:func:`PyUnicode_Export`. | ||
| In particular, this means that you must hold a reference to *unicode* | ||
| while an export is valid. | ||
| .. versionadded:: 3.14 | ||
| .. c:function:: PyObject* PyUnicode_Import(const void *data, Py_ssize_t nbytes, uint32_t format) | ||
| Create a string object from a buffer in an “export format”. | ||
| * Return a reference to a new string object on success. | ||
| * Set an exception and return ``NULL`` on error. | ||
| *data* must not be NULL. *nbytes* must be positive or zero. | ||
| See :c:func:`PyUnicode_Export` for the available formats. | ||
| .. versionadded:: 3.14 | ||
| .. c:function:: PyObject* PyUnicode_FromKindAndData(int kind, const void *buffer, \ | ||
| Py_ssize_t size) | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Add :c:func:`PyUnicode_Export` and :c:func:`PyUnicode_Import` functions to | ||
| export and import strings. Patch by Victor Stinner. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.