Author: Armin Rigo <[email protected]>
Branch: py3.5
Changeset: r93512:c45c28743766
Date: 2017-12-20 12:14 +0100
http://bitbucket.org/pypy/pypy/changeset/c45c28743766/
Log: Translation fixes
diff --git a/pypy/module/posix/interp_scandir.py
b/pypy/module/posix/interp_scandir.py
--- a/pypy/module/posix/interp_scandir.py
+++ b/pypy/module/posix/interp_scandir.py
@@ -269,7 +269,7 @@
def get_stat_or_lstat(self, follow_symlinks): # 'follow_symlinks'
ignored
if not self.stat_cached:
- path = self.space.unicode_w(self.fget_path(self.space))
+ path = self.space.unicode0_w(self.fget_path(self.space))
self.d_stat = rposix_stat.stat(path)
self.stat_cached = True
return self.d_stat
diff --git a/rpython/rlib/rposix_scandir.py b/rpython/rlib/rposix_scandir.py
--- a/rpython/rlib/rposix_scandir.py
+++ b/rpython/rlib/rposix_scandir.py
@@ -63,15 +63,12 @@
win32traits = make_win32_traits(unicode_traits)
- class DirP:
- def __init__(self):
- self.filedata = lltype.malloc(win32traits.WIN32_FIND_DATA,
flavor='raw')
- self.hFindFile = rwin32.INVALID_HANDLE_VALUE
-
- def close(self):
- lltype.free(self.filedata, flavor='raw')
- if self.hFindFile != rwin32.INVALID_HANDLE_VALUE:
- win32traits.FindClose(self.hFindFile)
+ SCANDIRP = lltype.Ptr(lltype.Struct('SCANDIRP',
+ ('filedata', win32traits.WIN32_FIND_DATA),
+ ('hFindFile', rwin32.HANDLE),
+ ('first_time', lltype.Bool),
+ ))
+ NULL_DIRP = lltype.nullptr(SCANDIRP.TO)
# must only be called with unicode!
@@ -79,22 +76,23 @@
if len(path) == 0:
path = u'.'
if path[-1] not in (u'\\', u'/', u':'):
- path += u'\\'
- mask = path + u'*.*'
- dirp = DirP()
+ mask = path + u'\\*.*'
+ else:
+ mask = path + u'*.*'
+ dirp = lltype.malloc(SCANDIRP.TO, flavor='raw')
hFindFile = win32traits.FindFirstFile(mask, dirp.filedata)
if hFindFile == rwin32.INVALID_HANDLE_VALUE:
error = rwin32.GetLastError_saved()
- dirp.close()
+ lltype.free(dirp, flavor='raw')
raise WindowsError(error, "FindFirstFileW failed")
dirp.hFindFile = hFindFile
dirp.first_time = True
return dirp
def closedir(dirp):
- dirp.close()
-
- NULL_DIRP = None
+ if dirp.hFindFile != rwin32.INVALID_HANDLE_VALUE:
+ win32traits.FindClose(dirp.hFindFile)
+ lltype.free(dirp, flavor='raw')
def nextentry(dirp):
"""Read the next entry and returns an opaque object.
diff --git a/rpython/rlib/rwin32file.py b/rpython/rlib/rwin32file.py
--- a/rpython/rlib/rwin32file.py
+++ b/rpython/rlib/rwin32file.py
@@ -148,7 +148,7 @@
save_err=rffi.RFFI_SAVE_LASTERROR)
FindClose = external('FindClose',
[rwin32.HANDLE],
- rwin32.BOOL)
+ rwin32.BOOL, releasegil=False)
GetFileAttributes = external(
'GetFileAttributes' + suffix,
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit