Skip to content

Commit 40f1755

Browse files
committed
Get some tests passing
1 parent dd9e0a4 commit 40f1755

File tree

6 files changed

+13
-35
lines changed

6 files changed

+13
-35
lines changed

src/core/IronPython/Runtime/DictionaryOps.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ public static object setdefault(PythonDictionary self, object key, object defaul
120120

121121
public static void update(CodeContext/*!*/ context, PythonDictionary/*!*/ self, object other) {
122122
if (other is PythonDictionary pyDict) {
123-
pyDict._storage.CopyTo(ref self._storage);
123+
if (pyDict.TreatAsMapping) {
124+
SlowUpdate(context, self, other);
125+
} else {
126+
pyDict._storage.CopyTo(ref self._storage);
127+
}
124128
} else {
125129
SlowUpdate(context, self, other);
126130
}
@@ -129,7 +133,7 @@ public static void update(CodeContext/*!*/ context, PythonDictionary/*!*/ self,
129133
private static void SlowUpdate(CodeContext/*!*/ context, PythonDictionary/*!*/ self, object other) {
130134
if (other is MappingProxy proxy) {
131135
update(context, self, proxy.GetDictionary(context));
132-
} else if (other is IDictionary dict) {
136+
} else if (other is IDictionary dict && other is not PythonDictionary) {
133137
IDictionaryEnumerator e = dict.GetEnumerator();
134138
while (e.MoveNext()) {
135139
self._storage.Add(ref self._storage, e.Key, e.Value);

src/core/IronPython/Runtime/Operations/PythonOps.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,6 +2603,8 @@ public static PythonDictionary UserMappingToPythonDictionary(CodeContext/*!*/ co
26032603
}
26042604

26052605
public static PythonDictionary CopyAndVerifyPythonDictionary(PythonFunction function, PythonDictionary dict) {
2606+
if (dict.TreatAsMapping) return CopyAndVerifyUserMapping(function, dict);
2607+
26062608
if (dict._storage.HasNonStringAttributes()) {
26072609
throw TypeError("{0}() keywords must be strings", function.__name__);
26082610
}

src/core/IronPython/Runtime/PythonDictionary.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,11 @@ internal bool TryRemoveValue(object key, out object value) {
678678
return _storage.TryRemoveValue(ref _storage, key, out value);
679679
}
680680

681+
/// <summary>
682+
/// If __iter__ is overridden then we should treat the dict as a mapping.
683+
/// </summary>
684+
internal bool TreatAsMapping => GetType() != typeof(PythonDictionary) && ((Func<object>)__iter__).Method.DeclaringType != typeof(PythonDictionary);
685+
681686
#region Debugger View
682687

683688
internal class DebugProxy {

tests/IronPython.Tests/Cases/CPythonCasesManifest.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,6 @@ Ignore=true
207207
RunCondition=$(IS_DEBUG) # https://github.com/IronLanguages/ironpython3/issues/1067
208208
Timeout=600000 # 10 minute timeout
209209

210-
[CPython.test_call] # IronPython.test_call_stdlib
211-
Ignore=true
212-
213210
[CPython.test_capi]
214211
Ignore=true
215212
Reason=ImportError: No module named _testcapi

tests/suite/test_call_stdlib.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

tests/suite/test_functools_stdlib.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@ def load_tests(loader, standard_tests, pattern):
4343
]
4444

4545
skip_tests = [
46-
test.test_functools.TestLRUC('test_kwargs_order'), # intermittent failures - https://github.com/IronLanguages/ironpython3/issues/1460
4746
test.test_functools.TestLRUC('test_lru_cache_threaded2'), # intermittent failures
4847
test.test_functools.TestLRUC('test_lru_cache_threaded3'), # intermittent failures
49-
test.test_functools.TestLRUPy('test_kwargs_order'), # intermittent failures - https://github.com/IronLanguages/ironpython3/issues/1460
5048
test.test_functools.TestLRUPy('test_lru_cache_threaded2'), # intermittent failures
5149
test.test_functools.TestLRUPy('test_lru_cache_threaded3'), # intermittent failures
5250
test.test_functools.TestPartialC('test_recursive_pickle'), # StackOverflowException

0 commit comments

Comments
 (0)