Skip to content

Commit 8ff33d5

Browse files
author
James William Pye
committed
Merge commit 'v0.8.0'; branch 'v0.8'
2 parents 322d79a + 0a190a6 commit 8ff33d5

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

postgresql/documentation/changes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
-----
1919
2020
* Fix encoding normalization.
21+
* Fix "method" decorator to return callable when val is None.
2122
2223
0.8.0 released on 2009-04-03
2324
----------------------------

postgresql/python/decorlib.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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)

postgresql/test/test_python.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ def testComposition(self):
119119
self.failUnlessEqual("100", simple("100"))
120120
timesfour_fourtimes = compose((methodcaller('__mul__', 4),)*4)
121121
self.failUnlessEqual(4*(4*4*4*4), timesfour_fourtimes(4))
122+
nothing = compose(())
123+
self.failUnlessEqual(nothing("100"), "100")
124+
self.failUnlessEqual(nothing(100), 100)
125+
self.failUnlessEqual(nothing(None), None)
122126

123127
def testRSetAttr(self):
124128
class anob(object):

0 commit comments

Comments
 (0)