pypy3.7 and pypy3.8:: Error: module '_winapi' has no attribute 'GetFileType'
During execution
pypy3.exe -m venv venv_dir\
getting error:
Error: module '_winapi' has no attribute 'GetFileType'
Issue was found in versions:
- pypy3.7-v7.3.3-win32.zip
- pypy3.7-v7.3.4-win64.zip
- pypy3.7-v7.3.5-win64.zip
- pypy-c-jit-latest-win64.zip Python 3.8.10 (cfd47581da0a, Jul 29 2021, 10:17:20) [PyPy 7.3.6-alpha0 with MSC v.1929 64 bit (AMD64)] on win32
Not found in version:
- pypy3.6-v7.3.3-win32.zip
Reason: \lib-python\3\subprocess.py
def _filter_handle_list(self, handle_list):
"""Filter out console handles that can't be used
in lpAttributeList["handle_list"] and make sure the list
isn't empty. This also removes duplicate handles."""
# An handle with it's lowest two bits set might be a special console
# handle that if passed in lpAttributeList["handle_list"], will
# cause it to fail.
return list({handle for handle in handle_list
if handle & 0x3 != 0x3
or _winapi.GetFileType(handle) !=
_winapi.FILE_TYPE_CHAR})
_filter_handle_list is used in subprocess._execute_child. New code was added first time in pypy3.7-v7.3.3-win32:
attribute_list = startupinfo.lpAttributeList
have_handle_list = bool(attribute_list and
"handle_list" in attribute_list and
attribute_list["handle_list"])
# If we were given an handle_list or need to create one
if have_handle_list or (use_std_handles and close_fds):
if attribute_list is None:
attribute_list = startupinfo.lpAttributeList = {}
handle_list = attribute_list["handle_list"] = \
list(attribute_list.get("handle_list", []))
if use_std_handles:
handle_list += [int(p2cread), int(c2pwrite), int(errwrite)]
handle_list[:] = self._filter_handle_list(handle_list)
if handle_list:
if not close_fds:
warnings.warn("startupinfo.lpAttributeList['handle_list'] "
"overriding close_fds", RuntimeWarning)
# When using the handle_list we always request to inherit
# handles but the only handles that will be inherited are
# the ones in the handle_list
close_fds = False
Recommended fix: Implement GetFileType() and FILE_TYPE_CHAR inside \lib_pypy_winapi.py