diff --git a/parso/_compatibility.py b/parso/_compatibility.py index 4c966d6..f1f0b0f 100644 --- a/parso/_compatibility.py +++ b/parso/_compatibility.py @@ -44,20 +44,6 @@ def u(string): return string -try: - # Python 3.3+ - FileNotFoundError = FileNotFoundError -except NameError: - # Python 2.7 (both IOError + OSError) - FileNotFoundError = EnvironmentError -try: - # Python 3.3+ - PermissionError = PermissionError -except NameError: - # Python 2.7 (both IOError + OSError) - PermissionError = EnvironmentError - - def utf8_repr(func): """ ``__repr__`` methods in Python 2 don't allow unicode objects to be diff --git a/parso/cache.py b/parso/cache.py index 8644423..d9be412 100644 --- a/parso/cache.py +++ b/parso/cache.py @@ -14,7 +14,7 @@ try: except: import pickle -from parso._compatibility import FileNotFoundError, PermissionError, scandir +from parso._compatibility import scandir from parso.file_io import FileIO LOG = logging.getLogger(__name__) diff --git a/parso/file_io.py b/parso/file_io.py index 34b41ec..a9fcfe3 100644 --- a/parso/file_io.py +++ b/parso/file_io.py @@ -1,5 +1,4 @@ import os -from parso._compatibility import FileNotFoundError class FileIO(object): @@ -19,8 +18,7 @@ class FileIO(object): """ try: return os.path.getmtime(self.path) - except OSError: - # Might raise FileNotFoundError, OSError for Python 2 + except FileNotFoundError: return None def _touch(self): diff --git a/parso/grammar.py b/parso/grammar.py index 6233005..fd30f29 100644 --- a/parso/grammar.py +++ b/parso/grammar.py @@ -1,7 +1,7 @@ import hashlib import os -from parso._compatibility import FileNotFoundError, is_pypy +from parso._compatibility import is_pypy from parso.pgen2 import generate_grammar from parso.utils import split_lines, python_bytes_to_unicode, parse_version_string from parso.python.diff import DiffParser diff --git a/test/test_cache.py b/test/test_cache.py index e1a0a9e..e572527 100644 --- a/test/test_cache.py +++ b/test/test_cache.py @@ -13,7 +13,7 @@ from parso.cache import (_CACHED_FILE_MAXIMUM_SURVIVAL, _VERSION_TAG, _load_from_file_system, _NodeCacheItem, _remove_cache_and_update_lock, _save_to_file_system, load_module, parser_cache, try_to_save_module) -from parso._compatibility import is_pypy, PermissionError +from parso._compatibility import is_pypy from parso import load_grammar from parso import cache from parso import file_io