[pypy-commit] pypy py3tests: Fix token module
rlamy
pypy.commits at gmail.com
Tue Apr 17 20:39:14 EDT 2018
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3tests
Changeset: r94366:b29602856871
Date: 2018-04-18 01:38 +0100
http://bitbucket.org/pypy/pypy/changeset/b29602856871/
Log: Fix token module
diff --git a/pypy/module/_cffi_backend/ctypefunc.py b/pypy/module/_cffi_backend/ctypefunc.py
--- a/pypy/module/_cffi_backend/ctypefunc.py
+++ b/pypy/module/_cffi_backend/ctypefunc.py
@@ -12,7 +12,8 @@
from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
from pypy.interpreter.error import OperationError, oefmt
-from pypy.module import _cffi_backend
+from pypy.module._cffi_backend.moduledef import (
+ FFI_DEFAULT_ABI, has_stdcall, FFI_STDCALL)
from pypy.module._cffi_backend import ctypearray, cdataobj, cerrno
from pypy.module._cffi_backend.ctypeobj import W_CType
from pypy.module._cffi_backend.ctypeptr import W_CTypePtrBase, W_CTypePointer
@@ -30,8 +31,7 @@
cif_descr = lltype.nullptr(CIF_DESCRIPTION)
- def __init__(self, space, fargs, fresult, ellipsis,
- abi=_cffi_backend.FFI_DEFAULT_ABI):
+ def __init__(self, space, fargs, fresult, ellipsis, abi=FFI_DEFAULT_ABI):
assert isinstance(ellipsis, bool)
extra, xpos = self._compute_extra_text(fargs, fresult, ellipsis, abi)
size = rffi.sizeof(rffi.VOIDP)
@@ -101,7 +101,7 @@
from pypy.module._cffi_backend import newtype
argnames = ['(*)(']
xpos = 2
- if _cffi_backend.has_stdcall and abi == _cffi_backend.FFI_STDCALL:
+ if has_stdcall and abi == FFI_STDCALL:
argnames[0] = '(__stdcall *)('
xpos += len('__stdcall ')
for i, farg in enumerate(fargs):
diff --git a/pypy/module/_cffi_backend/ffi_obj.py b/pypy/module/_cffi_backend/ffi_obj.py
--- a/pypy/module/_cffi_backend/ffi_obj.py
+++ b/pypy/module/_cffi_backend/ffi_obj.py
@@ -6,7 +6,8 @@
from rpython.rlib import jit, rgc
from rpython.rtyper.lltypesystem import lltype, rffi
-from pypy.module._cffi_backend import get_dict_rtld_constants
+from pypy.module._cffi_backend.moduledef import (
+ get_dict_rtld_constants)
from pypy.module._cffi_backend import parse_c_type, realize_c_type
from pypy.module._cffi_backend import newtype, cerrno, ccallback, ctypearray
from pypy.module._cffi_backend import ctypestruct, ctypeptr, handle
diff --git a/pypy/module/_cffi_backend/moduledef.py b/pypy/module/_cffi_backend/moduledef.py
--- a/pypy/module/_cffi_backend/moduledef.py
+++ b/pypy/module/_cffi_backend/moduledef.py
@@ -11,6 +11,7 @@
has_stdcall = True
except AttributeError:
has_stdcall = False
+ FFI_STDCALL = None
class Module(MixedModule):
diff --git a/pypy/module/_cffi_backend/newtype.py b/pypy/module/_cffi_backend/newtype.py
--- a/pypy/module/_cffi_backend/newtype.py
+++ b/pypy/module/_cffi_backend/newtype.py
@@ -8,7 +8,7 @@
from rpython.rtyper.lltypesystem import lltype, rffi
from rpython.rtyper.tool import rffi_platform
-from pypy.module import _cffi_backend
+from pypy.module._cffi_backend.moduledef import FFI_DEFAULT_ABI
from pypy.module._cffi_backend import (ctypeobj, ctypeprim, ctypeptr,
ctypearray, ctypestruct, ctypevoid, ctypeenum)
@@ -633,7 +633,7 @@
@unwrap_spec(w_fresult=ctypeobj.W_CType, ellipsis=int, abi=int)
def new_function_type(space, w_fargs, w_fresult, ellipsis=0,
- abi=_cffi_backend.FFI_DEFAULT_ABI):
+ abi=FFI_DEFAULT_ABI):
fargs = []
for w_farg in space.fixedview(w_fargs):
if not isinstance(w_farg, ctypeobj.W_CType):
diff --git a/pypy/module/_cffi_backend/test/test_c.py b/pypy/module/_cffi_backend/test/test_c.py
--- a/pypy/module/_cffi_backend/test/test_c.py
+++ b/pypy/module/_cffi_backend/test/test_c.py
@@ -17,12 +17,9 @@
"""
import py, sys, ctypes
-if sys.version_info < (2, 6):
- py.test.skip("requires the b'' literal syntax")
-
from rpython.tool.udir import udir
from pypy.interpreter import gateway
-from pypy.module._cffi_backend import Module
+from pypy.module._cffi_backend.moduledef import Module
from pypy.module._cffi_backend.newtype import _clean_cache, UniqueCache
from rpython.translator import cdir
from rpython.translator.platform import host
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -34,7 +34,6 @@
from rpython.rlib.rposix import FdValidator
from rpython.rlib.unroll import unrolling_iterable
from rpython.rlib.objectmodel import specialize
-from pypy.module import exceptions
from pypy.module.exceptions import interp_exceptions
from rpython.tool.sourcetools import func_with_new_name
from rpython.rtyper.lltypesystem.lloperation import llop
@@ -686,8 +685,9 @@
# PyExc_AttributeError, PyExc_OverflowError, PyExc_ImportError,
# PyExc_NameError, PyExc_MemoryError, PyExc_RuntimeError,
# PyExc_UnicodeEncodeError, PyExc_UnicodeDecodeError, ...
+ from pypy.module.exceptions.moduledef import Module
global all_exceptions
- all_exceptions = list(exceptions.Module.interpleveldefs)
+ all_exceptions = list(Module.interpleveldefs)
for exc_name in all_exceptions:
if exc_name in ('EnvironmentError', 'IOError', 'WindowsError'):
# FIXME: aliases of OSError cause a clash of names via
diff --git a/pypy/module/cpyext/unicodeobject.py b/pypy/module/cpyext/unicodeobject.py
--- a/pypy/module/cpyext/unicodeobject.py
+++ b/pypy/module/cpyext/unicodeobject.py
@@ -3,7 +3,7 @@
from rpython.rlib.runicode import unicode_encode_latin_1, unicode_encode_utf_16_helper
from rpython.rlib.rarithmetic import widen
-from pypy.module.unicodedata import unicodedb
+from pypy.objspace.std.unicodeobject import unicodedb
from pypy.module.cpyext.api import (
CANNOT_FAIL, Py_ssize_t, build_type_checkers, cpython_api,
bootstrap_function, CONST_STRING,
diff --git a/pypy/module/micronumpy/test/conftest.py b/pypy/module/micronumpy/test/conftest.py
--- a/pypy/module/micronumpy/test/conftest.py
+++ b/pypy/module/micronumpy/test/conftest.py
@@ -1,5 +1,2 @@
-import py
-
-def pytest_collect_directory(path, parent):
- py.test.skip("micronumpy tests skipped for now on py3.5")
-pytest_collect_file = pytest_collect_directory
+def pytest_ignore_collect():
+ return True
diff --git a/pypy/module/token/interp_token.py b/pypy/module/token/interp_token.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/token/interp_token.py
@@ -0,0 +1,14 @@
+from pypy.interpreter.gateway import unwrap_spec
+from pypy.interpreter.pyparser import pygram
+
+ at unwrap_spec(tok=int)
+def isterminal(space, tok):
+ return space.newbool(tok < 256)
+
+ at unwrap_spec(tok=int)
+def isnonterminal(space, tok):
+ return space.newbool(tok >= 256)
+
+ at unwrap_spec(tok=int)
+def iseof(space, tok):
+ return space.newbool(tok == pygram.tokens.ENDMARKER)
diff --git a/pypy/module/token/moduledef.py b/pypy/module/token/moduledef.py
--- a/pypy/module/token/moduledef.py
+++ b/pypy/module/token/moduledef.py
@@ -1,6 +1,5 @@
from pypy.interpreter.mixedmodule import MixedModule
-from pypy.interpreter.gateway import unwrap_spec
-from pypy.interpreter.pyparser import pytoken, pygram
+from pypy.interpreter.pyparser import pytoken
class Module(MixedModule):
@@ -8,9 +7,9 @@
appleveldefs = {}
interpleveldefs = {
"NT_OFFSET" : "space.newint(256)",
- "ISTERMINAL" : "__init__.isterminal",
- "ISNONTERMINAL" : "__init__.isnonterminal",
- "ISEOF" : "__init__.iseof"
+ "ISTERMINAL" : "interp_token.isterminal",
+ "ISNONTERMINAL" : "interp_token.isnonterminal",
+ "ISEOF" : "interp_token.iseof"
}
@@ -30,16 +29,3 @@
Module.interpleveldefs["__all__"] = "space.wrap(%r)" % (all_names,)
_init_tokens()
-
-
- at unwrap_spec(tok=int)
-def isterminal(space, tok):
- return space.newbool(tok < 256)
-
- at unwrap_spec(tok=int)
-def isnonterminal(space, tok):
- return space.newbool(tok >= 256)
-
- at unwrap_spec(tok=int)
-def iseof(space, tok):
- return space.newbool(tok == pygram.tokens.ENDMARKER)
More information about the pypy-commit
mailing list