File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 24
24
PY_3_10_PLUS ,
25
25
PY_3_11_PLUS ,
26
26
PY_3_13_PLUS ,
27
+ PY_3_14_PLUS ,
27
28
_AnnotationExtractor ,
28
29
_get_annotations ,
29
30
get_generic_base ,
@@ -618,6 +619,17 @@ def evolve(*args, **changes):
618
619
return cls (** changes )
619
620
620
621
622
+ # Hack to the get the underlying dict out of a mappingproxy
623
+ # Use it with: cls.__dict__ | _deproxier
624
+ # See: https://github.com/python/cpython/pull/136893
625
+ class _Deproxier :
626
+ def __ror__ (self , other ):
627
+ return other
628
+
629
+
630
+ _deproxier = _Deproxier ()
631
+
632
+
621
633
class _ClassBuilder :
622
634
"""
623
635
Iteratively build *one* class.
@@ -845,6 +857,13 @@ def _create_slots_class(self):
845
857
if k not in (* tuple (self ._attr_names ), "__dict__" , "__weakref__" )
846
858
}
847
859
860
+ if PY_3_14_PLUS :
861
+ # Clean up old dict to avoid leaks.
862
+ old_cls_dict = self ._cls .__dict__ | _deproxier
863
+ old_cls_dict .pop ("__dict__" , None )
864
+ if "__weakref__" in self ._cls .__dict__ :
865
+ del self ._cls .__weakref__
866
+
848
867
# If our class doesn't have its own implementation of __setattr__
849
868
# (either from the user or by us), check the bases, if one of them has
850
869
# an attrs-made __setattr__, that needs to be reset. We don't walk the
Original file line number Diff line number Diff line change 23
23
import attr
24
24
25
25
from attr import _config
26
- from attr ._compat import PY_3_10_PLUS , PY_3_14_PLUS
26
+ from attr ._compat import PY_3_10_PLUS
27
27
from attr ._make import (
28
28
Attribute ,
29
29
Factory ,
@@ -1896,7 +1896,6 @@ class C2(C):
1896
1896
1897
1897
assert [C2 ] == C .__subclasses__ ()
1898
1898
1899
- @pytest .mark .xfail (PY_3_14_PLUS , reason = "Currently broken on nightly." )
1900
1899
def test_no_references_to_original_when_using_cached_property (self ):
1901
1900
"""
1902
1901
When subclassing a slotted class and using cached property, there are
You can’t perform that action at this time.
0 commit comments