8000 Catch up with justin · python/cpython@1a8a63b · GitHub
[go: up one dir, main page]

Skip to content

Commit 1a8a63b

Browse files
committed
Catch up with justin
2 parents 58bd20c + 7a592f0 commit 1a8a63b

File tree

72 files changed

+1293
-686
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1293
-686
lines changed

Doc/library/profile.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ the following::
8282

8383
The first line indicates that 214 calls were monitored. Of those calls, 207
8484
were :dfn:`primitive`, meaning that the call was not induced via recursion. The
85-
next line: ``Ordered by: cumulative time``, indicates that the text string in the
86-
far right column was used to sort the output. The column headings include:
85+
next line: ``Ordered by: cumulative time`` indicates the output is sorted
86+
by the ``cumtime`` values. The column headings include:
8787

8888
ncalls
8989
for the number of calls.

Doc/tutorial/errors.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ The :keyword:`try` statement works as follows.
108108

109109
* If an exception occurs which does not match the exception named in the *except
110110
clause*, it is passed on to outer :keyword:`try` statements; if no handler is
111-
found, it is an *unhandled exception* and execution stops with a message as
112-
shown above.
111+
found, it is an *unhandled exception* and execution stops with an error message.
113112

114113
A :keyword:`try` statement may have more than one *except clause*, to specify
115114
handlers for different exceptions. At most one handler will be executed.

Grammar/python.gram

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ simple_stmt[stmt_ty] (memo):
124124
| &'nonlocal' nonlocal_stmt
125125

126126
compound_stmt[stmt_ty]:
127+
| invalid_compound_stmt
127128
| &('def' | '@' | 'async') function_def
128129
| &'if' if_stmt
129130
| &('class' | '@') class_def
@@ -1298,6 +1299,10 @@ invalid_import_from_targets:
12981299
| import_from_as_names ',' NEWLINE {
12991300
RAISE_SYNTAX_ERROR("trailing comma not allowed without surrounding parentheses") }
13001301

1302+
invalid_compound_stmt:
1303+
| a='elif' named_expression ':' { RAISE_SYNTAX_ERROR_STARTING_FROM(a, "'elif' must match an if-statement here") }
1304+
| a='else' ':' { RAISE_SYNTAX_ERROR_STARTING_FROM(a, "'else' must match a valid statement here") }
1305+
13011306
invalid_with_stmt:
13021307
| ['async'] 'with' ','.(expression ['as' star_target])+ NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
13031308
| ['async'] 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }

