Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ repos:
name: Run Ruff (format) on Tools/build/check_warnings.py
args: [--check, --config=Tools/build/.ruff.toml]
files: ^Tools/build/check_warnings.py
- id: ruff-format
name: Run Ruff (format) on Tools/wasm/
args: [--check, --config=Tools/wasm/.ruff.toml]
files: ^Tools/wasm/

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.9.0
Expand Down
4 changes: 2 additions & 2 deletions Include/Python.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ __pragma(warning(disable: 4201))
#include "pybuffer.h"
#include "pystats.h"
#include "pyatomic.h"
#include "pylock.h"
#include "cpython/pylock.h"
#include "critical_section.h"
#include "object.h"
#include "refcount.h"
Expand All @@ -105,7 +105,7 @@ __pragma(warning(disable: 4201))
#include "setobject.h"
#include "methodobject.h"
#include "moduleobject.h"
#include "monitoring.h"
#include "cpython/monitoring.h"
#include "cpython/funcobject.h"
#include "cpython/classobject.h"
#include "fileobject.h"
Expand Down
17 changes: 17 additions & 0 deletions Include/cpython/marshal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef _Py_CPYTHON_MARSHAL_H
# error "this header file must not be included directly"
#endif

PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(const char *,
Py_ssize_t);
PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *, int);

#define Py_MARSHAL_VERSION 5

PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *);
PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *);
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *);
PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *);

PyAPI_FUNC(void) PyMarshal_WriteLongToFile(long, FILE *, int);
PyAPI_FUNC(void) PyMarshal_WriteObjectToFile(PyObject *, FILE *, int);
16 changes: 14 additions & 2 deletions Include/cpython/monitoring.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#ifndef Py_CPYTHON_MONITORING_H
# error "this header file must not be included directly"
#ifndef Py_MONITORING_H
#define Py_MONITORING_H
#ifndef Py_LIMITED_API
#ifdef __cplusplus
extern "C" {
#endif

// There is currently no limited API for monitoring


/* Local events.
* These require bytecode instrumentation */

Expand Down Expand Up @@ -267,3 +273,9 @@ PyMonitoring_FireStopIterationEvent(PyMonitoringState *state, PyObject *codelike
}

#undef _PYMONITORING_IF_ACTIVE

#ifdef __cplusplus
}
#endif
#endif // !Py_LIMITED_API
#endif // !Py_MONITORING_H
15 changes: 13 additions & 2 deletions Include/cpython/pylock.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#ifndef Py_CPYTHON_LOCK_H
# error "this header file must not be included directly"
#ifndef Py_LOCK_H
#define Py_LOCK_H
#ifndef Py_LIMITED_API
#ifdef __cplusplus
extern "C" {
#endif


#define _Py_UNLOCKED 0
#define _Py_LOCKED 1

Expand Down Expand Up @@ -72,3 +76,10 @@ _PyMutex_IsLocked(PyMutex *m)
return (_Py_atomic_load_uint8(&m->_bits) & _Py_LOCKED) != 0;
}
#define PyMutex_IsLocked _PyMutex_IsLocked


#ifdef __cplusplus
}
#endif
#endif // !Py_LIMITED_API
#endif // !Py_LOCK_H
20 changes: 20 additions & 0 deletions Include/cpython/sliceobject.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef Py_CPYTHON_SLICEOBJECT_H
# error "this header file must not be included directly"
#endif

/* Slice object interface */

/*
A slice object containing start, stop, and step data members (the
names are from range). After much talk with Guido, it was decided to
let these be any arbitrary python type. Py_None stands for omitted values.
*/
typedef struct {
PyObject_HEAD
PyObject *start, *stop, *step; /* not NULL */
} PySliceObject;

PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop);
PyAPI_FUNC(int) _PySlice_GetLongIndices(PySliceObject *self, PyObject *length,
PyObject **start_ptr, PyObject **stop_ptr,
PyObject **step_ptr);
12 changes: 12 additions & 0 deletions Include/cpython/structseq.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef Py_CPYTHON_STRUCTSEQ_H
# error "this header file must not be included directly"
#endif

PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type,
PyStructSequence_Desc *desc);
PyAPI_FUNC(int) PyStructSequence_InitType2(PyTypeObject *type,
PyStructSequence_Desc *desc);

