mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
* Fix del obj.__dict__ to match CPython behavior (issue #5355) * Address CodeRabbit concerns: fix GC clearing and improve thread safety of lazy __dict__ recreation * Fix del obj.__dict__: improve GC safety, implement lazy re-creation in setattr, and enable passing CPython tests * Restore expectedFailure for test_has_inline_values * Fix ObjExt::new call site to include has_dict parameter * Remove stray test.py to avoid CI syntax errors * Remove debug txt files and clean test_class.py comments * Delete Lib/test/test_class.py * Restore test_class.py with correct changes (remove expectedFailure, no deletion) * Fix clippy warnings: remove unused into_inner, collapse nested if-let * Fix rustfmt formatting and ruff PEP 8 E302 blank line * Align __dict__ error messages and ensure safety for function/partial objects * Fix compilation errors: change &self to &Py<Self> in __dict__ methods * Fix compilation errors: resolve borrow-after-move and replace transpose on PySetterValue - type.rs: Replace invalid .transpose() on PySetterValue with explicit match on Assign/Delete variants in subtype_set_dict - function.rs: Fix borrow-after-move in set___dict__ by capturing class name before downcast; use as_object() for instance_dict/set_dict calls - _functools.rs: Same borrow-after-move fix and as_object() calls for PyPartial's __dict__ getter/setter * Fix compilation errors: resolve borrow-after-move and replace transpose on PySetterValue * Fix snippet formatting and mark test_remote as expected failure * Fix test_remote by removing HAS_DICT flag from function type * Fix lint formatting error * Remove unnecessary print statement in test_del_dict * Fix trailing newlines in snippet test * Trigger CI * Align __dict__ generic setter behavior * Move __dict__ deletion tests to relevant snippets --------- Co-authored-by: Jeong, YunWon <jeong@youknowone.org>
46 lines
1.0 KiB
Python
46 lines
1.0 KiB
Python
class MyObject:
|
|
pass
|
|
|
|
|
|
assert not MyObject() == MyObject()
|
|
assert MyObject() != MyObject()
|
|
myobj = MyObject()
|
|
assert myobj == myobj
|
|
assert not myobj != myobj
|
|
|
|
object.__subclasshook__(1) == NotImplemented
|
|
|
|
assert MyObject().__eq__(MyObject()) == NotImplemented
|
|
assert MyObject().__ne__(MyObject()) == NotImplemented
|
|
assert MyObject().__lt__(MyObject()) == NotImplemented
|
|
assert MyObject().__le__(MyObject()) == NotImplemented
|
|
assert MyObject().__gt__(MyObject()) == NotImplemented
|
|
assert MyObject().__ge__(MyObject()) == NotImplemented
|
|
|
|
obj = MyObject()
|
|
|
|
assert obj.__eq__(obj) is True
|
|
assert obj.__ne__(obj) is False
|
|
|
|
assert not hasattr(obj, "a")
|
|
obj.__dict__ = {"a": 1}
|
|
assert obj.a == 1
|
|
|
|
del obj.__dict__
|
|
d = obj.__dict__
|
|
assert isinstance(d, dict)
|
|
assert len(d) == 0
|
|
|
|
try:
|
|
obj.a
|
|
assert False, "AttributeError expected"
|
|
except AttributeError:
|
|
pass
|
|
|
|
# Value inside the formatter goes through a different path of resolution.
|
|
# Check that it still works all the same
|
|
d = {
|
|
0: "ab",
|
|
}
|
|
assert "ab ab" == "{k[0]} {vv}".format(k=d, vv=d[0])
|