From a6a56328ac88049f42012c3d492f9d8c2b9c347e Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Fri, 7 Mar 2014 11:00:47 -0600 Subject: Fixed issue in obj_to_ref when __module__ attribute doesn't exist. --- apscheduler/util.py | 2 +- tests/testutil.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apscheduler/util.py b/apscheduler/util.py index dcede4c..ffb3a55 100644 --- a/apscheduler/util.py +++ b/apscheduler/util.py @@ -162,8 +162,8 @@ def obj_to_ref(obj): """ Returns the path to the given object. """ - ref = '%s:%s' % (obj.__module__, get_callable_name(obj)) try: + ref = '%s:%s' % (obj.__module__, get_callable_name(obj)) obj2 = ref_to_obj(ref) if obj != obj2: raise ValueError diff --git a/tests/testutil.py b/tests/testutil.py index b9749fb..399560a 100644 --- a/tests/testutil.py +++ b/tests/testutil.py @@ -1,5 +1,6 @@ # coding: utf-8 from datetime import date, datetime, timedelta +from functools import partial import time import os import sys @@ -185,6 +186,7 @@ def test_callable_name(): def test_obj_to_ref(): assert_raises(ValueError, obj_to_ref, DummyClass.meth) assert_raises(ValueError, obj_to_ref, DummyClass.staticmeth) + assert_raises(ValueError, obj_to_ref, partial(DummyClass.meth)) eq_(obj_to_ref(DummyClass.classmeth), 'testutil:DummyClass.classmeth') eq_(obj_to_ref(shelve.open), 'shelve:open') -- cgit v1.2.1