Skip to content

Commit 20f9c3c

Browse files
committed
revert unintended changes
1 parent 013783c commit 20f9c3c

7 files changed

Lines changed: 11 additions & 31 deletions

File tree

‎Include/opcode.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ extern "C" {
123123
#define LOAD_CLOSURE 135 /* Load free variable from closure */
124124
#define LOAD_DEREF 136 /* Load and dereference from closure cell */
125125
#define STORE_DEREF 137 /* Store into cell */
126-
#define LOAD_NAME_LOCAL_ONLY 138
127126

128127
/* The next 3 opcodes must be contiguous and satisfy
129128
(CALL_FUNCTION_VAR - CALL_FUNCTION) & 3 == 1 */

‎Include/symtable.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
8888
#define GLOBAL_IMPLICIT 3
8989
#define FREE 4
9090
#define CELL 5
91-
#define LOCAL_ONLY 6
9291

9392
/* The following two names are used for the ste_unoptimized bit field */
9493
#define OPT_IMPORT_STAR 1

‎Lib/test/test_scope.py‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -690,14 +690,6 @@ def h():
690690
h = g()
691691
self.assertEqual(h(), 3)
692692

693-
def testLocalClosureShadowing(self):
694-
exec("""
695-
x = 4
696-
def f(x):
697-
class C:
698-
x = x
699-
raises(NameError, f, 3)""", {"raises" : self.assertRaises})
700-
701693

702694
def test_main():
703695
run_unittest(ScopeTests)

‎Objects/typeobject.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6094,7 +6094,6 @@ supercheck(PyTypeObject *type, PyObject *obj)
60946094
PyErr_SetString(PyExc_TypeError,
60956095
"super(type, obj): "
60966096
"obj must be an instance or subtype of type");
6097-
printf("%s\n", type->tp_name);
60986097
return NULL;
60996098
}
61006099

‎Python/ceval.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,7 +2052,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
20522052
break;
20532053

20542054
TARGET(LOAD_NAME)
2055-
TARGET(LOAD_NAME_LOCAL_ONLY)
20562055
w = GETITEM(names, oparg);
20572056
if ((v = f->f_locals) == NULL) {
20582057
PyErr_Format(PyExc_SystemError,
@@ -2074,14 +2073,15 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
20742073
}
20752074
}
20762075
if (x == NULL) {
2077-
if (opcode != LOAD_NAME_LOCAL_ONLY) {
2078-
x = PyDict_GetItem(f->f_globals, w);
2079-
if (x == NULL)
2080-
x = PyDict_GetItem(f->f_builtins, w);
2081-
}
2076+
x = PyDict_GetItem(f->f_globals, w);
20822077
if (x == NULL) {
2083-
format_exc_check_arg(PyExc_NameError, NAME_ERROR_MSG, w);
2084-
break;
2078+
x = PyDict_GetItem(f->f_builtins, w);
2079+
if (x == NULL) {
2080+
format_exc_check_arg(
2081+
PyExc_NameError,
2082+
NAME_ERROR_MSG, w);
2083+
break;
2084+
}
20852085
}
20862086
Py_INCREF(x);
20872087
}

‎Python/compile.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,6 @@ opcode_stack_effect(int opcode, int oparg)
787787
case LOAD_CONST:
788788
return 1;
789789
case LOAD_NAME:
790-
case LOAD_NAME_LOCAL_ONLY:
791790
return 1;
792791
case BUILD_TUPLE:
793792
case BUILD_LIST:
@@ -2482,7 +2481,6 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
24822481
optype = OP_DEREF;
24832482
break;
24842483
case LOCAL:
2485-
case LOCAL_ONLY:
24862484
if (c->u->u_ste->ste_type == FunctionBlock)
24872485
optype = OP_FAST;
24882486
break;
@@ -2558,7 +2556,7 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
25582556
break;
25592557
case OP_NAME:
25602558
switch (ctx) {
2561-
case Load: op = (scope == LOCAL_ONLY) ? LOAD_NAME_LOCAL_ONLY : LOAD_NAME; break;
2559+
case Load: op = LOAD_NAME; break;
25622560
case Store: op = STORE_NAME; break;
25632561
case Del: op = DELETE_NAME; break;
25642562
case AugLoad:

‎Python/symtable.c‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -432,14 +432,7 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags,
432432
return PySet_Add(free, name) >= 0;
433433
}
434434
if (flags & DEF_BOUND) {
435-
if (ste->ste_type == ClassBlock &&
436-
!(flags & DEF_PARAM) &&
437-
bound && PySet_Contains(bound, name)) {
438-
SET_SCOPE(scopes, name, LOCAL_ONLY);
439-
}
440-
else {
441-
SET_SCOPE(scopes, name, LOCAL);
442-
}
435+
SET_SCOPE(scopes, name, LOCAL);
443436
if (PySet_Add(local, name) < 0)
444437
return 0;
445438
if (PySet_Discard(global, name) < 0)
@@ -496,7 +489,7 @@ analyze_cells(PyObject *scopes, PyObject *free, const char *restricted)
496489
long scope;
497490
assert(PyLong_Check(v));
498491
scope = PyLong_AS_LONG(v);
499-
if (scope != LOCAL && scope != LOCAL_ONLY)
492+
if (scope != LOCAL)
500493
continue;
501494
if (!PySet_Contains(free, name))
502495
continue;

0 commit comments

Comments
 (0)