There was an error while loading. Please reload this page.
1 parent 900dd6a commit 78df829Copy full SHA for 78df829
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
@@ -39,9 +39,6 @@ typedef struct
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 +76,6 @@ tokenizeriter_new_impl(PyTypeObject *type, PyObject *readline,
79
76
}
80
77
self->done = 0;
81
78
82
83
- self->mutex = (PyMutex) {_Py_UNLOCKED};
84
85
-
86
self->last_line = NULL;
87
self->byte_col_offset_diff = 0;
88
self->last_lineno = 0;
@@ -191,13 +184,10 @@ tokenizeriter_next(tokenizeriterobject *it)
191
184
struct token token;
192
185
_PyToken_Init(&token);
193
186
194
195
- PyMutex_Lock(&it->mutex);
196
197
- int type = _PyTokenizer_Get(it->tok, &token);
198
199
- PyMutex_Unlock(&it->mutex);
200
187
+ int type;
188
+ Py_BEGIN_CRITICAL_SECTION(it);
189
+ type = _PyTokenizer_Get(it->tok, &token);
190
+ Py_END_CRITICAL_SECTION();
201
202
if (type == ERRORTOKEN) {
203
if(!PyErr_Occurred()) {
0 commit comments