Catch ValueError because IronPython raises it on bad filename #75

This commit is contained in:
Ram Rachum 2019-04-30 20:29:12 +03:00
parent eb59047a88
commit 59d3a9d178
3 changed files with 9 additions and 2 deletions

View file

@ -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

View file

@ -14,6 +14,7 @@ except ImportError:
import __builtin__ as builtins
from .third_party import six
from . import utils
ipython_filename_pattern = re.compile('^<ipython-input-([0-9]+)-.*>$')
@ -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()

View file

@ -30,3 +30,9 @@ class WritableStream(ABC):
return _check_methods(C, 'write')
return NotImplemented
file_reading_errors = (
IOError,
OSError,
ValueError # IronPython weirdness.
)