From a1517196e146ae0c40f3e7aee804a4089c612b73 Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Wed, 28 Aug 2019 20:31:16 +0300 Subject: [PATCH] Fix bug with empty source --- pysnooper/tracer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pysnooper/tracer.py b/pysnooper/tracer.py index 9b090a8..0844c59 100644 --- a/pysnooper/tracer.py +++ b/pysnooper/tracer.py @@ -80,7 +80,9 @@ def get_path_and_source_from_frame(frame): source = fp.read().splitlines() except utils.file_reading_errors: pass - if source is None: + if not source: + # We used to check `if source is None` but I found a rare bug where it + # was empty, but not `None`, so now we check `if not source`. source = UnavailableSource() # If we just read the source from a file, or if the loader did not