diff --git a/pysnooper/__init__.py b/pysnooper/__init__.py index a7e0464..2135595 100644 --- a/pysnooper/__init__.py +++ b/pysnooper/__init__.py @@ -7,7 +7,7 @@ import collections __VersionInfo = collections.namedtuple('VersionInfo', ('major', 'minor', 'micro')) -__version__ = '0.0.23' +__version__ = '0.0.24' __version_info__ = __VersionInfo(*(map(int, __version__.split('.')))) del collections, __VersionInfo # Avoid polluting the namespace diff --git a/pysnooper/tracer.py b/pysnooper/tracer.py index bc4dbd0..c4f4407 100644 --- a/pysnooper/tracer.py +++ b/pysnooper/tracer.py @@ -14,6 +14,7 @@ except ImportError: import __builtin__ as builtins from .third_party import six +from . import utils ipython_filename_pattern = re.compile('^$') @@ -109,7 +110,7 @@ def get_source_from_frame(frame): try: with open(file_name, 'rb') as fp: source = fp.read().splitlines() - except (OSError, IOError): + except utils.file_reading_errors: pass if source is None: source = UnavailableSource() diff --git a/pysnooper/utils.py b/pysnooper/utils.py index fc6a89c..07d8814 100644 --- a/pysnooper/utils.py +++ b/pysnooper/utils.py @@ -30,3 +30,9 @@ class WritableStream(ABC): return _check_methods(C, 'write') return NotImplemented + +file_reading_errors = ( + IOError, + OSError, + ValueError # IronPython weirdness. +)