Skip to content

Commit 9d6a2d0

Browse files
authored
bpo-43795: PEP-652: Clean up the stable ABI/limited API (GH-25482)
- `_Py_EncodeLocaleRaw`, which is private by name, undocumented, and wasn't exported in `python3.dll`, is moved to a private header. - `_Py_HashSecret_Initialized`, again private by name, undocumented, and not exported in `python3.dll`, is excluded with `Py_LIMITED_API`. - `PyMarshal_*` and `PyMember_*One` functions, declared in private headers and not exported in `python3.dll`, are removed from `Doc/data/stable_abi.dat`. - `PyMem_Calloc` which *was* exported in `python3dll.c`, is moved to public headers where it joins its other `PyMem_*` friends. Only the last change is documented in the blurb; others are not user-visible. (Nothing uses `Doc/data/stable_abi.dat` yet.) https://bugs.python.org/issue43795
1 parent e7cc64e commit 9d6a2d0

File tree

7 files changed

+7
-14
lines changed

7 files changed

+7
-14
lines changed

Doc/data/stable_abi.dat

+1-6
Original file line numberDiff line numberDiff line change
@@ -351,16 +351,11 @@ PyMapping_Length
351351
PyMapping_SetItemString
352352
PyMapping_Size
353353
PyMapping_Values
354-
PyMarshal_ReadObjectFromString
355-
PyMarshal_WriteLongToFile
356-
PyMarshal_WriteObjectToFile
357-
PyMarshal_WriteObjectToString
354+
PyMem_Calloc
358355
PyMem_Free
359356
PyMem_Malloc
360357
PyMem_Realloc
361358
PyMemberDescr_Type
362-
PyMember_GetOne
363-
PyMember_SetOne
364359
PyMemoryView_FromMemory
365360
PyMemoryView_FromObject
366361
PyMemoryView_GetContiguous

Include/cpython/fileutils.h

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ PyAPI_FUNC(int) _Py_EncodeLocaleEx(
3232
int current_locale,
3333
_Py_error_handler errors);
3434

35+
PyAPI_FUNC(char*) _Py_EncodeLocaleRaw(
36+
const wchar_t *text,
37+
size_t *error_pos);
3538

3639
PyAPI_FUNC(PyObject *) _Py_device_encoding(int);
3740

Include/cpython/pymem.h

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ PyAPI_FUNC(void) PyMem_RawFree(void *ptr);
1010
/* Try to get the allocators name set by _PyMem_SetupAllocators(). */
1111
PyAPI_FUNC(const char*) _PyMem_GetCurrentAllocatorName(void);
1212

13-
PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize);
14-
1513
/* strdup() using PyMem_RawMalloc() */
1614
PyAPI_FUNC(char *) _PyMem_RawStrdup(const char *str);
1715

Include/fileutils.h

-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ PyAPI_FUNC(wchar_t *) Py_DecodeLocale(
1212
PyAPI_FUNC(char*) Py_EncodeLocale(
1313
const wchar_t *text,
1414
size_t *error_pos);
15-
16-
PyAPI_FUNC(char*) _Py_EncodeLocaleRaw(
17-
const wchar_t *text,
18-
size_t *error_pos);
1915
#endif
2016

2117
#ifndef Py_LIMITED_API

Include/pyhash.h

-2
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,13 @@ typedef union {
7676
} expat;
7777
} _Py_HashSecret_t;
7878
PyAPI_DATA(_Py_HashSecret_t) _Py_HashSecret;
79-
#endif
8079

8180
#ifdef Py_DEBUG
8281
PyAPI_DATA(int) _Py_HashSecret_Initialized;
8382
#endif
8483

8584

8685
/* hash function definition */
87-
#ifndef Py_LIMITED_API
8886
typedef struct {
8987
Py_hash_t (*const hash)(const void *, Py_ssize_t);
9088
const char *name;

Include/pymem.h

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ extern "C" {
5050
*/
5151

5252
PyAPI_FUNC(void *) PyMem_Malloc(size_t size);
53+
PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize);
5354
PyAPI_FUNC(void *) PyMem_Realloc(void *ptr, size_t new_size);
5455
PyAPI_FUNC(void) PyMem_Free(void *ptr);
5556

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:c:func:`PyMem_Calloc` is now available in the limited C API
2+
(``Py_LIMITED_API``).

0 commit comments

Comments
 (0)