diff options
author | Carl Friedrich Bolz <cfbolz@gmx.de> | 2017-08-03 19:29:44 +0200 |
---|---|---|
committer | Carl Friedrich Bolz <cfbolz@gmx.de> | 2017-08-03 19:29:44 +0200 |
commit | 501116e88fdae121585ca002bc5f89e3d6877dff (patch) | |
tree | 42fab9371e5822924a2c4392232fa13d973f5cf5 /pypy | |
parent | remove the withcelldict option (translating without withcelldict is really not (diff) | |
download | pypy-501116e88fdae121585ca002bc5f89e3d6877dff.tar.gz pypy-501116e88fdae121585ca002bc5f89e3d6877dff.tar.bz2 pypy-501116e88fdae121585ca002bc5f89e3d6877dff.zip |
remove some more NOT_RPYTHON and replace them with the decorator
Diffstat (limited to 'pypy')
-rw-r--r-- | pypy/interpreter/argument.py | 3 | ||||
-rw-r--r-- | pypy/interpreter/error.py | 12 | ||||
-rw-r--r-- | pypy/interpreter/executioncontext.py | 5 | ||||
-rw-r--r-- | pypy/interpreter/gateway.py | 26 | ||||
-rw-r--r-- | pypy/interpreter/miscutils.py | 4 | ||||
-rw-r--r-- | pypy/interpreter/mixedmodule.py | 16 | ||||
-rw-r--r-- | pypy/interpreter/module.py | 8 | ||||
-rw-r--r-- | pypy/interpreter/pyframe.py | 4 | ||||
-rw-r--r-- | pypy/interpreter/pyopcode.py | 6 | ||||
-rw-r--r-- | pypy/interpreter/typedef.py | 14 | ||||
-rw-r--r-- | pypy/module/_codecs/__init__.py | 4 | ||||
-rw-r--r-- | pypy/module/_codecs/interp_codecs.py | 4 | ||||
-rw-r--r-- | pypy/module/posix/interp_posix.py | 4 | ||||
-rw-r--r-- | pypy/objspace/std/objspace.py | 2 | ||||
-rw-r--r-- | pypy/objspace/std/typeobject.py | 10 |
15 files changed, 72 insertions, 50 deletions
diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py index 20cd1cdd3a..ce725a77bd 100644 --- a/pypy/interpreter/argument.py +++ b/pypy/interpreter/argument.py @@ -2,6 +2,7 @@ Arguments objects. """ from rpython.rlib.debug import make_sure_not_resized +from rpython.rlib.objectmodel import not_rpython from rpython.rlib import jit from pypy.interpreter.error import OperationError, oefmt @@ -46,8 +47,8 @@ class Arguments(object): # behaviour but produces better error messages self.methodcall = methodcall + @not_rpython def __repr__(self): - """ NOT_RPYTHON """ name = self.__class__.__name__ if not self.keywords: return '%s(%s)' % (name, self.arguments_w,) diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py index bc60fabb21..d0b85fa496 100644 --- a/pypy/interpreter/error.py +++ b/pypy/interpreter/error.py @@ -7,6 +7,7 @@ from errno import EINTR from rpython.rlib import jit from rpython.rlib.objectmodel import we_are_translated, specialize +from rpython.rlib.objectmodel import not_rpython from rpython.rlib import rstack, rstackovf from pypy.interpreter import debug @@ -57,8 +58,9 @@ class OperationError(Exception): self.match(space, space.w_KeyboardInterrupt)) # note: an extra case is added in OpErrFmtNoArgs + @not_rpython def __str__(self): - "NOT_RPYTHON: Convenience for tracebacks." + "Convenience for tracebacks." s = self._w_value space = getattr(self.w_type, 'space', None) if space is not None: @@ -107,15 +109,16 @@ class OperationError(Exception): if RECORD_INTERPLEVEL_TRACEBACK: self.debug_excs.append(sys.exc_info()) + @not_rpython def print_application_traceback(self, space, file=None): - "NOT_RPYTHON: Dump a standard application-level traceback." + "Dump a standard application-level traceback." if file is None: file = sys.stderr self.print_app_tb_only(file) print >> file, self.errorstr(space) + @not_rpython def print_app_tb_only(self, file): - "NOT_RPYTHON" tb = self._application_traceback if tb: import linecache @@ -142,8 +145,9 @@ class OperationError(Exception): print >> file, l tb = tb.next + @not_rpython def print_detailed_traceback(self, space=None, file=None): - """NOT_RPYTHON: Dump a nice detailed interpreter- and + """Dump a nice detailed interpreter- and application-level traceback, useful to debug the interpreter.""" if file is None: file = sys.stderr diff --git a/pypy/interpreter/executioncontext.py b/pypy/interpreter/executioncontext.py index 9ab99654dc..d74099de6e 100644 --- a/pypy/interpreter/executioncontext.py +++ b/pypy/interpreter/executioncontext.py @@ -1,7 +1,7 @@ import sys from pypy.interpreter.error import OperationError, get_cleared_operation_error from rpython.rlib.unroll import unrolling_iterable -from rpython.rlib.objectmodel import specialize +from rpython.rlib.objectmodel import specialize, not_rpython from rpython.rlib import jit, rgc, objectmodel TICK_COUNTER_STEP = 100 @@ -423,8 +423,9 @@ class AbstractActionFlag(object): # to run at the next possible bytecode self.reset_ticker(-1) + @not_rpython def register_periodic_action(self, action, use_bytecode_counter): - """NOT_RPYTHON: + """ Register the PeriodicAsyncAction action to be called whenever the tick counter becomes smaller than 0. If 'use_bytecode_counter' is True, make sure that we decrease the tick counter at every bytecode. diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py index 7e6f8bfba9..a543d94d26 100644 --- a/pypy/interpreter/gateway.py +++ b/pypy/interpreter/gateway.py @@ -23,7 +23,7 @@ from pypy.interpreter.baseobjspace import (W_Root, ObjSpace, SpaceCache, DescrMismatch) from pypy.interpreter.error import OperationError, oefmt from pypy.interpreter.function import ClassMethod, FunctionWithFixedCode -from rpython.rlib.objectmodel import we_are_translated +from rpython.rlib.objectmodel import we_are_translated, not_rpython from rpython.rlib.rarithmetic import r_longlong, r_int, r_ulonglong, r_uint from rpython.tool.sourcetools import func_with_new_name, compile2 @@ -64,8 +64,8 @@ class Unwrapper(object): def _freeze_(self): return True + @not_rpython def unwrap(self, space, w_value): - """NOT_RPYTHON""" raise NotImplementedError @@ -380,8 +380,8 @@ class UnwrapSpec_EmitRun(UnwrapSpecEmit): class BuiltinActivation(object): _immutable_ = True + @not_rpython def __init__(self, behavior): - """NOT_RPYTHON""" self.behavior = behavior def _run(self, space, scope_w): @@ -621,9 +621,9 @@ class BuiltinCode(Code): # When a BuiltinCode is stored in a Function object, # you get the functionality of CPython's built-in function type. + @not_rpython def __init__(self, func, unwrap_spec=None, self_type=None, descrmismatch=None, doc=None): - "NOT_RPYTHON" # 'implfunc' is the interpreter-level function. # Note that this uses a lot of (construction-time) introspection. Code.__init__(self, func.__name__) @@ -969,10 +969,10 @@ class interp2app(W_Root): instancecache = {} + @not_rpython def __new__(cls, f, app_name=None, unwrap_spec=None, descrmismatch=None, as_classmethod=False, doc=None): - "NOT_RPYTHON" # f must be a function whose name does NOT start with 'app_' self_type = None if hasattr(f, 'im_func'): @@ -1013,8 +1013,8 @@ class interp2app(W_Root): self._staticdefs = zip(argnames[-len(defaults):], defaults) return self + @not_rpython def _getdefaults(self, space): - "NOT_RPYTHON" defs_w = [] for name, defaultval in self._staticdefs: if name.startswith('w_'): @@ -1070,8 +1070,8 @@ class interp2app(W_Root): class GatewayCache(SpaceCache): + @not_rpython def build(cache, gateway): - "NOT_RPYTHON" space = cache.space defs = gateway._getdefaults(space) # needs to be implemented by subclass code = gateway._code @@ -1141,8 +1141,8 @@ class ApplevelClass: w_globals = self.getwdict(space) return space.getitem(w_globals, space.newtext(name)) + @not_rpython def interphook(self, name): - "NOT_RPYTHON" def appcaller(space, *args_w): if not isinstance(space, ObjSpace): raise TypeError("first argument must be a space instance.") @@ -1179,15 +1179,16 @@ class ApplevelCache(SpaceCache): """NOT_RPYTHON The cache mapping each applevel instance to its lazily built w_dict""" + @not_rpython def build(self, app): - "NOT_RPYTHON. Called indirectly by Applevel.getwdict()." + "Called indirectly by Applevel.getwdict()." return build_applevel_dict(app, self.space) # __________ pure applevel version __________ +@not_rpython def build_applevel_dict(self, space): - "NOT_RPYTHON" w_glob = space.newdict(module=True) space.setitem(w_glob, space.newtext('__name__'), space.newtext(self.modname)) space.exec_(self.source, w_glob, w_glob, @@ -1198,8 +1199,9 @@ def build_applevel_dict(self, space): # ____________________________________________________________ +@not_rpython def appdef(source, applevel=ApplevelClass, filename=None): - """ NOT_RPYTHON: build an app-level helper function, like for example: + """ build an app-level helper function, like for example: myfunc = appdef('''myfunc(x, y): return x+y ''') @@ -1245,6 +1247,6 @@ class applevel_temp(ApplevelClass): # app2interp_temp is used for testing mainly +@not_rpython def app2interp_temp(func, applevel_temp=applevel_temp, filename=None): - """ NOT_RPYTHON """ return appdef(func, applevel_temp, filename=filename) diff --git a/pypy/interpreter/miscutils.py b/pypy/interpreter/miscutils.py index 59b314ed61..0a9e3b081e 100644 --- a/pypy/interpreter/miscutils.py +++ b/pypy/interpreter/miscutils.py @@ -3,6 +3,7 @@ Miscellaneous utilities. """ from rpython.rlib.listsort import make_timsort_class +from rpython.rlib.objectmodel import not_rpython class ThreadLocals: @@ -41,9 +42,8 @@ class ThreadLocals: # but in some corner cases it is not... unsure why self._value = None - +@not_rpython def make_weak_value_dictionary(space, keytype, valuetype): - "NOT_RPYTHON" if space.config.translation.rweakref: from rpython.rlib.rweakref import RWeakValueDictionary return RWeakValueDictionary(keytype, valuetype) diff --git a/pypy/interpreter/mixedmodule.py b/pypy/interpreter/mixedmodule.py index 738b91e66f..a49600fa0b 100644 --- a/pypy/interpreter/mixedmodule.py +++ b/pypy/interpreter/mixedmodule.py @@ -3,6 +3,9 @@ from pypy.interpreter.function import Function, BuiltinFunction from pypy.interpreter import gateway from pypy.interpreter.error import OperationError from pypy.interpreter.baseobjspace import W_Root + +from rpython.rlib.objectmodel import not_rpython + import sys class MixedModule(Module): @@ -15,16 +18,17 @@ class MixedModule(Module): lazy = False submodule_name = None + @not_rpython def __init__(self, space, w_name): - """ NOT_RPYTHON """ Module.__init__(self, space, w_name) self.lazy = True self.__class__.buildloaders() self.loaders = self.loaders.copy() # copy from the class to the inst self.submodules_w = [] + @not_rpython def install(self): - """NOT_RPYTHON: install this module, and it's submodules into + """install this module, and it's submodules into space.builtin_modules""" Module.install(self) if hasattr(self, "submodules"): @@ -61,8 +65,8 @@ class MixedModule(Module): self.w_initialdict = self.space.call_method(self.w_dict, 'items') @classmethod + @not_rpython def get_applevel_name(cls): - """ NOT_RPYTHON """ if cls.applevel_name is not None: return cls.applevel_name else: @@ -130,8 +134,8 @@ class MixedModule(Module): self._frozen = True @classmethod + @not_rpython def buildloaders(cls): - """ NOT_RPYTHON """ if not hasattr(cls, 'loaders'): # build a constant dictionary out of # applevel/interplevel definitions @@ -161,8 +165,8 @@ class MixedModule(Module): return space.newtext_or_none(cls.__doc__) +@not_rpython def getinterpevalloader(pkgroot, spec): - """ NOT_RPYTHON """ def ifileloader(space): d = {'space':space} # EVIL HACK (but it works, and this is not RPython :-) @@ -202,8 +206,8 @@ def getinterpevalloader(pkgroot, spec): return ifileloader applevelcache = {} +@not_rpython def getappfileloader(pkgroot, appname, spec): - """ NOT_RPYTHON """ # hum, it's a bit more involved, because we usually # want the import at applevel modname, attrname = spec.split('.') diff --git a/pypy/interpreter/module.py b/pypy/interpreter/module.py index 9741372cab..91c119a5cb 100644 --- a/pypy/interpreter/module.py +++ b/pypy/interpreter/module.py @@ -4,7 +4,7 @@ Module objects. from pypy.interpreter.baseobjspace import W_Root from pypy.interpreter.error import OperationError -from rpython.rlib.objectmodel import we_are_translated +from rpython.rlib.objectmodel import we_are_translated, not_rpython class Module(W_Root): @@ -40,13 +40,15 @@ class Module(W_Root): except OperationError: pass + @not_rpython def install(self): - """NOT_RPYTHON: installs this module into space.builtin_modules""" + """installs this module into space.builtin_modules""" modulename = self.space.text0_w(self.w_name) self.space.builtin_modules[modulename] = self + @not_rpython def setup_after_space_initialization(self): - """NOT_RPYTHON: to allow built-in modules to do some more setup + """to allow built-in modules to do some more setup after the space is fully initialized.""" def init(self, space): diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py index e2a8a55b48..0b47fe5cc2 100644 --- a/pypy/interpreter/pyframe.py +++ b/pypy/interpreter/pyframe.py @@ -7,6 +7,7 @@ from rpython.rlib.debug import make_sure_not_resized, check_nonneg from rpython.rlib.debug import ll_assert_not_none from rpython.rlib.jit import hint from rpython.rlib.objectmodel import instantiate, specialize, we_are_translated +from rpython.rlib.objectmodel import not_rpython from rpython.rlib.rarithmetic import intmask, r_uint from rpython.tool.pairtype import extendabletype @@ -144,8 +145,9 @@ class PyFrame(W_Root): return None return d.w_locals + @not_rpython def __repr__(self): - # NOT_RPYTHON: useful in tracebacks + # useful in tracebacks return "<%s.%s executing %s at line %s" % ( self.__class__.__module__, self.__class__.__name__, self.pycode, self.get_last_lineno()) diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py index bc5e027448..69f1c257de 100644 --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -7,7 +7,7 @@ The rest, dealing with variables in optimized ways, is in nestedscope.py. from rpython.rlib import jit, rstackovf from rpython.rlib.debug import check_nonneg from rpython.rlib.objectmodel import (we_are_translated, always_inline, - dont_inline) + dont_inline, not_rpython) from rpython.rlib.rarithmetic import r_uint, intmask from rpython.tool.sourcetools import func_with_new_name @@ -20,8 +20,8 @@ from pypy.interpreter.nestedscope import Cell from pypy.interpreter.pycode import PyCode, BytecodeCorruption from pypy.tool.stdlib_opcode import bytecode_spec +@not_rpython def unaryoperation(operationname): - """NOT_RPYTHON""" def opimpl(self, *ignored): operation = getattr(self.space, operationname) w_1 = self.popvalue() @@ -31,8 +31,8 @@ def unaryoperation(operationname): return func_with_new_name(opimpl, "opcode_impl_for_%s" % operationname) +@not_rpython def binaryoperation(operationname): - """NOT_RPYTHON""" def opimpl(self, *ignored): operation = getattr(self.space, operationname) w_2 = self.popvalue() diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py index a5a04c3776..c18257f5b7 100644 --- a/pypy/interpreter/typedef.py +++ b/pypy/interpreter/typedef.py @@ -8,14 +8,15 @@ from pypy.interpreter.gateway import (interp2app, BuiltinCode, unwrap_spec, from rpython.rlib.jit import promote from rpython.rlib.objectmodel import compute_identity_hash, specialize -from rpython.rlib.objectmodel import instantiate +from rpython.rlib.objectmodel import instantiate, not_rpython from rpython.tool.sourcetools import compile2, func_with_new_name class TypeDef(object): + @not_rpython def __init__(self, __name, __base=None, __total_ordering__=None, __buffer=None, **rawdict): - "NOT_RPYTHON: initialization-time only" + "initialization-time only" self.name = __name if __base is None: bases = [] @@ -113,8 +114,9 @@ def default_identity_hash(space, w_obj): # register_finalizer() or not. @specialize.memo() +@not_rpython def get_unique_interplevel_subclass(space, cls): - "NOT_RPYTHON: initialization-time only" + "initialization-time only" assert cls.typedef.acceptable_as_base_class try: return _unique_subclass_cache[cls] @@ -349,15 +351,17 @@ class GetSetProperty(W_Root): return self +@not_rpython def interp_attrproperty(name, cls, doc=None, wrapfn=None): - "NOT_RPYTHON: initialization-time only" + "initialization-time only" assert wrapfn is not None def fget(space, obj): return getattr(space, wrapfn)(getattr(obj, name)) return GetSetProperty(fget, cls=cls, doc=doc) +@not_rpython def interp_attrproperty_w(name, cls, doc=None): - "NOT_RPYTHON: initialization-time only" + "initialization-time only" def fget(space, obj): w_value = getattr(obj, name) if w_value is None: diff --git a/pypy/module/_codecs/__init__.py b/pypy/module/_codecs/__init__.py index 9f2285486f..5e09786823 100644 --- a/pypy/module/_codecs/__init__.py +++ b/pypy/module/_codecs/__init__.py @@ -1,5 +1,6 @@ from pypy.interpreter.mixedmodule import MixedModule from rpython.rlib import runicode +from rpython.rlib.objectmodel import not_rpython from pypy.module._codecs import interp_codecs class Module(MixedModule): @@ -86,9 +87,8 @@ Copyright (c) Corporation for National Research Initiatives. 'unicode_internal_encode' : 'interp_codecs.unicode_internal_encode', } + @not_rpython def __init__(self, space, *args): - "NOT_RPYTHON" - # mbcs codec is Windows specific, and based on rffi. if (hasattr(runicode, 'str_decode_mbcs')): self.interpleveldefs['mbcs_encode'] = 'interp_codecs.mbcs_encode' diff --git a/pypy/module/_codecs/interp_codecs.py b/pypy/module/_codecs/interp_codecs.py index 0ce1ac3dac..2f37d36310 100644 --- a/pypy/module/_codecs/interp_codecs.py +++ b/pypy/module/_codecs/interp_codecs.py @@ -1,5 +1,5 @@ from rpython.rlib import jit -from rpython.rlib.objectmodel import we_are_translated +from rpython.rlib.objectmodel import we_are_translated, not_rpython from rpython.rlib.rstring import UnicodeBuilder from rpython.rlib.runicode import code_to_unichr, MAXUNICODE @@ -268,8 +268,8 @@ def backslashreplace_errors(space, w_exc): raise oefmt(space.w_TypeError, "don't know how to handle %T in error callback", w_exc) +@not_rpython def register_builtin_error_handlers(space): - "NOT_RPYTHON" state = space.fromcache(CodecState) for error in ("strict", "ignore", "replace", "xmlcharrefreplace", "backslashreplace"): diff --git a/pypy/module/posix/interp_posix.py b/pypy/module/posix/interp_posix.py index b097c6f13a..34f3d1bff6 100644 --- a/pypy/module/posix/interp_posix.py +++ b/pypy/module/posix/interp_posix.py @@ -3,7 +3,7 @@ import sys from rpython.rlib import rposix, rposix_stat from rpython.rlib import objectmodel, rurandom -from rpython.rlib.objectmodel import specialize +from rpython.rlib.objectmodel import specialize, not_rpython from rpython.rlib.rarithmetic import r_longlong, intmask, r_uint from rpython.rlib.unroll import unrolling_iterable @@ -731,8 +731,8 @@ def get_fork_hooks(where): else: assert False, "Unknown fork hook" +@not_rpython def add_fork_hook(where, hook): - "NOT_RPYTHON" get_fork_hooks(where).append(hook) add_fork_hook('child', ExecutionContext._mark_thread_disappeared) diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py index cf7274c903..3091b07910 100644 --- a/pypy/objspace/std/objspace.py +++ b/pypy/objspace/std/objspace.py @@ -181,8 +181,8 @@ class StdObjSpace(ObjSpace): return self._wrap_not_rpython(x) + @not_rpython def _wrap_not_rpython(self, x): - "NOT_RPYTHON" # _____ this code is here to support testing only _____ # wrap() of a container works on CPython, but the code is diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py index a0130085dd..4d3a5caa43 100644 --- a/pypy/objspace/std/typeobject.py +++ b/pypy/objspace/std/typeobject.py @@ -11,7 +11,7 @@ from pypy.module.__builtin__ import abstractinst from rpython.rlib.jit import (promote, elidable_promote, we_are_jitted, elidable, dont_look_inside, unroll_safe) from rpython.rlib.objectmodel import current_object_addr_as_int, compute_hash -from rpython.rlib.objectmodel import we_are_translated +from rpython.rlib.objectmodel import we_are_translated, not_rpython from rpython.rlib.rarithmetic import intmask, r_uint class MutableCell(W_Root): @@ -212,8 +212,8 @@ class W_TypeObject(W_Root): else: self.terminator = NoDictTerminator(space, self) + @not_rpython def __repr__(self): - "NOT_RPYTHON" return '<W_TypeObject %r at 0x%x>' % (self.name, id(self)) def mutated(self, key): @@ -492,8 +492,9 @@ class W_TypeObject(W_Root): self, w_subtype, w_subtype) return w_subtype + @not_rpython def _cleanup_(self): - "NOT_RPYTHON. Forces the lazy attributes to be computed." + "Forces the lazy attributes to be computed." if 'lazyloaders' in self.__dict__: for attr in self.lazyloaders.keys(): self.getdictvalue(self.space, attr) @@ -1317,8 +1318,9 @@ def mro_error(space, orderlists): class TypeCache(SpaceCache): + @not_rpython def build(self, typedef): - "NOT_RPYTHON: initialization-time only." + "initialization-time only." from pypy.objspace.std.objectobject import W_ObjectObject from pypy.interpreter.typedef import GetSetProperty from rpython.rlib.objectmodel import instantiate |