Skip to content

Commit 3390863

Browse files
committed
Fix some coverage and pep8 issues.
1 parent 07359ad commit 3390863

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

toolz/functoolz.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,14 @@ def __reduce__(self):
329329
func = self.func
330330
modname = getattr(func, '__module__', None)
331331
qualname = getattr(func, '__qualname__', None)
332-
if qualname is None:
332+
if qualname is None: # pragma: py3 no cover
333333
qualname = getattr(func, '__name__', None)
334334
is_decorated = None
335335
if modname and qualname:
336336
attrs = []
337337
obj = import_module(modname)
338338
for attr in qualname.split('.'):
339-
if isinstance(obj, curry):
339+
if isinstance(obj, curry): # pragma: py2 no cover
340340
attrs.append('func')
341341
obj = obj.func
342342
obj = getattr(obj, attr, None)
@@ -351,7 +351,8 @@ def __reduce__(self):
351351
# functools.partial objects can't be pickled
352352
userdict = tuple((k, v) for k, v in self.__dict__.items()
353353
if k != '_partial')
354-
state = (type(self), func, self.args, self.keywords, userdict, is_decorated)
354+
state = (type(self), func, self.args, self.keywords, userdict,
355+
is_decorated)
355356
return (_restore_curry, state)
356357

357358

toolz/tests/test_serialization.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import toolz.curried.exceptions
44
import pickle
55
from toolz.compatibility import PY3
6+
from toolz.utils import raises
67

78

89
def test_compose():
@@ -177,3 +178,11 @@ def preserves_identity(obj):
177178
func2 = pickle.loads(pickle.dumps(func1))
178179
assert func1 is not func2
179180
assert func1(4) == func2(4) == 10
181+
182+
183+
def test_curried_bad_qualname():
184+
@toolz.curry
185+
class Bad(object):
186+
__qualname__ = 'toolz.functoolz.not.a.valid.path'
187+
188+
assert raises(pickle.PicklingError, lambda: pickle.dumps(Bad))

0 commit comments

Comments
 (0)