Skip to content

Commit

Permalink
Fixed IPython issue
Browse files Browse the repository at this point in the history
  • Loading branch information
micheles committed Jan 14, 2018
1 parent 12caca9 commit 723c5ce
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ HISTORY

## Unreleased

## 4.2.1 (2018-01-14)

Fixed a regression breaking IPython and discovered by https://github.com/spapini

## 4.2.0 (2018-01-14)

Added a facility to define families of decorators (aka decorators with
Expand Down
4 changes: 2 additions & 2 deletions docs/tests.documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ The ``decorator`` module

:Author: Michele Simionato
:E-mail: michele.simionato@gmail.com
:Version: 4.2.0 (2018-01-14)
:Version: 4.2.1 (2018-01-14)
:Supports: Python 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6
:Download page: http://pypi.python.org/pypi/decorator/4.2.0
:Download page: http://pypi.python.org/pypi/decorator/4.2.1
:Installation: ``pip install decorator``
:License: BSD license

Expand Down
5 changes: 3 additions & 2 deletions src/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import itertools
import collections

__version__ = '4.2.0'
__version__ = '4.2.1'

if sys.version >= '3':
from inspect import getfullargspec
Expand Down Expand Up @@ -261,7 +261,8 @@ def decorator(caller, _func=None):
name = caller.__name__
doc = caller.__doc__
nargs = caller.__code__.co_argcount
defaultargs = ', '.join(caller.__code__.co_varnames[1:nargs])
ndefs = len(caller.__defaults__ or ())
defaultargs = ', '.join(caller.__code__.co_varnames[nargs-ndefs:nargs])
if defaultargs:
defaultargs += ','
defaults = caller.__defaults__
Expand Down
6 changes: 6 additions & 0 deletions src/tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ def func(**kw):
# there is no confusion when passing args as a keyword argument
self.assertEqual(func(args='a'), {'args': 'a'})

def test_decorator_factory(self):
# similar to what IPython is doing in traitlets.config.application
@decorator
def catch_config_error(method, app, *args, **kwargs):
return method(app)
catch_config_error(lambda app: None)

# ################### test dispatch_on ############################# #
# adapted from test_functools in Python 3.5
Expand Down

0 comments on commit 723c5ce

Please sign in to comment.