From 6864aabe31e51c95b122594ceb95f764f92b358e Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Mon, 4 Nov 2019 14:36:30 +0700 Subject: [PATCH 1/2] _build_tlz: Ignore missing __file__ Many Python freezer tools have loaders that either do not set __file__ or they set __file__ with a guess, or it triggers a slower load process. --- tlz/_build_tlz.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tlz/_build_tlz.py b/tlz/_build_tlz.py index 3c017a54..f29eed1b 100644 --- a/tlz/_build_tlz.py +++ b/tlz/_build_tlz.py @@ -63,7 +63,10 @@ def exec_module(self, module): module.__doc__ = fast_mod.__doc__ # show file from toolz during introspection - module.__file__ = slow_mod.__file__ + try: + module.__file__ = slow_mod.__file__ + except AttributeError: + pass for k, v in fast_mod.__dict__.items(): tv = slow_mod.__dict__.get(k) From e6d27a2066dc8af3211a5bb6073e2cf6a76e4261 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Mon, 4 Nov 2019 15:06:37 +0700 Subject: [PATCH 2/2] test_tlz: Ignore missing __file__ Skip asserts if __file__ is missing. --- toolz/tests/test_tlz.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/toolz/tests/test_tlz.py b/toolz/tests/test_tlz.py index ed2646a8..c449f607 100644 --- a/toolz/tests/test_tlz.py +++ b/toolz/tests/test_tlz.py @@ -46,8 +46,10 @@ def test_tlz(): except ImportError: pass - assert tlz.__file__ == toolz.__file__ - assert tlz.functoolz.__file__ == toolz.functoolz.__file__ + if hasattr(tlz, '__file__'): + assert tlz.__file__ == toolz.__file__ + if hasattr(tlz.functoolz, '__file__'): + assert tlz.functoolz.__file__ == toolz.functoolz.__file__ assert tlz.pipe is toolz.pipe