Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
disabled_tests += [
# Issue with Unix vs DOS newlines in the file vs from the server
'test_ssl.ThreadedTests.test_socketserver',
]
if hasattr(sys, 'pypy_version_info'):
disabled_tests += [
'test_subprocess.ProcessTestCase.test_failed_child_execute_fd_leak',
# Does not exist in the CPython test suite, tests for a specific bug
# in PyPy's forking. Only runs on linux and is specific to the PyPy
# implementation of subprocess (possibly explains the extra parameter to
# _execut_child)
]
import cffi # pylint:disable=import-error,useless-suppression
if cffi.__version_info__ < (1, 2, 0):
disabled_tests += [
'test_signal.InterProcessSignalTests.test_main',
# Fails to get the signal to the correct handler due to
# https://bitbucket.org/cffi/cffi/issue/152/handling-errors-from-signal-handlers-in
]
# Generic Python 3
if sys.version_info[0] == 3:
disabled_tests += [
# Triggers the crash reporter
'test_threading.SubinterpThreadingTests.test_daemon_threads_fatal_error',
# Relies on an implementation detail, Thread._tstate_lock
'test_threading.ThreadTests.test_tstate_lock',
[0.25, -0.25]])
data_mono = np.array([0, 1, 2, -2, -1], dtype='int16')
filename_stereo = 'tests/stereo.wav'
filename_mono = 'tests/mono.wav'
filename_raw = 'tests/mono.raw'
filename_new = 'tests/delme.please'
if sys.version_info >= (3, 6):
import pathlib
open_variants = 'name', 'fd', 'obj', 'pathlib'
else:
open_variants = 'name', 'fd', 'obj'
xfail_from_buffer = pytest.mark.xfail(cffi.__version_info__ < (0, 9),
reason="from_buffer() since CFFI 0.9")
def _file_existing(request, filename, fdarg, objarg=None):
if request.param == 'name':
return filename
if request.param == 'pathlib':
return pathlib.Path(filename)
elif request.param == 'fd':
fd = os.open(filename, fdarg)
def finalizer():
with pytest.raises(OSError):
os.close(fd)
request.addfinalizer(finalizer)
from .. import base, flags, _structs
from .. import _register_backend
from .._coreutils import get_resource_filename, logger_set_level_callbacks
from .._mappings import cstructfield2enum, enummap
logger = logging.getLogger("wgpu") # noqa
# wgpu-native version that we target/expect
__version__ = "0.5.2"
__commit_sha__ = "160be433dbec0fc7a27d25f2aba3423666ccfa10"
version_info = tuple(map(int, __version__.split(".")))
if cffi_version_info < (1, 10): # no-cover
raise ImportError(f"{__name__} needs cffi 1.10 or later.")
# %% Load the lib and integrate logging system
def _get_wgpu_h():
""" Read header file and strip some stuff that cffi would stumble on.
"""
lines = []
with open(get_resource_filename("wgpu.h")) as f:
for line in f.readlines():
if not line.startswith(
(
"#include ",
"#define WGPU_LOCAL",
try:
import cffi
except (ImportError):
raise FFIEngineError('Error importing cffi')
__all__ = [
'get_error',
'kernel32',
]
ffi = cffi.FFI()
if cffi.__version_info__ >= (0, 9):
ffi.set_unicode(True)
ffi.cdef("""
typedef long long LARGE_INTEGER;
BOOL QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount);
typedef struct _FILETIME {
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME;
void GetSystemTimeAsFileTime(FILETIME *lpSystemTimeAsFileTime);
""")
try:
kernel32 = ffi.dlopen('kernel32.dll')
from .._ffi import register_ffi
from .._types import str_cls
from ..errors import LibraryNotFoundError
import cffi
__all__ = [
'crypt32',
'get_error',
]
ffi = cffi.FFI()
if cffi.__version_info__ >= (0, 9):
ffi.set_unicode(True)
if sys.maxsize > 2 ** 32:
ffi.cdef("typedef uint64_t ULONG_PTR;")
else:
ffi.cdef("typedef unsigned long ULONG_PTR;")
ffi.cdef("""
typedef HANDLE HCERTSTORE;
typedef unsigned char *PBYTE;
typedef struct _CRYPTOAPI_BLOB {
DWORD cbData;
PBYTE pbData;
} CRYPTOAPI_BLOB;
typedef CRYPTOAPI_BLOB CRYPT_INTEGER_BLOB;
typedef CRYPTOAPI_BLOB CERT_NAME_BLOB;
from .._ffi import register_ffi
from .._types import str_cls
from ..errors import LibraryNotFoundError
import cffi
__all__ = [
'get_error',
'kernel32',
]
ffi = cffi.FFI()
if cffi.__version_info__ >= (0, 9):
ffi.set_unicode(True)
ffi.cdef("""
typedef long long LARGE_INTEGER;
BOOL QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount);
typedef struct _FILETIME {
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME;
void GetSystemTimeAsFileTime(FILETIME *lpSystemTimeAsFileTime);
""")
try:
kernel32 = ffi.dlopen('kernel32.dll')
try:
import cffi
except (ImportError):
raise FFIEngineError('Error importing cffi')
__all__ = [
'advapi32',
'get_error',
]
ffi = cffi.FFI()
if cffi.__version_info__ >= (0, 9):
ffi.set_unicode(True)
ffi.cdef("""
typedef HANDLE HCRYPTPROV;
typedef HANDLE HCRYPTKEY;
typedef HANDLE HCRYPTHASH;
typedef unsigned int ALG_ID;
typedef struct _CRYPTOAPI_BLOB {
DWORD cbData;
BYTE *pbData;
} CRYPT_INTEGER_BLOB, CRYPT_OBJID_BLOB, CRYPT_DER_BLOB, CRYPT_ATTR_BLOB;
typedef struct _CRYPT_ALGORITHM_IDENTIFIER {
LPSTR pszObjId;
CRYPT_OBJID_BLOB Parameters;
} CRYPT_ALGORITHM_IDENTIFIER;
from .._ffi import register_ffi
from .._types import str_cls
from ..errors import LibraryNotFoundError
import cffi
__all__ = [
'get_error',
'secur32',
]
ffi = cffi.FFI()
if cffi.__version_info__ >= (0, 9):
ffi.set_unicode(True)
if sys.maxsize > 2 ** 32:
ffi.cdef("typedef uint64_t ULONG_PTR;")
else:
ffi.cdef("typedef unsigned long ULONG_PTR;")
ffi.cdef("""
typedef HANDLE HCERTSTORE;
typedef unsigned int ALG_ID;
typedef WCHAR SEC_WCHAR;
typedef unsigned long SECURITY_STATUS;
typedef void *LUID;
typedef void *SEC_GET_KEY_FN;
typedef struct _SecHandle {
ULONG_PTR dwLower;
ULONG_PTR dwUpper;
try:
import cffi
except (ImportError):
raise FFIEngineError('Error importing cffi')
__all__ = [
'crypt32',
'get_error',
]
ffi = cffi.FFI()
if cffi.__version_info__ >= (0, 9):
ffi.set_unicode(True)
if sys.maxsize > 2 ** 32:
ffi.cdef("typedef uint64_t ULONG_PTR;")
else:
ffi.cdef("typedef unsigned long ULONG_PTR;")
ffi.cdef("""
typedef HANDLE HCERTSTORE;
typedef unsigned char *PBYTE;
typedef struct _CRYPTOAPI_BLOB {
DWORD cbData;
PBYTE pbData;
} CRYPTOAPI_BLOB;
typedef CRYPTOAPI_BLOB CRYPT_INTEGER_BLOB;
typedef CRYPTOAPI_BLOB CERT_NAME_BLOB;
from .._ffi import register_ffi
from .._types import str_cls
from ..errors import LibraryNotFoundError
import cffi
__all__ = [
'advapi32',
'get_error',
]
ffi = cffi.FFI()
if cffi.__version_info__ >= (0, 9):
ffi.set_unicode(True)
ffi.cdef("""
typedef HANDLE HCRYPTPROV;
typedef HANDLE HCRYPTKEY;
typedef HANDLE HCRYPTHASH;
typedef unsigned int ALG_ID;
typedef struct _CRYPTOAPI_BLOB {
DWORD cbData;
BYTE *pbData;
} CRYPT_INTEGER_BLOB, CRYPT_OBJID_BLOB, CRYPT_DER_BLOB, CRYPT_ATTR_BLOB;
typedef struct _CRYPT_ALGORITHM_IDENTIFIER {
LPSTR pszObjId;
CRYPT_OBJID_BLOB Parameters;
} CRYPT_ALGORITHM_IDENTIFIER;