Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c5eb4e4

Browse files
amos402filmor
authored andcommitted
Checks __dict__ in ModuleObject.LoadNames.
1 parent 67ea3eb commit c5eb4e4

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/runtime/moduleobject.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,17 @@ public void LoadNames()
190190
foreach (string name in AssemblyManager.GetNames(_namespace))
191191
{
192192
cache.TryGetValue(name, out m);
193-
if (m == null)
193+
if (m != null)
194194
{
195-
ManagedType attr = GetAttribute(name, true);
195+
continue;
196196
}
197+
IntPtr attr = Runtime.PyDict_GetItemString(dict, name);
198+
// If __dict__ has already set a custom property, skip it.
199+
if (attr != IntPtr.Zero)
200+
{
201+
continue;
202+
}
203+
GetAttribute(name, true);
197204
}
198205
}
199206

src/tests/test_import.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_relative_missing_import():
1414

1515

1616
def test_import_all_on_second_time():
17-
"""Test import all attributes after a normal.
17+
"""Test import all attributes after a normal import without '*'.
1818
Due to import * only allowed at module level, the test body splited
1919
to a module file."""
2020
from . import importtest

0 commit comments

Comments
 (0)