@@ -428,9 +428,9 @@ def __fspath__(self):
428
428
429
429
class Visitor :
430
430
def __init__ (self , fil , rec , ignore , bf , sort ):
431
- if isinstance (fil , py . builtin . _basestring ):
431
+ if isinstance (fil , str ):
432
432
fil = FNMatcher (fil )
433
- if isinstance (rec , py . builtin . _basestring ):
433
+ if isinstance (rec , str ):
434
434
self .rec = FNMatcher (rec )
435
435
elif not hasattr (rec , "__call__" ) and rec :
436
436
self .rec = lambda path : True
@@ -882,7 +882,7 @@ def listdir(self, fil=None, sort=None):
882
882
if fil is None and sort is None :
883
883
names = error .checked_call (os .listdir , self .strpath )
884
884
return map_as_list (self ._fastjoin , names )
885
- if isinstance (fil , py . builtin . _basestring ):
885
+ if isinstance (fil , str ):
886
886
if not self ._patternchars .intersection (fil ):
887
887
child = self ._fastjoin (fil )
888
888
if exists (child .strpath ):
@@ -989,14 +989,14 @@ def write(self, data, mode="w", ensure=False):
989
989
if ensure :
990
990
self .dirpath ().ensure (dir = 1 )
991
991
if "b" in mode :
992
- if not py . builtin . _isbytes (data ):
992
+ if not isinstance (data , bytes ):
993
993
raise ValueError ("can only process bytes" )
994
994
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 ):
997
997
data = str (data )
998
998
else :
999
- data = py . builtin . _totext ( data , sys .getdefaultencoding ())
999
+ data = data . decode ( sys .getdefaultencoding ())
1000
1000
f = self .open (mode )
1001
1001
try :
1002
1002
f .write (data )
@@ -1221,7 +1221,8 @@ def pyimport(self, modname=None, ensuresyspath=True):
1221
1221
mod .__file__ = str (self )
1222
1222
sys .modules [modname ] = mod
1223
1223
try :
1224
- py .builtin .execfile (str (self ), mod .__dict__ )
1224
+ with open (str (self ), 'rb' ) as f :
1225
+ exec (f .read (), mod .__dict__ )
1225
1226
except :
1226
1227
del sys .modules [modname ]
1227
1228
raise
@@ -1239,12 +1240,12 @@ def sysexec(self, *argv, **popen_opts):
1239
1240
proc = Popen ([str (self )] + argv , ** popen_opts )
1240
1241
stdout , stderr = proc .communicate ()
1241
1242
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 ())
1244
1245
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 (
1248
1249
ret ,
1249
1250
ret ,
1250
1251
str (self ),
@@ -1262,7 +1263,7 @@ def sysfind(cls, name, checker=None, paths=None):
1262
1263
but may work on cygwin.
1263
1264
"""
1264
1265
if isabs (name ):
1265
- p = py . path . local (name )
1266
+ p = local (name )
1266
1267
if p .check (file = 1 ):
1267
1268
return p
1268
1269
else :
@@ -1288,7 +1289,7 @@ def sysfind(cls, name, checker=None, paths=None):
1288
1289
1289
1290
for x in paths :
1290
1291
for addext in tryadd :
1291
- p = py . path . local (x ).join (name , abs = True ) + addext
1292
+ p = local (x ).join (name , abs = True ) + addext
1292
1293
try :
1293
1294
if p .check (file = 1 ):
1294
1295
if checker :
@@ -1323,7 +1324,7 @@ def get_temproot(cls):
1323
1324
"""
1324
1325
import tempfile
1325
1326
1326
- return py . path . local (tempfile .gettempdir ())
1327
+ return local (tempfile .gettempdir ())
1327
1328
1328
1329
@classmethod
1329
1330
def mkdtemp (cls , rootdir = None ):
0 commit comments