summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2024-08-14 05:17:04 (GMT)
committerGitHub <noreply@github.com>2024-08-14 05:17:04 (GMT)
commit05fc4d758aa9b731c722e6c1c18e1f5e54597393 (patch)
tree13f4ccc8f86e6bc7c9b5b3a537be3ddd08298205 /Python/compile.c
parente03073ff20107793a4ea28cdac0d6894774dd110 (diff)
downloadcpython-05fc4d758aa9b731c722e6c1c18e1f5e54597393.zip
cpython-05fc4d758aa9b731c722e6c1c18e1f5e54597393.tar.gz
cpython-05fc4d758aa9b731c722e6c1c18e1f5e54597393.tar.bz2
gh-122985: add SYMBOL_TO_SCOPE macro in symtable (#122986)
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 0efa747..237b5db 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -491,7 +491,7 @@ each key.
static PyObject *
dictbytype(PyObject *src, int scope_type, int flag, Py_ssize_t offset)
{
- Py_ssize_t i = offset, scope, num_keys, key_i;
+ Py_ssize_t i = offset, num_keys, key_i;
PyObject *k, *v, *dest = PyDict_New();
PyObject *sorted_keys;
@@ -533,10 +533,7 @@ dictbytype(PyObject *src, int scope_type, int flag, Py_ssize_t offset)
Py_DECREF(dest);
return NULL;
}
- /* XXX this should probably be a macro in symtable.h */
- scope = (vi >> SCOPE_OFFSET) & SCOPE_MASK;
-
- if (scope == scope_type || vi & flag) {
+ if (SYMBOL_TO_SCOPE(vi) == scope_type || vi & flag) {
PyObject *item = PyLong_FromSsize_t(i);
if (item == NULL) {
Py_DECREF(sorted_keys);
@@ -5393,7 +5390,7 @@ push_inlined_comprehension_state(struct compiler *c, location loc,
if (symbol == -1 && PyErr_Occurred()) {
return ERROR;
}
- long scope = (symbol >> SCOPE_OFFSET) & SCOPE_MASK;
+ long scope = SYMBOL_TO_SCOPE(symbol);
PyObject *outv = PyDict_GetItemWithError(SYMTABLE_ENTRY(c)->ste_symbols, k);
if (outv == NULL) {
if (PyErr_Occurred()) {
@@ -5405,7 +5402,7 @@ push_inlined_comprehension_state(struct compiler *c, location loc,
if (outsymbol == -1 && PyErr_Occurred()) {
return ERROR;
}
- long outsc = (outsymbol >> SCOPE_OFFSET) & SCOPE_MASK;
+ long outsc = SYMBOL_TO_SCOPE(outsymbol);
// If a name has different scope inside than outside the comprehension,
// we need to temporarily handle it with the right scope while
// compiling the comprehension. If it's free in the comprehension