Skip to content

Commit

Permalink
_pytest._py.path: importlib mode always available
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile committed Oct 19, 2022
1 parent 61b29d6 commit cb713c6
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/_pytest/_py/path.py
@@ -1,8 +1,11 @@
"""
local path implementation.
"""
from __future__ import annotations

import atexit
import fnmatch
import importlib.util
import io
import os
import posixpath
Expand Down Expand Up @@ -440,11 +443,6 @@ def map_as_list(func, iter):
return list(map(func, iter))


ALLOW_IMPORTLIB_MODE = sys.version_info > (3, 5)
if ALLOW_IMPORTLIB_MODE:
import importlib


class Stat:
def __getattr__(self, name):
return getattr(self._osstatresult, "st_" + name)
Expand Down Expand Up @@ -1110,8 +1108,6 @@ def pyimport(self, modname=None, ensuresyspath=True):
if ensuresyspath == "importlib":
if modname is None:
modname = self.purebasename
if not ALLOW_IMPORTLIB_MODE:
raise ImportError("Can't use importlib due to old version of Python")
spec = importlib.util.spec_from_file_location(modname, str(self))
if spec is None:
raise ImportError(
Expand Down

0 comments on commit cb713c6

Please sign in to comment.