Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0d0520a

Browse files
authored
gh-107211: No longer export internal functions (3) (#107215)
No longer export these 14 internal C API functions: * _PySys_Audit() * _PySys_SetAttr() * _PyTraceBack_FromFrame() * _PyTraceBack_Print_Indented() * _PyUnicode_FormatAdvancedWriter() * _PyUnicode_ScanIdentifier() * _PyWarnings_Init() * _Py_DumpASCII() * _Py_DumpDecimal() * _Py_DumpHexadecimal() * _Py_DumpTraceback() * _Py_DumpTracebackThreads() * _Py_WriteIndent() * _Py_WriteIndentedMargin()
1 parent 5a61692 commit 0d0520a

File tree

7 files changed

+30
-23
lines changed

7 files changed

+30
-23
lines changed

Include/internal/pycore_sysmodule.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11-
PyAPI_FUNC(int) _PySys_Audit(
11+
extern int _PySys_Audit(
1212
PyThreadState *tstate,
1313
const char *event,
1414
const char *argFormat,
@@ -18,7 +18,7 @@ PyAPI_FUNC(int) _PySys_Audit(
1818
PyAPI_FUNC() to not export the symbol. */
1919
extern void _PySys_ClearAuditHooks(PyThreadState *tstate);
2020

21-
PyAPI_FUNC(int) _PySys_SetAttr(PyObject *, PyObject *);
21+
extern int _PySys_SetAttr(PyObject *, PyObject *);
2222

2323
extern int _PySys_ClearAttrString(PyInterpreterState *interp,
2424
const char *name, int verbose);

Include/internal/pycore_time.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,12 @@ extern int _PyTime_GetPerfCounterWithInfo(
324324

325325
// Create a deadline.
326326
// Pseudo code: _PyTime_GetMonotonicClock() + timeout.
327+
// Export for '_ssl' shared extension.
327328
PyAPI_FUNC(_PyTime_t) _PyDeadline_Init(_PyTime_t timeout);
328329

329330
// Get remaining time from a deadline.
330331
// Pseudo code: deadline - _PyTime_GetMonotonicClock().
332+
// Export for '_ssl' shared extension.
331333
PyAPI_FUNC(_PyTime_t) _PyDeadline_Get(_PyTime_t deadline);
332334

333335

Include/internal/pycore_traceback.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern "C" {
2525
2626
This function is signal safe. */
2727

28-
PyAPI_FUNC(void) _Py_DumpTraceback(
28+
extern void _Py_DumpTraceback(
2929
int fd,
3030
PyThreadState *tstate);
3131

@@ -52,7 +52,7 @@ PyAPI_FUNC(void) _Py_DumpTraceback(
5252
5353
This function is signal safe. */
5454

55-
PyAPI_FUNC(const char*) _Py_DumpTracebackThreads(
55+
extern const char* _Py_DumpTracebackThreads(
5656
int fd,
5757
PyInterpreterState *interp,
5858
PyThreadState *current_tstate);
@@ -64,23 +64,23 @@ PyAPI_FUNC(const char*) _Py_DumpTracebackThreads(
6464
string which is not ready (PyUnicode_WCHAR_KIND).
6565
6666
This function is signal safe. */
67-
PyAPI_FUNC(void) _Py_DumpASCII(int fd, PyObject *text);
67+
extern void _Py_DumpASCII(int fd, PyObject *text);
6868

6969
/* Format an integer as decimal into the file descriptor fd.
7070
7171
This function is signal safe. */
72-
PyAPI_FUNC(void) _Py_DumpDecimal(
72+
extern void _Py_DumpDecimal(
7373
int fd,
7474
size_t value);
7575

7676
/* Format an integer as hexadecimal with width digits into fd file descriptor.
7777
The function is signal safe. */
78-
PyAPI_FUNC(void) _Py_DumpHexadecimal(
78+
extern void _Py_DumpHexadecimal(
7979
int fd,
8080
uintptr_t value,
8181
Py_ssize_t width);
8282

83-
PyAPI_FUNC(PyObject*) _PyTraceBack_FromFrame(
83+
extern PyObject* _PyTraceBack_FromFrame(
8484
PyObject *tb_next,
8585
PyFrameObject *frame);
8686

@@ -89,11 +89,11 @@ PyAPI_FUNC(PyObject*) _PyTraceBack_FromFrame(
8989

9090
/* Write the traceback tb to file f. Prefix each line with
9191
indent spaces followed by the margin (if it is not NULL). */
92-
PyAPI_FUNC(int) _PyTraceBack_Print_Indented(
92+
extern int _PyTraceBack_Print_Indented(
9393
PyObject *tb, int indent, const char* margin,
9494
const char *header_margin, const char *header, PyObject *f);
95-
PyAPI_FUNC(int) _Py_WriteIndentedMargin(int, const char*, PyObject *);
96-
PyAPI_FUNC(int) _Py_WriteIndent(int, PyObject *);
95+
extern int _Py_WriteIndentedMargin(int, const char*, PyObject *);
96+
extern int _Py_WriteIndent(int, PyObject *);
9797

9898
#ifdef __cplusplus
9999
}

Include/internal/pycore_tracemalloc.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,16 @@ struct _tracemalloc_runtime_state {
117117
}
118118

119119

120-
/* Get the traceback where a memory block was allocated.
121-
122-
Return a tuple of (filename: str, lineno: int) tuples.
123-
124-
Return None if the tracemalloc module is disabled or if the memory block
125-
is not tracked by tracemalloc.
126-
127-
Raise an exception and return NULL on error. */
120+
// Get the traceback where a memory block was allocated.
121+
//
122+
// Return a tuple of (filename: str, lineno: int) tuples.
123+
//
124+
// Return None if the tracemalloc module is disabled or if the memory block
125+
// is not tracked by tracemalloc.
126+
//
127+
// Raise an exception and return NULL on error.
128+
//
129+
// Export for '_testinternalcapi' shared extension.
128130
PyAPI_FUNC(PyObject*) _PyTraceMalloc_GetTraceback(
129131
unsigned int domain,
130132
uintptr_t ptr);

Include/internal/pycore_typeobject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ extern static_builtin_state * _PyStaticType_GetState(PyInterpreterState *, PyTyp
114114
extern void _PyStaticType_ClearWeakRefs(PyInterpreterState *, PyTypeObject *type);
115115
extern void _PyStaticType_Dealloc(PyInterpreterState *, PyTypeObject *);
116116

117+
// Export for 'math' shared extension
117118
PyAPI_FUNC(PyObject *) _PyType_GetDict(PyTypeObject *);
118119
extern PyObject * _PyType_GetBases(PyTypeObject *type);
119120
extern PyObject * _PyType_GetMRO(PyTypeObject *type);

Include/internal/pycore_unicodeobject.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ _PyUnicodeWriter_Dealloc(_PyUnicodeWriter *writer);
187187

188188
/* Format the object based on the format_spec, as defined in PEP 3101
189189
(Advanced String Formatting). */
190-
PyAPI_FUNC(int) _PyUnicode_FormatAdvancedWriter(
190+
extern int _PyUnicode_FormatAdvancedWriter(
191191
_PyUnicodeWriter *writer,
192192
PyObject *obj,
193193
PyObject *format_spec,
@@ -245,8 +245,9 @@ extern PyObject* _PyUnicode_DecodeUnicodeEscapeStateful(
245245
const char *errors, /* error handling */
246246
Py_ssize_t *consumed); /* bytes consumed */
247247

248-
/* Helper for PyUnicode_DecodeUnicodeEscape that detects invalid escape
249-
chars. */
248+
// Helper for PyUnicode_DecodeUnicodeEscape that detects invalid escape
249+
// chars.
250+
// Export for test_peg_generator.
250251
PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeInternal(
251252
const char *string, /* Unicode-Escape encoded string */
252253
Py_ssize_t length, /* size of string */
@@ -369,6 +370,7 @@ PyAPI_FUNC(int) _PyUnicode_Equal(PyObject *, PyObject *);
369370
extern int _PyUnicode_WideCharString_Converter(PyObject *, void *);
370371
extern int _PyUnicode_WideCharString_Opt_Converter(PyObject *, void *);
371372

373+
// Export for test_peg_generator
372374
PyAPI_FUNC(Py_ssize_t) _PyUnicode_ScanIdentifier(PyObject *);
373375

374376
/* --- Runtime lifecycle -------------------------------------------------- */

Include/internal/pycore_warnings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct _warnings_runtime_state {
1919

2020
extern int _PyWarnings_InitState(PyInterpreterState *interp);
2121

22-
PyAPI_FUNC(PyObject*) _PyWarnings_Init(void);
22+
extern PyObject* _PyWarnings_Init(void);
2323

2424
extern void _PyErr_WarnUnawaitedCoroutine(PyObject *coro);
2525
extern void _PyErr_WarnUnawaitedAgenMethod(PyAsyncGenObject *agen, PyObject *method);

0 commit comments

Comments
 (0)