Skip to content

Commit e6d8953

Browse files
jbrockmendeljreback
authored andcommitted
Fix make_signature TypeError in py3 (pandas-dev#17609)
1 parent d1fe892 commit e6d8953

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

pandas/tests/util/test_util.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pytest
1010
from pandas.compat import intern
1111
from pandas.util._move import move_into_mutable_buffer, BadMove, stolenbuf
12-
from pandas.util._decorators import deprecate_kwarg
12+
from pandas.util._decorators import deprecate_kwarg, make_signature
1313
from pandas.util._validators import (validate_args, validate_kwargs,
1414
validate_args_and_kwargs,
1515
validate_bool_kwarg)
@@ -467,3 +467,17 @@ def test_set_locale(self):
467467

468468
current_locale = locale.getlocale()
469469
assert current_locale == self.current_locale
470+
471+
472+
def test_make_signature():
473+
# See GH 17608
474+
# Case where the func does not have default kwargs
475+
sig = make_signature(validate_kwargs)
476+
assert sig == (['fname', 'kwargs', 'compat_args'],
477+
['fname', 'kwargs', 'compat_args'])
478+
479+
# Case where the func does have default kwargs
480+
sig = make_signature(deprecate_kwarg)
481+
assert sig == (['old_arg_name', 'new_arg_name',
482+
'mapping=None', 'stacklevel=2'],
483+
['old_arg_name', 'new_arg_name', 'mapping', 'stacklevel'])

pandas/util/_decorators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def make_signature(func):
242242
defaults = ('',) * n_wo_defaults
243243
else:
244244
n_wo_defaults = len(spec.args) - len(spec.defaults)
245-
defaults = ('',) * n_wo_defaults + spec.defaults
245+
defaults = ('',) * n_wo_defaults + tuple(spec.defaults)
246246
args = []
247247
for i, (var, default) in enumerate(zip(spec.args, defaults)):
248248
args.append(var if default == '' else var + '=' + repr(default))

0 commit comments

Comments
 (0)