diff --git a/src/core/IronPython/Runtime/Importer.cs b/src/core/IronPython/Runtime/Importer.cs index 6f3db9812..42d81b6a2 100644 --- a/src/core/IronPython/Runtime/Importer.cs +++ b/src/core/IronPython/Runtime/Importer.cs @@ -127,7 +127,11 @@ private static object ImportModuleFrom(CodeContext/*!*/ context, object from, Ar string name = parts.Array[parts.Offset + parts.Count - 1]; if (from is NamespaceTracker ns) { if (ns.TryGetValue(name, out object val)) { - return MemberTrackerToPython(context, val); + object ret = MemberTrackerToPython(context, val); + if (ret != null && val is NamespaceTracker retns && !context.LanguageContext.SystemStateModules.ContainsKey(retns.Name)) { + context.LanguageContext.SystemStateModules[retns.Name] = ret; + } + return ret; } } diff --git a/tests/suite/test_cliclass.py b/tests/suite/test_cliclass.py index 8b6bbafc8..28c1e2a8c 100644 --- a/tests/suite/test_cliclass.py +++ b/tests/suite/test_cliclass.py @@ -1199,11 +1199,14 @@ def test_serialization(self): System.StringSplitOptions.RemoveEmptyEntries, ] - if False: - # TODO: Enum types are not picklable if defined in nested namespaces - # https://github.com/IronLanguages/ironpython3/issues/1989 - clr.AddReference("System.Text.Json") - data.append(System.Text.Json.JsonValueKind.Object) # byte-based enum + if is_cli: + # enum types + clr.AddReference("Microsoft.Scripting") + import Microsoft.Scripting + data.append(Microsoft.Scripting.Severity.Warning) # different namespace than System + if is_netcoreapp: + clr.AddReference("System.Text.Json") + data.append(System.Text.Json.JsonValueKind.Object) # byte-based enum data.append(list(data)) # list of all the data.. data.append(tuple(data)) # tuple of all the data...