Skip to content

Commit 16d383a

Browse files
authored
Handle __class__ pathologies (#1540)
1 parent 894df46 commit 16d383a

3 files changed

Lines changed: 3 additions & 2 deletions

File tree

Src/IronPython/Compiler/Ast/ClassDefinition.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ internal override bool TryBindOuter(ScopeStatement from, PythonReference referen
128128
if (TryGetVariable(reference.Name, out variable)) {
129129
if (variable.Kind is VariableKind.Global) {
130130
AddReferencedGlobal(reference.Name);
131+
return variable;
131132
} else if (variable.Kind is VariableKind.Local) {
132133
// TODO: This results in doing a dictionary lookup to get/set the local,
133134
// when it should probably be an uninitialized check / global lookup for gets

Src/IronPython/Runtime/Operations/PythonOps.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,7 @@ public static void InitializeForFinalization(CodeContext/*!*/ context, object ne
14981498

14991499
// If __class__ is used, verify that it has been set
15001500
if (vars._storage is RuntimeVariablesDictionaryStorage storage) {
1501-
int pos = Array.IndexOf(storage.Names, "__class__");
1501+
int pos = Array.IndexOf(storage.Names, "__class__", storage.NumFreeVars, storage.Names.Length - storage.NumFreeVars);
15021502
if (pos >= 0) {
15031503
ClosureCell classCell = storage.GetCell(pos);
15041504
if (!ReferenceEquals(classCell.Value, obj)) {

Src/IronPythonTest/Cases/CPythonCasesManifest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ Ignore=true
887887
Reason=ImportError: No module named _msi
888888

889889
[CPython.test_super]
890-
Ignore=true
890+
Ignore=false # will have to be ignored again in 3.6
891891

892892
[CPython.test_support]
893893
RunCondition=NOT $(IS_POSIX) # TODO: debug

0 commit comments

Comments
 (0)