typedef PyTupleObject PyStructSequence;
#define PyStructSequence_SET_ITEM PyStructSequence_SetItem
#define PyStructSequence_GET_ITEM PyStructSequence_GetItem
23 changes: 5 additions & 18 deletions Include/marshal.h
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@

/* Interface for marshal.c */

#ifndef Py_MARSHAL_H
#define Py_MARSHAL_H
#ifndef Py_LIMITED_API

#ifdef __cplusplus
extern "C" {
#endif

PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(const char *,
Py_ssize_t);
PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *, int);

#define Py_MARSHAL_VERSION 5

PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *);
PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *);
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *);
PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *);

PyAPI_FUNC(void) PyMarshal_WriteLongToFile(long, FILE *, int);
PyAPI_FUNC(void) PyMarshal_WriteObjectToFile(PyObject *, FILE *, int);
#ifndef Py_LIMITED_API
# define _Py_CPYTHON_MARSHAL_H
# include "cpython/marshal.h"
# undef _Py_CPYTHON_MARSHAL_H
#endif

#ifdef __cplusplus
}
#endif

#endif /* Py_LIMITED_API */
#endif /* !Py_MARSHAL_H */
18 changes: 0 additions & 18 deletions Include/monitoring.h

This file was deleted.

16 changes: 0 additions & 16 deletions Include/pylock.h

This file was deleted.

25 changes: 6 additions & 19 deletions Include/sliceobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,13 @@ PyAPI_DATA(PyObject) _Py_EllipsisObject; /* Don't use this directly */

/* Slice object interface */

/*

A slice object containing start, stop, and step data members (the
names are from range). After much talk with Guido, it was decided to
let these be any arbitrary python type. Py_None stands for omitted values.
*/
#ifndef Py_LIMITED_API
typedef struct {
PyObject_HEAD
PyObject *start, *stop, *step; /* not NULL */
} PySliceObject;
#endif

PyAPI_DATA(PyTypeObject) PySlice_Type;
PyAPI_DATA(PyTypeObject) PyEllipsis_Type;

#define PySlice_Check(op) Py_IS_TYPE((op), &PySlice_Type)

PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop,
PyObject* step);
#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop);
PyAPI_FUNC(int) _PySlice_GetLongIndices(PySliceObject *self, PyObject *length,
PyObject **start_ptr, PyObject **stop_ptr,
PyObject **step_ptr);
#endif
PyAPI_FUNC(int) PySlice_GetIndices(PyObject *r, Py_ssize_t length,
Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step);
Py_DEPRECATED(3.7)
Expand All @@ -63,6 +44,12 @@ PyAPI_FUNC(Py_ssize_t) PySlice_AdjustIndices(Py_ssize_t length,
Py_ssize_t step);
#endif

#ifndef Py_LIMITED_API
# define Py_CPYTHON_SLICEOBJECT_H
# include "cpython/sliceobject.h"
# undef Py_CPYTHON_SLICEOBJECT_H
#endif

#ifdef __cplusplus
}
#endif
Expand Down
12 changes: 3 additions & 9 deletions Include/structseq.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ typedef struct PyStructSequence_Desc {

PyAPI_DATA(const char * const) PyStructSequence_UnnamedField;

#ifndef Py_LIMITED_API
PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type,
PyStructSequence_Desc *desc);
PyAPI_FUNC(int) PyStructSequence_InitType2(PyTypeObject *type,
PyStructSequence_Desc *desc);
#endif
PyAPI_FUNC(PyTypeObject*) PyStructSequence_NewType(PyStructSequence_Desc *desc);

PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type);
Expand All @@ -35,9 +29,9 @@ PyAPI_FUNC(void) PyStructSequence_SetItem(PyObject*, Py_ssize_t, PyObject*);
PyAPI_FUNC(PyObject*) PyStructSequence_GetItem(PyObject*, Py_ssize_t);

#ifndef Py_LIMITED_API
typedef PyTupleObject PyStructSequence;
#define PyStructSequence_SET_ITEM PyStructSequence_SetItem
#define PyStructSequence_GET_ITEM PyStructSequence_GetItem
# define Py_CPYTHON_STRUCTSEQ_H
# include "cpython/structseq.h"
# undef Py_CPYTHON_STRUCTSEQ_H
#endif

