diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2016-10-17 11:28:43 -0400 |
---|---|---|
committer | Gerrit Code Review <gerrit2@ln3.zzzcomputing.com> | 2016-10-17 11:28:43 -0400 |
commit | 4684cfb50836dc57107e49d4a78a8889c40d9662 (patch) | |
tree | 942a437d62437988678ff5e09383d6c04814f005 | |
parent | d18221c542bf4d7381be2afdcd4c098698ff8eae (diff) | |
parent | 665b92d83f3a93d8df54338a35f2b3e70e7f21a0 (diff) | |
download | sqlalchemy-4684cfb50836dc57107e49d4a78a8889c40d9662.tar.gz |
Merge "Check for __module__ not present in util.wrap_callable()"
-rw-r--r-- | doc/build/changelog/changelog_11.rst | 11 | ||||
-rw-r--r-- | lib/sqlalchemy/util/langhelpers.py | 3 | ||||
-rw-r--r-- | test/base/test_utils.py | 13 |
3 files changed, 26 insertions, 1 deletions
diff --git a/doc/build/changelog/changelog_11.rst b/doc/build/changelog/changelog_11.rst index b879adc10..b90b932b5 100644 --- a/doc/build/changelog/changelog_11.rst +++ b/doc/build/changelog/changelog_11.rst @@ -21,6 +21,17 @@ .. changelog:: :version: 1.1.2 + .. change:: + :tags: bug, sql + :tickets: 3823 + + Fixed a regression caused by a newly added function that performs the + "wrap callable" function of sql :class:`.DefaultGenerator` objects, + an attribute error raised for ``__module__`` when the default callable + was a ``functools.partial`` or other object that doesn't have a + ``__module__`` attribute. + + .. changelog:: :version: 1.1.1 :released: October 7, 2016 diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index 4675f7cdb..f2ca80664 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -1398,7 +1398,8 @@ def wrap_callable(wrapper, fn): else: _f = wrapper _f.__name__ = fn.__class__.__name__ - _f.__module__ = fn.__module__ + if hasattr(fn, '__module__'): + _f.__module__ = fn.__module__ if hasattr(fn.__call__, '__doc__') and fn.__call__.__doc__: _f.__doc__ = fn.__call__.__doc__ diff --git a/test/base/test_utils.py b/test/base/test_utils.py index 7e2473dee..5199d6155 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -382,6 +382,19 @@ class WrapCallableTest(fixtures.TestBase): eq_(c.__name__, "MyFancyDefault") eq_(c.__doc__, None) + def test_wrapping_update_wrapper_functools_parial(self): + def my_default(x): + return x + + import functools + my_functools_default = functools.partial(my_default, 5) + + c = util.wrap_callable( + lambda: my_functools_default(), my_functools_default) + eq_(c.__name__, "partial") + eq_(c.__doc__, my_functools_default.__call__.__doc__) + eq_(c(), 5) + class ToListTest(fixtures.TestBase): def test_from_string(self): |