Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions pyext.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@

import sys, inspect, types, functools

if not hasattr(inspect, 'getargspec'):
inspect.getargspec = inspect.getfullargspec

def _targspec(func, specs, attr='__orig_arg__'):
if hasattr(func, '__is_overload__') and func.__is_overload__:
return getattr(func, attr)
Expand Down Expand Up @@ -127,11 +130,26 @@ def _argspec(func):
except ImportError:
IPython = None
else:
# Replace IPython's argspec
oipyargspec = IPython.core.oinspect.getargspec
try:
oipyargspec = IPython.core.oinspect.getargspec
except AttributeError:

def _get_ipython_argspec(func):
if hasattr(inspect, "getfullargspec"):
argspec = inspect.getfullargspec(func)
else:
argspec = inspect.getargspec(func)
return argspec

oipyargspec = _get_ipython_argspec

def _ipyargspec(func):
return _targspec(func, oipyargspec, '__orig_arg_ipy__')
IPython.core.oinspect.getargspec = _ipyargspec

try:
IPython.core.oinspect.getargspec = _ipyargspec
except AttributeError:
pass

class overload(object):
'''Simple function overloading in Python.'''
Expand Down