Kwpolska / merge_args

Merge signatures of two functions with Advanced Hackery.
BSD 3-Clause "New" or "Revised" License
31 stars 6 forks source link

Doesn't work in Python 3.8 #2

Closed Bobronium closed 4 years ago

Bobronium commented 4 years ago
Traceback (most recent call last):
   ...
  File ".../python3.8/site-packages/merge_args.py", line 96, in _merge
    passer_code = types.CodeType(len(args_merged), len(kwonlyargs_merged),
TypeError: code() takes at least 14 arguments (13 given)

Found similar issue: https://github.com/Suor/whatever/issues/7

Also, might be helpful: https://docs.python.org/3/whatsnew/3.8.html

types.CodeType has a new parameter in the second position of the constructor (posonlyargcount) to support positional-only arguments defined in PEP 570. The first argument (argcount) now represents the total number of positional arguments (including positional-only arguments). The new replace() method of types.CodeType can be used to make the code future-proof.