Include/cpython/pystate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ struct _ts {
151151

152152
/* Tagged pointer to top-most critical section, or zero if there is no
153153
* active critical section. Critical sections are only used in
154-
* `--disable-gil` builds (i.e., when Py_NOGIL is defined to 1). In the
154+
* `--disable-gil` builds (i.e., when Py_GIL_DISABLED is defined to 1). In the
155155
* default build, this field is always zero.
156156
*/
157157
uintptr_t critical_section;

Include/internal/pycore_critical_section.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ extern "C" {
8686
#define _Py_CRITICAL_SECTION_TWO_MUTEXES 0x2
8787
#define _Py_CRITICAL_SECTION_MASK 0x3
8888

89-
#ifdef Py_NOGIL
89+
#ifdef Py_GIL_DISABLED
9090
# define Py_BEGIN_CRITICAL_SECTION(op) \
9191
{ \
9292
_PyCriticalSection _cs; \
@@ -104,13 +104,13 @@ extern "C" {
104104
# define Py_END_CRITICAL_SECTION2() \
105105
_PyCriticalSection2_End(&_cs2); \
106106
}
107-
#else /* !Py_NOGIL */
107+
#else /* !Py_GIL_DISABLED */
108108
// The critical section APIs are no-ops with the GIL.
109109
# define Py_BEGIN_CRITICAL_SECTION(op)
110110
# define Py_END_CRITICAL_SECTION()
111111
# define Py_BEGIN_CRITICAL_SECTION2(a, b)
112112
# define Py_END_CRITICAL_SECTION2()
113-
#endif /* !Py_NOGIL */
113+
#endif /* !Py_GIL_DISABLED */
114114

115115
typedef struct {
116116
// Tagged pointer to an outer active critical section (or 0).

Include/internal/pycore_importdl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ typedef FARPROC dl_funcptr;
3131
# define PYD_DEBUG_SUFFIX ""
3232
#endif
3333

34-
#ifdef Py_NOGIL
34+
#ifdef Py_GIL_DISABLED
3535
# define PYD_THREADING_TAG "t"
3636
#else
3737
# define PYD_THREADING_TAG ""

Include/internal/pycore_lock.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ extern "C" {
3333
// ...
3434
// PyMutex_Unlock(&m);
3535

36-
// NOTE: In Py_NOGIL builds, `struct _PyMutex` is defined in Include/object.h.
37-
// The Py_NOGIL builds need the definition in Include/object.h for the
36+
// NOTE: In Py_GIL_DISABLED builds, `struct _PyMutex` is defined in Include/object.h.
37+
// The Py_GIL_DISABLED builds need the definition in Include/object.h for the
3838
// `ob_mutex` field in PyObject. For the default (non-free-threaded) build,
3939
// we define the struct here to avoid exposing it in the public API.
40-
#ifndef Py_NOGIL
40+
#ifndef Py_GIL_DISABLED
4141
struct _PyMutex { uint8_t v; };
4242
#endif
4343

Include/internal/pycore_object.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ PyAPI_FUNC(int) _PyObject_IsFreed(PyObject *);
5454
Furthermore, we can't use designated initializers in Extensions since these
5555
are not supported pre-C++20. Thus, keeping an internal copy here is the most
5656
backwards compatible solution */
57-
#if defined(Py_NOGIL)
57+
#if defined(Py_GIL_DISABLED)
5858
#define _PyObject_HEAD_INIT(type) \
5959
{ \
6060
.ob_ref_local = _Py_IMMORTAL_REFCNT_LOCAL, \
@@ -103,7 +103,7 @@ static inline void _Py_RefcntAdd(PyObject* op, Py_ssize_t n)
103103
#ifdef Py_REF_DEBUG
104104
_Py_AddRefTotal(_PyInterpreterState_GET(), n);
105105
#endif
106-
#if !defined(Py_NOGIL)
106+
#if !defined(Py_GIL_DISABLED)
107107
op->ob_refcnt += n;
108108
#else
109109
if (_Py_IsOwnedByCurrentThread(op)) {
@@ -128,7 +128,7 @@ static inline void _Py_RefcntAdd(PyObject* op, Py_ssize_t n)
128128
static inline void _Py_SetImmortal(PyObject *op)
129129
{
130130
if (op) {
131-
#ifdef Py_NOGIL
131+
#ifdef Py_GIL_DISABLED
132132
op->ob_tid = _Py_UNOWNED_TID;
133133
op->ob_ref_local = _Py_IMMORTAL_REFCNT_LOCAL;
134134
op->ob_ref_shared = 0;
@@ -145,7 +145,7 @@ static inline void _Py_SetMortal(PyObject *op, Py_ssize_t refcnt)
145145
{
146146
if (op) {
147147
assert(_Py_IsImmortal(op));
148-
#ifdef Py_NOGIL
148+
#ifdef Py_GIL_DISABLED
149149
op->ob_tid = _Py_UNOWNED_TID;
150150
op->ob_ref_local = 0;
151151
op->ob_ref_shared = _Py_REF_SHARED(refcnt, _Py_REF_MERGED);
@@ -169,7 +169,7 @@ static inline void _Py_ClearImmortal(PyObject *op)
169169
op = NULL; \
170170
} while (0)
171171

172-
#if !defined(Py_NOGIL)
172+
#if !defined(Py_GIL_DISABLED)
173173
static inline void
174174
_Py_DECREF_SPECIALIZED(PyObject *op, const destructor destruct)
175175
{
@@ -210,7 +210,7 @@ _Py_DECREF_NO_DEALLOC(PyObject *op)
210210
}
211211

212212
#else
213-
// TODO: implement Py_DECREF specializations for Py_NOGIL build
213+
// TODO: implement Py_DECREF specializations for Py_GIL_DISABLED build
214214
static inline void
215215
_Py_DECREF_SPECIALIZED(PyObject *op, const destructor destruct)
216216
{
@@ -238,7 +238,7 @@ _Py_REF_IS_QUEUED(Py_ssize_t ob_ref_shared)
238238
// Merge the local and shared reference count fields and add `extra` to the
239239
// refcount when merging.
240240
Py_ssize_t _Py_ExplicitMergeRefcount(PyObject *op, Py_ssize_t extra);
241-
#endif // !defined(Py_NOGIL)
241+
#endif // !defined(Py_GIL_DISABLED)
242242

243243
#ifdef Py_REF_DEBUG
244244
# undef _Py_DEC_REFTOTAL

Include/internal/pycore_opcode_metadata.h

Lines changed: 47 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uops.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extern "C" {
1010

1111
#include "pycore_frame.h" // _PyInterpreterFrame
1212

13-
#define _Py_UOP_MAX_TRACE_LENGTH 256
13+
#define _Py_UOP_MAX_TRACE_LENGTH 512
1414

1515
typedef struct {
1616
uint16_t opcode;

Include/internal/pycore_weakref.h

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

11+
#include "pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION()
12+
1113
static inline PyObject* _PyWeakref_GET_REF(PyObject *ref_obj) {
1214
assert(PyWeakref_Check(ref_obj));
1315
PyWeakReference *ref = _Py_CAST(PyWeakReference*, ref_obj);
@@ -35,15 +37,20 @@ static inline PyObject* _PyWeakref_GET_REF(PyObject *ref_obj) {
3537

3638
static inline int _PyWeakref_IS_DEAD(PyObject *ref_obj) {
3739
assert(PyWeakref_Check(ref_obj));
40+
int is_dead;
41+
Py_BEGIN_CRITICAL_SECTION(ref_obj);
3842
PyWeakReference *ref = _Py_CAST(PyWeakReference*, ref_obj);
3943
PyObject *obj = ref->wr_object;
4044
if (obj == Py_None) {
4145
// clear_weakref() was called
42-
return 1;
46+
is_dead = 1;
4347
}
44-
45-
// See _PyWeakref_GET_REF() for the rationale of this test
46-
return (Py_REFCNT(obj) == 0);
48+
else {
49+
// See _PyWeakref_GET_REF() for the rationale of this test
50+
is_dead = (Py_REFCNT(obj) == 0);
51+
}
52+
Py_END_CRITICAL_SECTION();
53+
return is_dead;
4754
}
4855

4956
extern Py_ssize_t _PyWeakref_GetWeakrefCount(PyWeakReference *head);

0 commit comments

Comments
 (0)
0