Skip to content

Commit

Permalink
Fix import_module ignoring e.g. 1.12.0 when min_module_version='1.6.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
bjodah committed Feb 27, 2017
1 parent efdb61b commit 0517911
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sympy/external/importtools.py
Expand Up @@ -3,6 +3,7 @@
from __future__ import print_function, division

import sys
from distutils.version import LooseVersion

# Override these in the module to change the default warning behavior.
# For example, you might set both to False before running the tests so that
Expand Down Expand Up @@ -154,10 +155,10 @@ def import_module(module, min_module_version=None, min_python_version=None,
modversion = getattr(mod, module_version_attr)
if module_version_attr_call_args is not None:
modversion = modversion(*module_version_attr_call_args)
if modversion < min_module_version:
if modversion < LooseVersion(min_module_version):
if warn_old_version:
# Attempt to create a pretty string version of the version
if isinstance(min_module_version, basestring):
if isinstance(min_module_version, str if sys.version_info[0] > 2 else basestring):
verstr = min_module_version
elif isinstance(min_module_version, (tuple, list)):
verstr = '.'.join(map(str, min_module_version))
Expand Down

0 comments on commit 0517911

Please sign in to comment.