Skip to content

Commit 1d5f957

Browse files
committed
remove other py.* accesses in _pytest._py.path
1 parent f8169fc commit 1d5f957

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/_pytest/_py/path.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,9 @@ def __fspath__(self):
428428

429429
class Visitor:
430430
def __init__(self, fil, rec, ignore, bf, sort):
431-
if isinstance(fil, py.builtin._basestring):
431+
if isinstance(fil, str):
432432
fil = FNMatcher(fil)
433-
if isinstance(rec, py.builtin._basestring):
433+
if isinstance(rec, str):
434434
self.rec = FNMatcher(rec)
435435
elif not hasattr(rec, "__call__") and rec:
436436
self.rec = lambda path: True
@@ -882,7 +882,7 @@ def listdir(self, fil=None, sort=None):
882882
if fil is None and sort is None:
883883
names = error.checked_call(os.listdir, self.strpath)
884884
return map_as_list(self._fastjoin, names)
885-
if isinstance(fil, py.builtin._basestring):
885+
if isinstance(fil, str):
886886
if not self._patternchars.intersection(fil):
887887
child = self._fastjoin(fil)
888888
if exists(child.strpath):
@@ -989,14 +989,14 @@ def write(self, data, mode="w", ensure=False):
989989
if ensure:
990990
self.dirpath().ensure(dir=1)
991991
if "b" in mode:
992-
if not py.builtin._isbytes(data):
992+
if not isinstance(data, bytes):
993993
raise ValueError("can only process bytes")
994994
else:
995-
if not py.builtin._istext(data):
996-
if not py.builtin._isbytes(data):
995+
if not isinstance(data, str):
996+
if not isinstance(data, bytes):
997997
data = str(data)
998998
else:
999-
data = py.builtin._totext(data, sys.getdefaultencoding())
999+
data = data.decode(sys.getdefaultencoding())
10001000
f = self.open(mode)
10011001
try:
10021002
f.write(data)
@@ -1221,7 +1221,8 @@ def pyimport(self, modname=None, ensuresyspath=True):
12211221
mod.__file__ = str(self)
12221222
sys.modules[modname] = mod
12231223
try:
1224-
py.builtin.execfile(str(self), mod.__dict__)
1224+
with open(str(self), 'rb') as f:
1225+
exec(f.read(), mod.__dict__)
12251226
except:
12261227
del sys.modules[modname]
12271228
raise
@@ -1239,12 +1240,12 @@ def sysexec(self, *argv, **popen_opts):
12391240
proc = Popen([str(self)] + argv, **popen_opts)
12401241
stdout, stderr = proc.communicate()
12411242
ret = proc.wait()
1242-
if py.builtin._isbytes(stdout):
1243-
stdout = py.builtin._totext(stdout, sys.getdefaultencoding())
1243+
if isinstance(stdout, bytes):
1244+
stdout = stdout.decode(sys.getdefaultencoding())
12441245
if ret != 0:
1245-
if py.builtin._isbytes(stderr):
1246-
stderr = py.builtin._totext(stderr, sys.getdefaultencoding())
1247-
raise py.process.cmdexec.Error(
1246+
if isinstance(stderr, bytes):
1247+
stderr = stderr.decode(sys.getdefaultencoding())
1248+
raise RuntimeError(
12481249
ret,
12491250
ret,
12501251
str(self),
@@ -1262,7 +1263,7 @@ def sysfind(cls, name, checker=None, paths=None):
12621263
but may work on cygwin.
12631264
"""
12641265
if isabs(name):
1265-
p = py.path.local(name)
1266+
p = local(name)
12661267
if p.check(file=1):
12671268
return p
12681269
else:
@@ -1288,7 +1289,7 @@ def sysfind(cls, name, checker=None, paths=None):
12881289

12891290
for x in paths:
12901291
for addext in tryadd:
1291-
p = py.path.local(x).join(name, abs=True) + addext
1292+
p = local(x).join(name, abs=True) + addext
12921293
try:
12931294
if p.check(file=1):
12941295
if checker:
@@ -1323,7 +1324,7 @@ def get_temproot(cls):
13231324
"""
13241325
import tempfile
13251326

1326-
return py.path.local(tempfile.gettempdir())
1327+
return local(tempfile.gettempdir())
13271328

13281329
@classmethod
13291330
def mkdtemp(cls, rootdir=None):

0 commit comments

Comments
 (0)