There was an error while loading. Please reload this page.
1 parent 900dd6a commit abf568aCopy full SHA for abf568a
1 file changed
Python/Python-tokenize.c
@@ -1,10 +1,10 @@
1
#include "Python.h"
2
#include "errcode.h"
3
-#include "internal/pycore_lock.h" // PyMutex
+#include "internal/pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION
4
#include "../Parser/lexer/state.h"
5
#include "../Parser/lexer/lexer.h"
6
#include "../Parser/tokenizer/tokenizer.h"
7
-#include "../Parser/pegen.h" // _PyPegen_byte_offset_to_character_offset()
+#include "../Parser/pegen.h" // _PyPegen_byte_offset_to_character_offset()
8
9
static struct PyModuleDef _tokenizemodule;
10
@@ -38,10 +38,6 @@ typedef struct
38
PyObject *last_line;
39
Py_ssize_t last_lineno;
40
Py_ssize_t byte_col_offset_diff;
41
-
42
-#ifdef Py_GIL_DISABLED
43
- PyMutex mutex;
44
-#endif
45
} tokenizeriterobject;
46
47
/*[clinic input]
@@ -79,10 +75,6 @@ tokenizeriter_new_impl(PyTypeObject *type, PyObject *readline,
79
75
}
80
76
self->done = 0;
81
77
82
83
- self->mutex = (PyMutex) {_Py_UNLOCKED};
84
85
86
78
self->last_line = NULL;
87
self->byte_col_offset_diff = 0;
88
self->last_lineno = 0;
@@ -191,13 +183,10 @@ tokenizeriter_next(tokenizeriterobject *it)
191
183
struct token token;
192
184
_PyToken_Init(&token);
193
185
194
195
- PyMutex_Lock(&it->mutex);
196
197
- int type = _PyTokenizer_Get(it->tok, &token);
198
199
- PyMutex_Unlock(&it->mutex);
200
186
+ int type;
187
+ Py_BEGIN_CRITICAL_SECTION(it);
188
+ type = _PyTokenizer_Get(it->tok, &token);
189
+ Py_END_CRITICAL_SECTION();
201
190
202
if (type == ERRORTOKEN) {
203
if(!PyErr_Occurred()) {
0 commit comments