GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use Py_BEGIN_CRITICAL_SECTION · python/cpython@abf568a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Python
    • Python-tokenize.c
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Python/Python-tokenize.c‎

Copy file name to clipboardExpand all lines: Python/Python-tokenize.c
+6-17Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include "Python.h"
22
#include "errcode.h"
3-
#include "internal/pycore_lock.h" // PyMutex
3+
#include "internal/pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION
44
#include "../Parser/lexer/state.h"
55
#include "../Parser/lexer/lexer.h"
66
#include "../Parser/tokenizer/tokenizer.h"
7-
#include "../Parser/pegen.h" // _PyPegen_byte_offset_to_character_offset()
7+
#include "../Parser/pegen.h" // _PyPegen_byte_offset_to_character_offset()
88

99
static struct PyModuleDef _tokenizemodule;
1010

@@ -38,10 +38,6 @@ typedef struct
3838
PyObject *last_line;
3939
Py_ssize_t last_lineno;
4040
Py_ssize_t byte_col_offset_diff;
41-
42-
#ifdef Py_GIL_DISABLED
43-
PyMutex mutex;
44-
#endif
4541
} tokenizeriterobject;
4642

4743
/*[clinic input]
@@ -79,10 +75,6 @@ tokenizeriter_new_impl(PyTypeObject *type, PyObject *readline,
7975
}
8076
self->done = 0;
8177

82-
#ifdef Py_GIL_DISABLED
83-
self->mutex = (PyMutex) {_Py_UNLOCKED};
84-
#endif
85-
8678
self->last_line = NULL;
8779
self->byte_col_offset_diff = 0;
8880
self->last_lineno = 0;
@@ -191,13 +183,10 @@ tokenizeriter_next(tokenizeriterobject *it)
191183
struct token token;
192184
_PyToken_Init(&token);
193185

194-
#ifdef Py_GIL_DISABLED
195-
PyMutex_Lock(&it->mutex);
196-
#endif
197-
int type = _PyTokenizer_Get(it->tok, &token);
198-
#ifdef Py_GIL_DISABLED
199-
PyMutex_Unlock(&it->mutex);
200-
#endif
186+
int type;
187+
Py_BEGIN_CRITICAL_SECTION(it);
188+
type = _PyTokenizer_Get(it->tok, &token);
189+
Py_END_CRITICAL_SECTION();
201190

202191
if (type == ERRORTOKEN) {
203192
if(!PyErr_Occurred()) {

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.