diff options
Diffstat (limited to 'lib_pypy')
-rw-r--r-- | lib_pypy/__init__.py | 2 | ||||
-rw-r--r-- | lib_pypy/_cffi_ssl/_stdssl/__init__.py | 2 | ||||
-rw-r--r-- | lib_pypy/_crypt/__init__.py | 2 | ||||
-rw-r--r-- | lib_pypy/_ctypes_test.py | 2 | ||||
-rw-r--r-- | lib_pypy/_curses.py | 2 | ||||
-rw-r--r-- | lib_pypy/_dbm.py | 2 | ||||
-rw-r--r-- | lib_pypy/_hashlib/__init__.py | 5 | ||||
-rw-r--r-- | lib_pypy/_overlapped.py | 2 | ||||
-rw-r--r-- | lib_pypy/_scproxy.py | 2 | ||||
-rw-r--r-- | lib_pypy/_sysconfigdata.py | 17 | ||||
-rw-r--r-- | lib_pypy/_testcapimodule.c | 10 | ||||
-rw-r--r-- | lib_pypy/_testmultiphase.c.h | 101 | ||||
-rw-r--r-- | lib_pypy/_testmultiphase.py | 4 | ||||
-rw-r--r-- | lib_pypy/_winapi.py | 2 | ||||
-rw-r--r-- | lib_pypy/cffi.dist-info/METADATA | 1 | ||||
-rw-r--r-- | lib_pypy/msvcrt.py | 2 | ||||
-rw-r--r-- | lib_pypy/pyrepl/_minimal_curses.py | 2 | ||||
-rw-r--r-- | lib_pypy/readline.py | 4 | ||||
-rw-r--r-- | lib_pypy/syslog.py | 2 |
19 files changed, 139 insertions, 27 deletions
diff --git a/lib_pypy/__init__.py b/lib_pypy/__init__.py index 5747a91294..dad4526e1f 100644 --- a/lib_pypy/__init__.py +++ b/lib_pypy/__init__.py @@ -1,4 +1,4 @@ # This __init__.py shows up in PyPy's app-level standard library. # Let's try to prevent that confusion... if __name__ != 'lib_pypy': - raise ImportError('__init__') + raise ModuleNotFoundError('__init__', name='__init__') diff --git a/lib_pypy/_cffi_ssl/_stdssl/__init__.py b/lib_pypy/_cffi_ssl/_stdssl/__init__.py index b87ff68038..bbf721c649 100644 --- a/lib_pypy/_cffi_ssl/_stdssl/__init__.py +++ b/lib_pypy/_cffi_ssl/_stdssl/__init__.py @@ -13,7 +13,7 @@ except ImportError as e: "If you have a compiler installed, you can try to rebuild it by running:\n" + \ "cd %s\n" % os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + \ "%s _ssl_build.py\n" % sys.executable - raise ImportError(str(e) + msg) + raise ModuleNotFoundError(str(e) + msg, name='_cffi_ssl') from _cffi_ssl._stdssl.certificate import (_test_decode_cert, _decode_certificate, _certificate_to_der) diff --git a/lib_pypy/_crypt/__init__.py b/lib_pypy/_crypt/__init__.py index d81ea545ff..4e295f89eb 100644 --- a/lib_pypy/_crypt/__init__.py +++ b/lib_pypy/_crypt/__init__.py @@ -19,7 +19,7 @@ ffi.cdef('char *crypt(char *word, char *salt);') try: lib = ffi.dlopen('crypt') except OSError: - raise ImportError('crypt not available') + raise ModuleNotFoundError('crypt not available', name='crypt') @builtinify diff --git a/lib_pypy/_ctypes_test.py b/lib_pypy/_ctypes_test.py index 1889a21765..75dadd4d56 100644 --- a/lib_pypy/_ctypes_test.py +++ b/lib_pypy/_ctypes_test.py @@ -4,7 +4,7 @@ import os try: import cpyext except ImportError: - raise ImportError("No module named '_ctypes_test'") + raise ModuleNotFoundError("No module named '_ctypes_test'", name='_ctypes_test') try: import _ctypes _ctypes.PyObj_FromPtr = None diff --git a/lib_pypy/_curses.py b/lib_pypy/_curses.py index 64fea97393..1fc079673b 100644 --- a/lib_pypy/_curses.py +++ b/lib_pypy/_curses.py @@ -3,7 +3,7 @@ import sys if sys.platform == 'win32': #This module does not exist in windows - raise ImportError('No module named _curses') + raise ModuleNotFoundError('No module named _curses', name='_curses') import locale from functools import wraps diff --git a/lib_pypy/_dbm.py b/lib_pypy/_dbm.py index fab08524cc..c64f541b40 100644 --- a/lib_pypy/_dbm.py +++ b/lib_pypy/_dbm.py @@ -152,7 +152,7 @@ if sys.platform != 'darwin': if libpath: break else: - raise ImportError("Cannot find dbm library") + raise ModuleNotFoundError("Cannot find dbm library", name='_dbm') lib = CDLL(libpath) # Linux _platform = 'bdb' else: diff --git a/lib_pypy/_hashlib/__init__.py b/lib_pypy/_hashlib/__init__.py index db8b13b41f..3f2c03b503 100644 --- a/lib_pypy/_hashlib/__init__.py +++ b/lib_pypy/_hashlib/__init__.py @@ -64,6 +64,11 @@ class HASH(object): return "<%s HASH object at 0x%s>" % (self.name, id(self)) def update(self, string): + if isinstance(string, str): + raise TypeError("Unicode-objects must be encoded before hashing") + elif isinstance(string, memoryview): + # issue 2756: ffi.from_buffer() cannot handle memoryviews + string = string.tobytes() buf = ffi.from_buffer(string) with self.lock: # XXX try to not release the GIL for small requests diff --git a/lib_pypy/_overlapped.py b/lib_pypy/_overlapped.py index a5fdf83767..56397a127e 100644 --- a/lib_pypy/_overlapped.py +++ b/lib_pypy/_overlapped.py @@ -10,7 +10,7 @@ import _winapi from _winapi import _Z, RaiseFromWindowsErr if sys.platform != 'win32': - raise ImportError("The '_overlapped' module is only available on Windows") + raise ModuleNotFoundError("The '_overlapped' module is only available on Windows", name='_overlapped') # Declare external Win32 functions diff --git a/lib_pypy/_scproxy.py b/lib_pypy/_scproxy.py index 1f4299ffff..64478f0d49 100644 --- a/lib_pypy/_scproxy.py +++ b/lib_pypy/_scproxy.py @@ -4,7 +4,7 @@ the SystemConfiguration framework. """ import sys if sys.platform != 'darwin': - raise ImportError('Requires Mac OS X') + raise ModuleNotFoundError('Requires Mac OS X', name='_scproxy') from ctypes import c_int32, c_int64, c_void_p, c_char_p, c_int, cdll from ctypes import pointer, create_string_buffer diff --git a/lib_pypy/_sysconfigdata.py b/lib_pypy/_sysconfigdata.py index 33fbfd6b6d..8deb672ef1 100644 --- a/lib_pypy/_sysconfigdata.py +++ b/lib_pypy/_sysconfigdata.py @@ -52,6 +52,23 @@ else: build_time_vars['LDLIBRARY'] = 'libpypy3-c.so' build_time_vars['INCLUDEPY'] = os.path.join(mybase, 'include', 'pypy' + pydot) build_time_vars['LIBDIR'] = os.path.join(mybase, 'bin') + # try paths relative to sys.base_prefix first + tzpaths = [ + os.path.join(mybase, 'share', 'zoneinfo'), + os.path.join(mybase, 'lib', 'zoneinfo'), + os.path.join(mybase, 'share', 'lib', 'zoneinfo'), + os.path.join(mybase, '..', 'etc', 'zoneinfo'), + ] + # add absolute system paths if sys.base_prefix != "/usr" + # (then we'd be adding duplicates) + if mybase != '/usr': + tzpaths.extend([ + '/usr/share/zoneinfo', + '/usr/lib/zoneinfo', + '/usr/share/lib/zoneinfo', + '/etc/zoneinfo', + ]) + build_time_vars['TZPATH'] = ':'.join(tzpaths) if find_executable("gcc"): build_time_vars.update({ diff --git a/lib_pypy/_testcapimodule.c b/lib_pypy/_testcapimodule.c index 88e8a6bc0f..fca51fe409 100644 --- a/lib_pypy/_testcapimodule.c +++ b/lib_pypy/_testcapimodule.c @@ -2724,7 +2724,6 @@ test_PyDateTime_DELTA_GET(PyObject *self, PyObject *obj) return Py_BuildValue("(lll)", days, seconds, microseconds); } -#ifndef PYPY_VERSION /* test_thread_state spawns a thread of its own, and that thread releases * `thread_done` when it's finished. The driver code has to know when the * thread finishes, because the thread uses a PyObject (the callable) that @@ -2805,9 +2804,7 @@ test_thread_state(PyObject *self, PyObject *args) return NULL; Py_RETURN_NONE; } -#endif -#ifndef PYPY_VERSION /* test Py_AddPendingCalls using threads */ static int _pending_callback(void *arg) { @@ -2843,7 +2840,6 @@ pending_threadfunc(PyObject *self, PyObject *arg) } Py_RETURN_TRUE; } -#endif /* PYPY_VERSION */ /* Some tests of PyUnicode_FromFormat(). This needs more tests. */ static PyObject * @@ -2852,10 +2848,6 @@ test_string_from_format(PyObject *self, PyObject *Py_UNUSED(ignored)) PyObject *result; char *msg; -#ifdef PYPY_VERSION -#define _PyUnicode_EqualToASCIIString(a, b) (PyUnicode_CompareWithASCIIString(a, b) == 0) -#endif - #define CHECK_1_FORMAT(FORMAT, TYPE) \ result = PyUnicode_FromFormat(FORMAT, (TYPE)1); \ if (result == NULL) \ @@ -5541,10 +5533,8 @@ static PyMethodDef TestMethods[] = { {"unicode_encodedecimal", unicode_encodedecimal, METH_VARARGS}, {"unicode_transformdecimaltoascii", unicode_transformdecimaltoascii, METH_VARARGS}, {"unicode_legacy_string", unicode_legacy_string, METH_VARARGS}, -#ifndef PYPY_VERSION {"_test_thread_state", test_thread_state, METH_VARARGS}, {"_pending_threadfunc", pending_threadfunc, METH_VARARGS}, -#endif // ifndef PYPY_VERSION #ifdef HAVE_GETTIMEOFDAY {"profile_int", profile_int, METH_NOARGS}, #endif diff --git a/lib_pypy/_testmultiphase.c.h b/lib_pypy/_testmultiphase.c.h new file mode 100644 index 0000000000..0d38c230f7 --- /dev/null +++ b/lib_pypy/_testmultiphase.c.h @@ -0,0 +1,101 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(_testmultiphase_StateAccessType_get_defining_module__doc__, +"get_defining_module($self, /)\n" +"--\n" +"\n" +"Return the module of the defining class."); + +#define _TESTMULTIPHASE_STATEACCESSTYPE_GET_DEFINING_MODULE_METHODDEF \ + {"get_defining_module", (PyCFunction)(void(*)(void))_testmultiphase_StateAccessType_get_defining_module, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_get_defining_module__doc__}, + +static PyObject * +_testmultiphase_StateAccessType_get_defining_module_impl(StateAccessTypeObject *self, + PyTypeObject *cls); + +static PyObject * +_testmultiphase_StateAccessType_get_defining_module(StateAccessTypeObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = { NULL}; + static _PyArg_Parser _parser = {":get_defining_module", _keywords, 0}; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser + )) { + goto exit; + } + return_value = _testmultiphase_StateAccessType_get_defining_module_impl(self, cls); + +exit: + return return_value; +} + +PyDoc_STRVAR(_testmultiphase_StateAccessType_increment_count_clinic__doc__, +"increment_count_clinic($self, /, n=1, *, twice=False)\n" +"--\n" +"\n" +"Add \'n\' from the module-state counter.\n" +"\n" +"Pass \'twice\' to double that amount.\n" +"\n" +"This tests Argument Clinic support for defining_class."); + +#define _TESTMULTIPHASE_STATEACCESSTYPE_INCREMENT_COUNT_CLINIC_METHODDEF \ + {"increment_count_clinic", (PyCFunction)(void(*)(void))_testmultiphase_StateAccessType_increment_count_clinic, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_increment_count_clinic__doc__}, + +static PyObject * +_testmultiphase_StateAccessType_increment_count_clinic_impl(StateAccessTypeObject *self, + PyTypeObject *cls, + int n, int twice); + +static PyObject * +_testmultiphase_StateAccessType_increment_count_clinic(StateAccessTypeObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"n", "twice", NULL}; + static _PyArg_Parser _parser = {"|i$p:increment_count_clinic", _keywords, 0}; + int n = 1; + int twice = 0; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &n, &twice)) { + goto exit; + } + return_value = _testmultiphase_StateAccessType_increment_count_clinic_impl(self, cls, n, twice); + +exit: + return return_value; +} + +PyDoc_STRVAR(_testmultiphase_StateAccessType_get_count__doc__, +"get_count($self, /)\n" +"--\n" +"\n" +"Return the value of the module-state counter."); + +#define _TESTMULTIPHASE_STATEACCESSTYPE_GET_COUNT_METHODDEF \ + {"get_count", (PyCFunction)(void(*)(void))_testmultiphase_StateAccessType_get_count, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_get_count__doc__}, + +static PyObject * +_testmultiphase_StateAccessType_get_count_impl(StateAccessTypeObject *self, + PyTypeObject *cls); + +static PyObject * +_testmultiphase_StateAccessType_get_count(StateAccessTypeObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = { NULL}; + static _PyArg_Parser _parser = {":get_count", _keywords, 0}; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser + )) { + goto exit; + } + return_value = _testmultiphase_StateAccessType_get_count_impl(self, cls); + +exit: + return return_value; +} +/*[clinic end generated code: output=39eea487e94e7f5d input=a9049054013a1b77]*/ diff --git a/lib_pypy/_testmultiphase.py b/lib_pypy/_testmultiphase.py index e10e9996f5..d24cdea434 100644 --- a/lib_pypy/_testmultiphase.py +++ b/lib_pypy/_testmultiphase.py @@ -4,13 +4,13 @@ import os try: import cpyext except ImportError: - raise ImportError("No module named '_testmultiphase'") + raise ModuleNotFoundError("No module named '_testmultiphase'", name='_testmultiphase') import _pypy_testcapi cfile = '_testmultiphase.c' thisdir = os.path.dirname(__file__) output_dir = _pypy_testcapi.get_hashed_dir(os.path.join(thisdir, cfile)) try: - fp, filename, description = imp.find_module('_test_multiphase', path=[output_dir]) + fp, filename, description = imp.find_module('_testmultiphase', path=[output_dir]) with fp: imp.load_module('_testmultiphase', fp, filename, description) except ImportError: diff --git a/lib_pypy/_winapi.py b/lib_pypy/_winapi.py index ef31b9c161..0285801e5c 100644 --- a/lib_pypy/_winapi.py +++ b/lib_pypy/_winapi.py @@ -7,7 +7,7 @@ modules on Windows. import sys if sys.platform != 'win32': - raise ImportError("The '_winapi' module is only available on Windows") + raise ImportError("The '_winapi' module is only available on Windows", name="_winapi") # Declare external Win32 functions diff --git a/lib_pypy/cffi.dist-info/METADATA b/lib_pypy/cffi.dist-info/METADATA index 723deb6630..1e9927006d 100644 --- a/lib_pypy/cffi.dist-info/METADATA +++ b/lib_pypy/cffi.dist-info/METADATA @@ -20,7 +20,6 @@ Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: License :: OSI Approved :: MIT License License-File: LICENSE -Requires-Dist: pycparser CFFI diff --git a/lib_pypy/msvcrt.py b/lib_pypy/msvcrt.py index 5437b0e156..e567081dc5 100644 --- a/lib_pypy/msvcrt.py +++ b/lib_pypy/msvcrt.py @@ -11,7 +11,7 @@ still useful routines. import sys if sys.platform != 'win32': - raise ModuleNotFoundError("The 'msvcrt' module is only available on Windows") + raise ModuleNotFoundError("The 'msvcrt' module is only available on Windows", name="msvcrt") import _rawffi if sys.maxsize > 2 ** 31: diff --git a/lib_pypy/pyrepl/_minimal_curses.py b/lib_pypy/pyrepl/_minimal_curses.py index bc0dd4231f..fc51679815 100644 --- a/lib_pypy/pyrepl/_minimal_curses.py +++ b/lib_pypy/pyrepl/_minimal_curses.py @@ -22,7 +22,7 @@ def _find_clib(): path = ctypes.util.find_library(lib) if path: return path - raise ImportError("curses library not found") + raise ModuleNotFoundError("curses library not found", name="_minimal_curses") _clibpath = _find_clib() clib = ctypes.cdll.LoadLibrary(_clibpath) diff --git a/lib_pypy/readline.py b/lib_pypy/readline.py index e08747acf4..34b326518f 100644 --- a/lib_pypy/readline.py +++ b/lib_pypy/readline.py @@ -11,6 +11,6 @@ try: except ImportError: import sys if sys.platform == 'win32': - raise ImportError("the 'readline' module is not available on Windows" - " (on either PyPy or CPython)") + raise ModuleNotFoundError("the 'readline' module is not available on Windows" + " (on either PyPy or CPython)", name="readline") raise diff --git a/lib_pypy/syslog.py b/lib_pypy/syslog.py index e9b25342e7..6a778596e6 100644 --- a/lib_pypy/syslog.py +++ b/lib_pypy/syslog.py @@ -8,7 +8,7 @@ syslog facility. import sys if sys.platform == 'win32': - raise ImportError("No syslog on Windows") + raise ModuleNotFoundError("No syslog on Windows", name="syslog") try: from __pypy__ import builtinify except ImportError: builtinify = lambda f: f |