Skip to content

Commit b62cb52

Browse files
[3.13] Revert "gh-115432: Add critical section variant that handles a NULL object (GH-115433)" (GH-118861) (#118872)
This reverts commit ad4f909. The API ended up not being used. (cherry picked from commit 46c8081) Co-authored-by: Sam Gross <[email protected]>
1 parent 00ec116 commit b62cb52

File tree

2 files changed

+0
-38
lines changed

2 files changed

+0
-38
lines changed

Include/internal/pycore_critical_section.h

-29
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,6 @@ extern "C" {
9999
_PyCriticalSection_End(&_cs); \
100100
}
101101

102-
# define Py_XBEGIN_CRITICAL_SECTION(op) \
103-
{ \
104-
_PyCriticalSection _cs_opt = {0}; \
105-
_PyCriticalSection_XBegin(&_cs_opt, _PyObject_CAST(op))
106-
107-
# define Py_XEND_CRITICAL_SECTION() \
108-
_PyCriticalSection_XEnd(&_cs_opt); \
109-
}
110-
111102
# define Py_BEGIN_CRITICAL_SECTION2(a, b) \
112103
{ \
113104
_PyCriticalSection2 _cs2; \
@@ -144,8 +135,6 @@ extern "C" {
144135
# define Py_BEGIN_CRITICAL_SECTION_MUT(mut)
145136
# define Py_BEGIN_CRITICAL_SECTION(op)
146137
# define Py_END_CRITICAL_SECTION()
147-
# define Py_XBEGIN_CRITICAL_SECTION(op)
148-
# define Py_XEND_CRITICAL_SECTION()
149138
# define Py_BEGIN_CRITICAL_SECTION2(a, b)
150139
# define Py_END_CRITICAL_SECTION2()
151140
# define _Py_CRITICAL_SECTION_ASSERT_MUTEX_LOCKED(mutex)
@@ -202,16 +191,6 @@ _PyCriticalSection_Begin(_PyCriticalSection *c, PyMutex *m)
202191
}
203192
}
204193

205-
static inline void
206-
_PyCriticalSection_XBegin(_PyCriticalSection *c, PyObject *op)
207-
{
208-
#ifdef Py_GIL_DISABLED
209-
if (op != NULL) {
210-
_PyCriticalSection_Begin(c, &_PyObject_CAST(op)->ob_mutex);
211-
}
212-
#endif
213-
}
214-
215194
// Removes the top-most critical section from the thread's stack of critical
216195
// sections. If the new top-most critical section is inactive, then it is
217196
// resumed.
@@ -234,14 +213,6 @@ _PyCriticalSection_End(_PyCriticalSection *c)
234213
_PyCriticalSection_Pop(c);
235214
}
236215

237-
static inline void
238-
_PyCriticalSection_XEnd(_PyCriticalSection *c)
239-
{
240-
if (c->mutex) {
241-
_PyCriticalSection_End(c);
242-
}
243-
}
244-
245216
static inline void
246217
_PyCriticalSection2_Begin(_PyCriticalSection2 *c, PyMutex *m1, PyMutex *m2)
247218
{

Modules/_testinternalcapi/test_critical_sections.c

-9
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,6 @@ test_critical_sections(PyObject *self, PyObject *Py_UNUSED(args))
4949
Py_END_CRITICAL_SECTION2();
5050
assert_nogil(!PyMutex_IsLocked(&d2->ob_mutex));
5151

52-
// Optional variant behaves the same if the object is non-NULL
53-
Py_XBEGIN_CRITICAL_SECTION(d1);
54-
assert_nogil(PyMutex_IsLocked(&d1->ob_mutex));
55-
Py_XEND_CRITICAL_SECTION();
56-
57-
// No-op
58-
Py_XBEGIN_CRITICAL_SECTION(NULL);
59-
Py_XEND_CRITICAL_SECTION();
60-
6152
Py_DECREF(d2);
6253
Py_DECREF(d1);
6354
Py_RETURN_NONE;

0 commit comments

Comments
 (0)