From e2f780ceffd86bce0c6732d861e73eb86a68a0e6 Mon Sep 17 00:00:00 2001 From: Jarek Glowacki Date: Fri, 8 Jul 2016 00:54:05 +1000 Subject: [PATCH] Improve module import from ref --- apscheduler/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apscheduler/util.py b/apscheduler/util.py index 62e3362e..72ff46b4 100644 --- a/apscheduler/util.py +++ b/apscheduler/util.py @@ -259,12 +259,12 @@ def ref_to_obj(ref): modulename, rest = ref.split(':', 1) try: - obj = __import__(modulename) + obj = __import__(modulename, globals(), locals(), [rest]) except ImportError: raise LookupError('Error resolving reference %s: could not import module' % ref) try: - for name in modulename.split('.')[1:] + rest.split('.'): + for name in rest.split('.'): obj = getattr(obj, name) return obj except Exception: