[Python-checkins] r52476 - in python/trunk/Lib: functools.py test/test_functools.py
andrew.kuchling
python-checkins at python.org
Fri Oct 27 18:39:11 CEST 2006
Author: andrew.kuchling
Date: Fri Oct 27 18:39:10 2006
New Revision: 52476
Modified:
python/trunk/Lib/functools.py
python/trunk/Lib/test/test_functools.py
Log:
[Bug #1576241] Let functools.wraps work with built-in functions
Modified: python/trunk/Lib/functools.py
==============================================================================
--- python/trunk/Lib/functools.py (original)
+++ python/trunk/Lib/functools.py Fri Oct 27 18:39:10 2006
@@ -32,7 +32,7 @@
for attr in assigned:
setattr(wrapper, attr, getattr(wrapped, attr))
for attr in updated:
- getattr(wrapper, attr).update(getattr(wrapped, attr))
+ getattr(wrapper, attr).update(getattr(wrapped, attr, {}))
# Return the wrapper so this can be used as a decorator via partial()
return wrapper
Modified: python/trunk/Lib/test/test_functools.py
==============================================================================
--- python/trunk/Lib/test/test_functools.py (original)
+++ python/trunk/Lib/test/test_functools.py Fri Oct 27 18:39:10 2006
@@ -210,6 +210,13 @@
self.assertEqual(wrapper.attr, 'This is a different test')
self.assertEqual(wrapper.dict_attr, f.dict_attr)
+ def test_builtin_update(self):
+ # Test for bug #1576241
+ def wrapper():
+ pass
+ functools.update_wrapper(wrapper, max)
+ self.assertEqual(wrapper.__name__, 'max')
+ self.assert_(wrapper.__doc__.startswith('max('))
class TestWraps(TestUpdateWrapper):
More information about the Python-checkins
mailing list