Skip to content

Commit 546cab8

Browse files
authored
gh-106320: Remove private _PyTraceback functions (#108453)
Move private functions to the internal C API (pycore_traceback.h): * _Py_DisplaySourceLine() * _PyTraceback_Add()
1 parent d6ac5c7 commit 546cab8

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

Include/cpython/traceback.h

-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,3 @@ struct _traceback {
1111
int tb_lasti;
1212
int tb_lineno;
1313
};
14-
15-
PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int, int *, PyObject **);
16-
PyAPI_FUNC(void) _PyTraceback_Add(const char *, const char *, int);

Include/internal/pycore_traceback.h

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11+
// Export for '_ctypes' shared extension
12+
PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int, int *, PyObject **);
13+
14+
// Export for 'pyexact' shared extension
15+
PyAPI_FUNC(void) _PyTraceback_Add(const char *, const char *, int);
16+
1117
/* Write the Python traceback into the file 'fd'. For example:
1218
1319
Traceback (most recent call first):

Modules/_ctypes/callproc.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ module _ctypes
101101
#define DONT_USE_SEH
102102
#endif
103103

104-
#include "pycore_runtime.h" // _PyRuntime
105-
#include "pycore_global_objects.h" // _Py_ID()
104+
#include "pycore_runtime.h" // _PyRuntime
105+
#include "pycore_global_objects.h"// _Py_ID()
106+
#include "pycore_traceback.h" // _PyTraceback_Add()
107+
106108
#include "clinic/callproc.c.h"
107109

108110
#define CTYPES_CAPSULE_NAME_PYMEM "_ctypes pymem"

Modules/pyexpat.c

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "Python.h"
66
#include "pycore_import.h" // _PyImport_SetModule()
77
#include "pycore_pyhash.h" // _Py_HashSecret
8+
#include "pycore_traceback.h" // _PyTraceback_Add()
89

910
#include <ctype.h>
1011
#include <stddef.h> // offsetof()

Python/_warnings.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#include "Python.h"
22
#include "pycore_dict.h" // _PyDict_GetItemWithError()
3-
#include "pycore_frame.h"
4-
#include "pycore_initconfig.h"
53
#include "pycore_interp.h" // PyInterpreterState.warnings
64
#include "pycore_long.h" // _PyLong_GetZero()
7-
#include "pycore_pyerrors.h"
5+
#include "pycore_pyerrors.h" // _PyErr_Occurred()
86
#include "pycore_pylifecycle.h" // _Py_IsInterpreterFinalizing()
97
#include "pycore_pystate.h" // _PyThreadState_GET()
108
#include "pycore_sysmodule.h" // _PySys_GetAttr()
9+
#include "pycore_traceback.h" // _Py_DisplaySourceLine()
1110

1211
#include "clinic/_warnings.c.h"
1312

0 commit comments

Comments
 (0)