#ifdef __cplusplus
Expand Down
5 changes: 3 additions & 2 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -1191,14 +1191,12 @@ PYTHON_HEADERS= \
$(srcdir)/Include/intrcheck.h \
$(srcdir)/Include/iterobject.h \
$(srcdir)/Include/listobject.h \
$(srcdir)/Include/pylock.h \
$(srcdir)/Include/longobject.h \
$(srcdir)/Include/marshal.h \
$(srcdir)/Include/memoryobject.h \
$(srcdir)/Include/methodobject.h \
$(srcdir)/Include/modsupport.h \
$(srcdir)/Include/moduleobject.h \
$(srcdir)/Include/monitoring.h \
$(srcdir)/Include/object.h \
$(srcdir)/Include/objimpl.h \
$(srcdir)/Include/opcode.h \
Expand Down Expand Up @@ -1271,6 +1269,7 @@ PYTHON_HEADERS= \
$(srcdir)/Include/cpython/pylock.h \
$(srcdir)/Include/cpython/longintrepr.h \
$(srcdir)/Include/cpython/longobject.h \
$(srcdir)/Include/cpython/marshal.h \
$(srcdir)/Include/cpython/memoryobject.h \
$(srcdir)/Include/cpython/methodobject.h \
$(srcdir)/Include/cpython/modsupport.h \
Expand All @@ -1296,6 +1295,8 @@ PYTHON_HEADERS= \
$(srcdir)/Include/cpython/pythonrun.h \
$(srcdir)/Include/cpython/pythread.h \
$(srcdir)/Include/cpython/setobject.h \
$(srcdir)/Include/cpython/sliceobject.h \
$(srcdir)/Include/cpython/structseq.h \
$(srcdir)/Include/cpython/traceback.h \
$(srcdir)/Include/cpython/tracemalloc.h \
$(srcdir)/Include/cpython/tupleobject.h \
Expand Down
2 changes: 0 additions & 2 deletions Modules/_testcapi/monitoring.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "parts.h"
#include "util.h"

#include "monitoring.h"

#define Py_BUILD_CORE
#include "internal/pycore_instruments.h"

Expand Down
35 changes: 0 additions & 35 deletions PCbuild/field3.py

This file was deleted.

5 changes: 4 additions & 1 deletion PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,11 @@
<ClInclude Include="..\Include\cpython\pylock.h" />
<ClInclude Include="..\Include\cpython\longintrepr.h" />
<ClInclude Include="..\Include\cpython\longobject.h" />
<ClInclude Include="..\Include\cpython\marshal.h" />
<ClInclude Include="..\Include\cpython\memoryobject.h" />
<ClInclude Include="..\Include\cpython\methodobject.h" />
<ClInclude Include="..\Include\cpython\modsupport.h" />
<ClInclude Include="..\Include\cpython\monitoring.h" />
<ClInclude Include="..\Include\cpython\object.h" />
<ClInclude Include="..\Include\cpython\objimpl.h" />
<ClInclude Include="..\Include\cpython\odictobject.h" />
Expand All @@ -190,6 +192,8 @@
<ClInclude Include="..\Include\cpython\pythonrun.h" />
<ClInclude Include="..\Include\cpython\pythread.h" />
<ClInclude Include="..\Include\cpython\setobject.h" />
<ClInclude Include="..\Include\cpython\sliceobject.h" />
<ClInclude Include="..\Include\cpython\structseq.h" />
<ClInclude Include="..\Include\cpython\traceback.h" />
<ClInclude Include="..\Include\cpython\tracemalloc.h" />
<ClInclude Include="..\Include\cpython\tupleobject.h" />
Expand Down Expand Up @@ -332,7 +336,6 @@
<ClInclude Include="..\Include\intrcheck.h" />
<ClInclude Include="..\Include\iterobject.h" />
<ClInclude Include="..\Include\listobject.h" />
<ClInclude Include="..\Include\pylock.h" />
<ClInclude Include="..\Include\longobject.h" />
<ClInclude Include="..\Include\marshal.h" />
<ClInclude Include="..\Include\memoryobject.h" />
Expand Down
Loading
Loading