File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010-----
1111
1212 * Fix encoding normalization.
13+ * Fix "method" decorator to return callable when val is None.
1314
14150.8.0 released on 2009-04-03
1516----------------------------
Original file line number Diff line number Diff line change @@ -40,4 +40,6 @@ class method(object):
4040 def __init__ (self , callable ):
4141 self .callable = callable
4242 def __get__ (self , val , typ ):
43- return types .MethodType (self .callable , val or typ )
43+ if val is None :
44+ return self .callable
45+ return types .MethodType (self .callable , val )
Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ def testComposition(self):
3030 self .failUnlessEqual ("100" , simple ("100" ))
3131 timesfour_fourtimes = compose ((methodcaller ('__mul__' , 4 ),)* 4 )
3232 self .failUnlessEqual (4 * (4 * 4 * 4 * 4 ), timesfour_fourtimes (4 ))
33+ nothing = compose (())
34+ self .failUnlessEqual (nothing ("100" ), "100" )
35+ self .failUnlessEqual (nothing (100 ), 100 )
36+ self .failUnlessEqual (nothing (None ), None )
3337
3438 def testRSetAttr (self ):
3539 class anob (object ):
You can’t perform that action at this time.
0 commit comments