File tree 2 files changed +18
-9
lines changed
2 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,9 @@ In next release ...
5
5
6
6
Bugfixes:
7
7
8
+ - Persistent subclasses now correctly call ``__init__`` on
9
+ construction.
10
+
8
11
- Add support for ``__slots__``.
9
12
10
13
0.3 (2012-02-02)
Original file line number Diff line number Diff line change @@ -60,18 +60,24 @@ class Persistent(object):
60
60
_p_resolve_conflict = None
61
61
62
62
def __new__ (cls , * args , ** kwargs ):
63
- for base in cls .__mro__ :
64
- if base .__new__ is cls .__new__ :
65
- continue
66
- try :
67
- inst = base .__new__ (cls )
68
- except TypeError :
69
- continue
70
- break
63
+ bases = cls .__mro__
64
+ try :
65
+ index = bases .index (Local )
66
+ except ValueError :
67
+ for base in bases :
68
+ if base .__new__ is cls .__new__ :
69
+ continue
70
+ factory = base .__new__
71
+ break
72
+ else :
73
+ factory = object .__new__
71
74
else :
72
- raise TypeError ("Can't create object of type %s." % repr (cls ))
75
+ cls = bases [index + 1 ]
76
+ factory = object .__new__
73
77
78
+ inst = factory (cls )
74
79
checkout (inst )
80
+ inst .__init__ (* args , ** kwargs )
75
81
return inst
76
82
77
83
def __deepcopy__ (self , memo ):
You can’t perform that action at this time.
0 commit comments