summaryrefslogtreecommitdiff
path: root/pint/registry_helpers.py
diff options
context:
space:
mode:
authorJonathan Wheeler <jonathan.m.wheeler@gmail.com>2018-07-13 08:13:19 -0700
committerJonathan Wheeler <jonathan.m.wheeler@gmail.com>2018-07-13 08:13:19 -0700
commit735ebecbdba6d4104ee8a22816eca4285f5cd84a (patch)
tree9c6519e9792f3cd3fed5d1c6bb6a22d9a822daf2 /pint/registry_helpers.py
parentcac6e839dc7afceab501459ca7118bb3d5a8ce1e (diff)
downloadpint-735ebecbdba6d4104ee8a22816eca4285f5cd84a.tar.gz
Added backwards compatibility for py27
Diffstat (limited to 'pint/registry_helpers.py')
-rw-r--r--pint/registry_helpers.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/pint/registry_helpers.py b/pint/registry_helpers.py
index 1136831..cc692d8 100644
--- a/pint/registry_helpers.py
+++ b/pint/registry_helpers.py
@@ -18,8 +18,8 @@ from .util import to_units_container, UnitsContainer
try:
from inspect import signature
except ImportError:
- # Python2 does not have the inspect library.
- pass
+ # Python2 does not have the inspect library. Import the backport.
+ from funcsigs import signature
# for detecting whether we can support the inspect library
import sys
@@ -174,18 +174,18 @@ def wraps(ureg, ret, args, strict=True):
@functools.wraps(func, assigned=assigned, updated=updated)
def wrapper(*values, **kw):
- if sys.version_info >= (3, 0):
- # Named keywords may have been left blank. Wherever the named keyword is blank,
- # fill it in with the default value.
- sig = signature(func)
- bound_arguments = sig.bind(*values, **kw)
- for param in sig.parameters.values():
- if param.name not in bound_arguments.arguments:
- bound_arguments.arguments[param.name] = param.default
+ # Named keywords may have been left blank. Wherever the named keyword is blank,
+ # fill it in with the default value.
+ sig = signature(func)
+ bound_arguments = sig.bind(*values, **kw)
- values = [bound_arguments.arguments[key] for key in sig.parameters.keys()]
- kw = {}
+ for param in sig.parameters.values():
+ if param.name not in bound_arguments.arguments:
+ bound_arguments.arguments[param.name] = param.default
+
+ values = [bound_arguments.arguments[key] for key in sig.parameters.keys()]
+ kw = {}
# In principle, the values are used as is
# When then extract the magnitudes when needed.