Commit Graph
9 Commits
Author SHA1 Message Date
Changjoon e7252b2c4e Make mappingproxy's nb_or slot symmetric for dict | mp (#7723)
* Make mappingproxy's nb_or slot symmetric for dict | mp

CPython's mappingproxy_or (Objects/descrobject.c) unwraps a mappingproxy
on either side of '|' to its underlying mapping and delegates back to
PyNumber_Or. This makes 'dict | mp', 'mp | dict', and 'mp | mp' all
produce a plain dict result without dict's own nb_or having to know
about mappingproxy.

RustPython's 'or' slot in 'AsNumber for PyMappingProxy' only handled
the case where the left operand is a mappingproxy. When the slot fired
with a=dict, b=mp (because dict.nb_or returned NotImplemented), it
returned NotImplemented again — so 'dict | mp' raised TypeError. This
propagated to 'UserDict | mappingproxy' (which calls self.data | other).

Rewrite the slot to unwrap a mappingproxy on either side (or both)
before delegating to vm._or on the underlying mappings. The
inplace_or slot is unchanged — '|=' is still rejected.

Unmasks test_userdict.UserDictTest.test_mixed_or.

* Unmask test_types.MappingProxyTests.test_union

The slot fix in this PR also enables this test, which was marked
expectedFailure for the same dict|mappingproxy TypeError. Caught as
UNEXPECTED SUCCESS in CI.
2026-04-29 18:16:27 +09:00
Shahar Naveh 30323d5a52 Update seq tests from 3.14.4 (#7606)
* Update seq related tests
2026-04-15 14:17:01 +09:00
ShaharNaveh ab9594c4de Update test_dictcomps, test_userdict 2026-02-13 13:36:33 +02:00
ShaharNaveh e00a95d15c Update test_userdict.py from 3.13.7 2025-08-31 12:14:40 +03:00
LYK 58f988bf33 Update test_userdict.py from CPython 3.11.2
Only whitespace is different.
2023-03-08 14:37:00 +09:00
Jeong YunWon 743ca30a46 remove windows stack overflow skipIf 2022-07-25 03:29:06 +09:00
CPython developers c62076e0e9 Update test_dict from CPython 3.10.5 2022-07-18 03:54:49 +09:00
Padraic Fanning 9c5343b9ae Skip stack overflow on Windows 2021-06-09 19:31:15 -04:00
Padraic Fanning ae00fef135 Add test_userdict from CPython 3.8 2021-06-09 17:47:35 -04:00