Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Keep some C-API functions private for now.
  • Loading branch information
ericsnowcurrently committed Oct 2, 2023
commit 0ad6f4190330e84018d7df74ef7e17b2cb90cf9e
2 changes: 0 additions & 2 deletions Include/cpython/pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@ PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);

PyAPI_FUNC(PyInterpreterState *) _PyInterpreterState_LookUpID(int64_t);

/* Frame evaluation API */

typedef PyObject* (*_PyFrameEvalFunction)(PyThreadState *tstate, struct _PyInterpreterFrame *, int);
Expand Down
3 changes: 3 additions & 0 deletions Include/internal/pycore_interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ struct _xidregitem {
crossinterpdatafunc getdata;
};

// Export for the _xxinterpchannels module.
PyAPI_FUNC(PyInterpreterState *) _PyInterpreterState_LookUpID(int64_t);

extern int _PyInterpreterState_IDInitref(PyInterpreterState *);
extern int _PyInterpreterState_IDIncref(PyInterpreterState *);
extern void _PyInterpreterState_IDDecref(PyInterpreterState *);
Expand Down
21 changes: 21 additions & 0 deletions Include/internal/pycore_pybuffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef Py_INTERNAL_PYBUFFER_H
#define Py_INTERNAL_PYBUFFER_H
#ifdef __cplusplus
extern "C" {
#endif

#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif


// Exported for the _xxinterpchannels module.
PyAPI_FUNC(int) _PyBuffer_ReleaseInInterpreter(
PyInterpreterState *interp, Py_buffer *view);
PyAPI_FUNC(int) _PyBuffer_ReleaseInInterpreterAndRawFree(
PyInterpreterState *interp, Py_buffer *view);

#ifdef __cplusplus
}
#endif
#endif /* !Py_INTERNAL_PYBUFFER_H */
4 changes: 0 additions & 4 deletions Include/pybuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ PyAPI_FUNC(int) PyBuffer_FillInfo(Py_buffer *view, PyObject *o, void *buf,

/* Releases a Py_buffer obtained from getbuffer ParseTuple's "s*". */
PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view);
PyAPI_FUNC(int) PyUnstable_Buffer_ReleaseInInterpreter(
PyInterpreterState *interp, Py_buffer *view);
PyAPI_FUNC(int) PyUnstable_Buffer_ReleaseInInterpreterAndRawFree(
PyInterpreterState *interp, Py_buffer *view);

/* Maximum number of dimensions */
#define PyBUF_MAX_NDIM 64
Expand Down
1 change: 1 addition & 0 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -1790,6 +1790,7 @@ PYTHON_HEADERS= \
$(srcdir)/Include/internal/pycore_parking_lot.h \
$(srcdir)/Include/internal/pycore_pathconfig.h \
$(srcdir)/Include/internal/pycore_pyarena.h \
$(srcdir)/Include/internal/pycore_pybuffer.h \
$(srcdir)/Include/internal/pycore_pyerrors.h \
$(srcdir)/Include/internal/pycore_pyhash.h \
$(srcdir)/Include/internal/pycore_pylifecycle.h \
Expand Down
8 changes: 7 additions & 1 deletion Modules/_xxinterpchannelsmodule.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
/* interpreters module */
/* low-level access to interpreter primitives */

#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include "interpreteridobject.h"
#include "pycore_pybuffer.h" // _PyBuffer_ReleaseInInterpreterAndRawFree()
#include "pycore_interp.h" // _PyInterpreterState_LookUpID()


/*
Expand Down Expand Up @@ -229,7 +235,7 @@ xibufferview_dealloc(XIBufferViewObject *self)
since other objects may be using the buffer still. */
assert(interp != NULL);

if (PyUnstable_Buffer_ReleaseInInterpreterAndRawFree(interp, self->view) < 0) {
if (_PyBuffer_ReleaseInInterpreterAndRawFree(interp, self->view) < 0) {
// XXX Emit a warning?
PyErr_Clear();
}
Expand Down
9 changes: 5 additions & 4 deletions Objects/abstract.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "Python.h"
#include "pycore_abstract.h" // _PyIndex_Check()
#include "pycore_pybuffer.h"
#include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_ceval.h" // _Py_EnterRecursiveCallTstate()
#include "pycore_object.h" // _Py_CheckSlotResult()
Expand Down Expand Up @@ -814,15 +815,15 @@ _buffer_release_call(void *arg)
}

int
PyUnstable_Buffer_ReleaseInInterpreter(PyInterpreterState *interp,
Py_buffer *view)
_PyBuffer_ReleaseInInterpreter(PyInterpreterState *interp,
Py_buffer *view)
{
return _Py_CallInInterpreter(interp, _buffer_release_call, view);
}

int
PyUnstable_Buffer_ReleaseInInterpreterAndRawFree(PyInterpreterState *interp,
Py_buffer *view)
_PyBuffer_ReleaseInInterpreterAndRawFree(PyInterpreterState *interp,
Py_buffer *view)
{
return _Py_CallInInterpreterAndRawFree(interp, _buffer_release_call, view);
}
Expand Down