| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 264f4af commit d8f32be
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1069,6 +1069,9 @@ New Features | |||
| 1069 | 1069 | limited C API. | |
| 1070 | 1070 | (Contributed by Victor Stinner in :gh:`85283`.) | |
| 1071 | 1071 | ||
| 1072 | + * Add :c:func:`PyUnicode_AsUTF8` function to the limited C API. | ||
| 1073 | + (Contributed by Victor Stinner in :gh:`111089`.) | ||
| 1074 | + | ||
| 1072 | 1075 | ||
| 1073 | 1076 | Porting to Python 3.13 | |
| 1074 | 1077 | ---------------------- | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -440,19 +440,6 @@ PyAPI_FUNC(PyObject*) PyUnicode_FromKindAndData( | |||
| 440 | 440 | const void *buffer, | |
| 441 | 441 | Py_ssize_t size); | |
| 442 | 442 | ||
| 443 | - /* --- Manage the default encoding ---------------------------------------- */ | ||
| 444 | - | ||
| 445 | - // Returns a pointer to the default encoding (UTF-8) of the | ||
| 446 | - // Unicode object unicode. | ||
| 447 | - // | ||
| 448 | - // Raise an exception if the string contains embedded null characters. | ||
| 449 | - // Use PyUnicode_AsUTF8AndSize() to accept embedded null characters. | ||
| 450 | - // | ||
| 451 | - // This function caches the UTF-8 encoded string in the Unicode object | ||
| 452 | - // and subsequent calls will return the same string. The memory is released | ||
| 453 | - // when the Unicode object is deallocated. | ||
| 454 | - PyAPI_FUNC(const char *) PyUnicode_AsUTF8(PyObject *unicode); | ||
| 455 | - | ||
| 456 | 443 | ||
| 457 | 444 | /* === Characters Type APIs =============================================== */ | |
| 458 | 445 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -443,7 +443,17 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String( | |||
| 443 | 443 | PyObject *unicode /* Unicode object */ | |
| 444 | 444 | ); | |
| 445 | 445 | ||
| 446 | - // Returns a pointer to the default encoding (UTF-8) of the | ||
| 446 | + // Returns a pointer to the UTF-8 encoding of the Unicode object unicode. | ||
| 447 | + // | ||
| 448 | + // Raise an exception if the string contains embedded null characters. | ||
| 449 | + // Use PyUnicode_AsUTF8AndSize() to accept embedded null characters. | ||
| 450 | + // | ||
| 451 | + // This function caches the UTF-8 encoded string in the Unicode object | ||
| 452 | + // and subsequent calls will return the same string. The memory is released | ||
| 453 | + // when the Unicode object is deallocated. | ||
| 454 | + PyAPI_FUNC(const char *) PyUnicode_AsUTF8(PyObject *unicode); | ||
| 455 | + | ||
| 456 | + // Returns a pointer to the UTF-8 encoding of the | ||
| 447 | 457 | // Unicode object unicode and the size of the encoded representation | |
| 448 | 458 | // in bytes stored in `*size` (if size is not NULL). | |
| 449 | 459 | // | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + Add :c:func:`PyUnicode_AsUTF8` function to the limited C API. Patch by | ||
| 2 | + Victor Stinner. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2478,3 +2478,5 @@ | |||
| 2478 | 2478 | added = '3.13' | |
| 2479 | 2479 | [function.PySys_AuditTuple] | |
| 2480 | 2480 | added = '3.13' | |
| 2481 | + [function.PyUnicode_AsUTF8] | ||
| 2482 | + added = '3.13' | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,7 +44,7 @@ _posixshmem_shm_open_impl(PyObject *module, PyObject *path, int flags, | |||
| 44 | 44 | { | |
| 45 | 45 | int fd; | |
| 46 | 46 | int async_err = 0; | |
| 47 | - const char *name = PyUnicode_AsUTF8AndSize(path, NULL); | ||
| 47 | + const char *name = PyUnicode_AsUTF8(path); | ||
| 48 | 48 | if (name == NULL) { | |
| 49 | 49 | return -1; | |
| 50 | 50 | } | |
@@ -83,7 +83,7 @@ _posixshmem_shm_unlink_impl(PyObject *module, PyObject *path) | |||
| 83 | 83 | { | |
| 84 | 84 | int rv; | |
| 85 | 85 | int async_err = 0; | |
| 86 | - const char *name = PyUnicode_AsUTF8AndSize(path, NULL); | ||
| 86 | + const char *name = PyUnicode_AsUTF8(path); | ||
| 87 | 87 | if (name == NULL) { | |
| 88 | 88 | return NULL; | |
| 89 | 89 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments