[pypy-commit] pypy default: replace NOT_RPYTHON by @not_rpython in rlib/

cfbolz pypy.commits at gmail.com
Mon Nov 7 13:26:46 EST 2016


Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: 
Changeset: r88194:959d4c580113
Date: 2016-11-07 19:24 +0100
http://bitbucket.org/pypy/pypy/changeset/959d4c580113/

Log:	replace NOT_RPYTHON by @not_rpython in rlib/

diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -3,7 +3,7 @@
 import py
 
 from rpython.rlib.nonconst import NonConstant
-from rpython.rlib.objectmodel import CDefinedIntSymbolic, keepalive_until_here, specialize
+from rpython.rlib.objectmodel import CDefinedIntSymbolic, keepalive_until_here, specialize, not_rpython
 from rpython.rlib.unroll import unrolling_iterable
 from rpython.rtyper.extregistry import ExtRegistryEntry
 from rpython.tool.sourcetools import rpython_wrapper
@@ -614,14 +614,14 @@
     inline_jit_merge_point = False
     _store_last_enter_jit = None
 
+    @not_rpython
     def __init__(self, greens=None, reds=None, virtualizables=None,
                  get_jitcell_at=None, set_jitcell_at=None,
                  get_printable_location=None, confirm_enter_jit=None,
                  can_never_inline=None, should_unroll_one_iteration=None,
                  name='jitdriver', check_untranslated=True, vectorize=False,
                  get_unique_id=None, is_recursive=False, get_location=None):
-        """ NOT_RPYTHON
-            get_location:
+        """get_location:
               The return value is designed to provide enough information to express the
               state of an interpreter when invoking jit_merge_point.
               For a bytecode interperter such as PyPy this includes, filename, line number,
diff --git a/rpython/rlib/parsing/parsing.py b/rpython/rlib/parsing/parsing.py
--- a/rpython/rlib/parsing/parsing.py
+++ b/rpython/rlib/parsing/parsing.py
@@ -1,6 +1,7 @@
 import py
 from rpython.rlib.parsing.lexer import SourcePos
 from rpython.rlib.parsing.tree import Node, Symbol, Nonterminal
+from rpython.rlib.objectmodel import not_rpython
 
 class Rule(object):
     def __init__(self, nonterminal, expansions):
@@ -181,8 +182,8 @@
             raise ParseError(input[error.pos].source_pos, error)
         return result[0]
 
+    @not_rpython
     def has_left_recursion(self):
-        """NOT_RPYTHON"""
         follows = {}
         for rule in self.rules:
             follow = py.builtin.set()
diff --git a/rpython/rlib/parsing/tree.py b/rpython/rlib/parsing/tree.py
--- a/rpython/rlib/parsing/tree.py
+++ b/rpython/rlib/parsing/tree.py
@@ -1,4 +1,5 @@
 import py
+from rpython.rlib.objectmodel import not_rpython
 
 class Node(object):
     def view(self):
@@ -38,8 +39,8 @@
             id(self), symbol,
             repr(addinfo).replace('"', '').replace("\\", "\\\\")))
 
+    @not_rpython
     def visit(self, visitor):
-        "NOT_RPYTHON"
         if isinstance(visitor, RPythonVisitor):
             return visitor.dispatch(self)
         method = getattr(visitor, "visit_" + self.symbol, None)
@@ -76,8 +77,8 @@
                     id(child),
                     repr(child).replace('"', '').replace("\\", "\\\\"))
 
+    @not_rpython
     def visit(self, visitor):
-        "NOT_RPYTHON"
         if isinstance(visitor, RPythonVisitor):
             return visitor.dispatch(self)
         general = getattr(visitor, "visit", None)
diff --git a/rpython/rlib/rarithmetic.py b/rpython/rlib/rarithmetic.py
--- a/rpython/rlib/rarithmetic.py
+++ b/rpython/rlib/rarithmetic.py
@@ -37,7 +37,7 @@
 from rpython.rlib import objectmodel
 from rpython.flowspace.model import Constant, const
 from rpython.flowspace.specialcase import register_flow_sc
-from rpython.rlib.objectmodel import specialize
+from rpython.rlib.objectmodel import specialize, not_rpython
 
 """
 Long-term target:
@@ -105,10 +105,8 @@
 # XXX returning int(n) should not be necessary and should be simply n.
 # XXX TODO: replace all int(n) by long(n) and fix everything that breaks.
 # XXX       Then relax it and replace int(n) by n.
+ at not_rpython
 def intmask(n):
-    """
-    NOT_RPYTHON
-    """
     if isinstance(n, objectmodel.Symbolic):
         return n        # assume Symbolics don't overflow
     assert not isinstance(n, float)
@@ -120,10 +118,8 @@
         n -= 2*LONG_TEST
     return int(n)
 
+ at not_rpython
 def longlongmask(n):
-    """
-    NOT_RPYTHON
-    """
     assert isinstance(n, (int, long))
     n = long(n)
     n &= LONGLONG_MASK
@@ -168,8 +164,8 @@
     return isinstance(r, (base_int, int, long, bool)) and (
         -maxint - 1 <= r <= maxint)
 
+ at not_rpython
 def ovfcheck(r):
-    "NOT_RPYTHON"
     # to be used as ovfcheck(x <op> y)
     # raise OverflowError if the operation did overflow
     assert not isinstance(r, r_uint), "unexpected ovf check on unsigned"
diff --git a/rpython/rlib/rawrefcount.py b/rpython/rlib/rawrefcount.py
--- a/rpython/rlib/rawrefcount.py
+++ b/rpython/rlib/rawrefcount.py
@@ -6,7 +6,7 @@
 #
 import sys, weakref
 from rpython.rtyper.lltypesystem import lltype, llmemory
-from rpython.rlib.objectmodel import we_are_translated, specialize
+from rpython.rlib.objectmodel import we_are_translated, specialize, not_rpython
 from rpython.rtyper.extregistry import ExtRegistryEntry
 from rpython.rlib import rgc
 
@@ -23,8 +23,9 @@
     return res
 
 
+ at not_rpython
 def init(dealloc_trigger_callback=None):
-    """NOT_RPYTHON: set up rawrefcount with the GC.  This is only used
+    """set up rawrefcount with the GC.  This is only used
     for tests; it should not be called at all during translation.
     """
     global _p_list, _o_list, _adr2pypy, _pypy2ob, _pypy2ob_rev
@@ -37,8 +38,9 @@
     _d_list = []
     _dealloc_trigger_callback = dealloc_trigger_callback
 
+ at not_rpython
 def create_link_pypy(p, ob):
-    "NOT_RPYTHON: a link where the PyPy object contains some or all the data"
+    "a link where the PyPy object contains some or all the data"
     #print 'create_link_pypy\n\t%s\n\t%s' % (p, ob)
     assert p not in _pypy2ob
     assert ob._obj not in _pypy2ob_rev
@@ -48,8 +50,9 @@
     _pypy2ob_rev[ob._obj] = p
     _p_list.append(ob)
 
+ at not_rpython
 def create_link_pyobj(p, ob):
-    """NOT_RPYTHON: a link where the PyObject contains all the data.
+    """a link where the PyObject contains all the data.
        from_obj() will not work on this 'p'."""
     #print 'create_link_pyobj\n\t%s\n\t%s' % (p, ob)
     assert p not in _pypy2ob
@@ -58,8 +61,8 @@
     ob.c_ob_pypy_link = _build_pypy_link(p)
     _o_list.append(ob)
 
+ at not_rpython
 def from_obj(OB_PTR_TYPE, p):
-    "NOT_RPYTHON"
     ob = _pypy2ob.get(p)
     if ob is None:
         return lltype.nullptr(OB_PTR_TYPE.TO)
@@ -67,8 +70,8 @@
     assert _pypy2ob_rev[ob._obj] is p
     return ob
 
+ at not_rpython
 def to_obj(Class, ob):
-    "NOT_RPYTHON"
     link = ob.c_ob_pypy_link
     if link == 0:
         return None
@@ -76,8 +79,9 @@
     assert isinstance(p, Class)
     return p
 
+ at not_rpython
 def next_dead(OB_PTR_TYPE):
-    """NOT_RPYTHON.  When the GC runs, it finds some pyobjs to be dead
+    """When the GC runs, it finds some pyobjs to be dead
     but cannot immediately dispose of them (it doesn't know how to call
     e.g. tp_dealloc(), and anyway calling it immediately would cause all
     sorts of bugs).  So instead, it stores them in an internal list,
@@ -89,8 +93,9 @@
     assert lltype.typeOf(ob) == OB_PTR_TYPE
     return ob
 
+ at not_rpython
 def _collect(track_allocation=True):
-    """NOT_RPYTHON: for tests only.  Emulates a GC collection.
+    """for tests only.  Emulates a GC collection.
     Will invoke dealloc_trigger_callback() once if there are objects
     whose _Py_Dealloc() should be called.
     """
diff --git a/rpython/rlib/rawstorage.py b/rpython/rlib/rawstorage.py
--- a/rpython/rlib/rawstorage.py
+++ b/rpython/rlib/rawstorage.py
@@ -4,7 +4,7 @@
 from rpython.annotator import model as annmodel
 from rpython.rtyper.llannotation import lltype_to_annotation
 from rpython.rlib.rgc import lltype_is_gc
-from rpython.rlib.objectmodel import specialize
+from rpython.rlib.objectmodel import specialize, not_rpython
 
 RAW_STORAGE = rffi.CCHARP.TO
 RAW_STORAGE_PTR = rffi.CCHARP
@@ -16,23 +16,23 @@
                          track_allocation=track_allocation,
                          zero=zero)
 
+ at not_rpython
 def raw_storage_getitem(TP, storage, index):
-    "NOT_RPYTHON"
     _check_alignment(TP, index)
     return _raw_storage_getitem_unchecked(TP, storage, index)
 
+ at not_rpython
 def _raw_storage_getitem_unchecked(TP, storage, index):
-    "NOT_RPYTHON"
     return rffi.cast(rffi.CArrayPtr(TP), rffi.ptradd(storage, index))[0]
 
+ at not_rpython
 def raw_storage_setitem(storage, index, item):
-    "NOT_RPYTHON"
     TP = lltype.typeOf(item)
     _check_alignment(TP, index)
     _raw_storage_setitem_unchecked(storage, index, item)
 
+ at not_rpython
 def _raw_storage_setitem_unchecked(storage, index, item):
-    "NOT_RPYTHON"
     TP = lltype.typeOf(item)
     rffi.cast(rffi.CArrayPtr(TP), rffi.ptradd(storage, index))[0] = item
 
diff --git a/rpython/rlib/rbigint.py b/rpython/rlib/rbigint.py
--- a/rpython/rlib/rbigint.py
+++ b/rpython/rlib/rbigint.py
@@ -4,7 +4,7 @@
 from rpython.rlib.rfloat import isinf, isnan
 from rpython.rlib.rstring import StringBuilder
 from rpython.rlib.debug import make_sure_not_resized, check_regular_int
-from rpython.rlib.objectmodel import we_are_translated, specialize
+from rpython.rlib.objectmodel import we_are_translated, specialize, not_rpython
 from rpython.rlib import jit
 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.rtyper import extregistry
@@ -149,14 +149,14 @@
         self.sign = sign
 
     # __eq__ and __ne__ method exist for testingl only, they are not RPython!
+    @not_rpython
     def __eq__(self, other):
-        # NOT_RPYTHON
         if not isinstance(other, rbigint):
             return NotImplemented
         return self.eq(other)
 
+    @not_rpython
     def __ne__(self, other):
-        # NOT_RPYTHON
         return not (self == other)
 
     def digit(self, x):
@@ -218,8 +218,8 @@
         return NULLRBIGINT
 
     @staticmethod
+    @not_rpython
     def fromlong(l):
-        "NOT_RPYTHON"
         return rbigint(*args_from_long(l))
 
     @staticmethod
@@ -1230,8 +1230,8 @@
             ret /= math.log(base)
         return ret
 
+    @not_rpython
     def tolong(self):
-        "NOT_RPYTHON"
         l = 0L
         digits = list(self._digits)
         digits.reverse()
@@ -1356,8 +1356,8 @@
 # ^^^ specialized by the precise type of 'x', which is typically a r_xxx
 #     instance from rlib.rarithmetic
 
+ at not_rpython
 def args_from_long(x):
-    "NOT_RPYTHON"
     if x >= 0:
         if x == 0:
             return [NULLDIGIT], 0
diff --git a/rpython/rlib/rdynload.py b/rpython/rlib/rdynload.py
--- a/rpython/rlib/rdynload.py
+++ b/rpython/rlib/rdynload.py
@@ -3,7 +3,7 @@
 
 from rpython.rtyper.tool import rffi_platform
 from rpython.rtyper.lltypesystem import rffi, lltype
-from rpython.rlib.objectmodel import we_are_translated
+from rpython.rlib.objectmodel import we_are_translated, not_rpython
 from rpython.rlib.rarithmetic import r_uint
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 from rpython.translator.platform import platform
@@ -92,8 +92,9 @@
             return ""
         return rffi.charp2str(res)
 
+    @not_rpython
     def _dlerror_on_dlopen_untranslated(name):
-        "NOT_RPYTHON: aaargh"
+        # aaargh
         import ctypes
         name = rffi.charp2str(name)
         try:
diff --git a/rpython/rlib/rfloat.py b/rpython/rlib/rfloat.py
--- a/rpython/rlib/rfloat.py
+++ b/rpython/rlib/rfloat.py
@@ -7,6 +7,7 @@
 from rpython.rtyper.extfunc import register_external
 from rpython.rtyper.tool import rffi_platform
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
+from rpython.rlib.objectmodel import not_rpython
 
 
 class CConfig:
@@ -187,16 +188,17 @@
     # Try to get math functions added in 2.6.
     from math import isinf, isnan, copysign, acosh, asinh, atanh, log1p
 except ImportError:
+    @not_rpython
     def isinf(x):
-        "NOT_RPYTHON"
         return x == INFINITY or x == -INFINITY
 
+    @not_rpython
     def isnan(v):
-        "NOT_RPYTHON"
         return v != v
 
+    @not_rpython
     def copysign(x, y):
-        """NOT_RPYTHON. Return x with the sign of y"""
+        """Return x with the sign of y"""
         if x < 0.:
             x = -x
         if y > 0. or (y == 0. and math.atan2(y, -1.) > 0.):
@@ -208,8 +210,8 @@
     _2_to_p28 = 268435456.0; # 2**28
     _ln2 = 6.93147180559945286227E-01
 
+    @not_rpython
     def acosh(x):
-        "NOT_RPYTHON"
         if isnan(x):
             return NAN
         if x < 1.:
@@ -227,8 +229,8 @@
         t = x - 1.0
         return log1p(t + math.sqrt(2. * t + t * t))
 
+    @not_rpython
     def asinh(x):
-        "NOT_RPYTHON"
         absx = abs(x)
         if not isfinite(x):
             return x
@@ -243,8 +245,8 @@
             w = log1p(absx + t / (1. + math.sqrt(1. + t)))
         return copysign(w, x)
 
+    @not_rpython
     def atanh(x):
-        "NOT_RPYTHON"
         if isnan(x):
             return x
         absx = abs(x)
@@ -259,8 +261,8 @@
             t = .5 * log1p((absx + absx) / (1. - absx))
         return copysign(t, x)
 
+    @not_rpython
     def log1p(x):
-        "NOT_RPYTHON"
         if abs(x) < DBL_EPSILON // 2.:
             return x
         elif -.5 <= x <= 1.:
@@ -272,8 +274,8 @@
 try:
     from math import expm1 # Added in Python 2.7.
 except ImportError:
+    @not_rpython
     def expm1(x):
-        "NOT_RPYTHON"
         if abs(x) < .7:
             u = math.exp(x)
             if u == 1.:
@@ -319,8 +321,8 @@
         r = math.floor(absx)
     return copysign(r, x)
 
+ at not_rpython
 def isfinite(x):
-    "NOT_RPYTHON"
     return not isinf(x) and not isnan(x)
 
 def float_as_rbigint_ratio(value):
diff --git a/rpython/rlib/rgc.py b/rpython/rlib/rgc.py
--- a/rpython/rlib/rgc.py
+++ b/rpython/rlib/rgc.py
@@ -5,7 +5,7 @@
 
 from rpython.rlib import jit
 from rpython.rlib.objectmodel import we_are_translated, enforceargs, specialize
-from rpython.rlib.objectmodel import CDefinedIntSymbolic
+from rpython.rlib.objectmodel import CDefinedIntSymbolic, not_rpython
 from rpython.rtyper.extregistry import ExtRegistryEntry
 from rpython.rtyper.lltypesystem import lltype, llmemory
 
@@ -422,8 +422,9 @@
         else:
             self._untranslated_register_finalizer(obj)
 
+    @not_rpython
     def _get_tag(self):
-        "NOT_RPYTHON: special-cased below"
+        "special-cased below"
 
     def _reset(self):
         import collections
@@ -530,14 +531,14 @@
 # ____________________________________________________________
 
 
+ at not_rpython
 def get_rpy_roots():
-    "NOT_RPYTHON"
     # Return the 'roots' from the GC.
     # The gc typically returns a list that ends with a few NULL_GCREFs.
     return [_GcRef(x) for x in gc.get_objects()]
 
+ at not_rpython
 def get_rpy_referents(gcref):
-    "NOT_RPYTHON"
     x = gcref._x
     if isinstance(x, list):
         d = x
@@ -583,8 +584,8 @@
                          resulttype=lltype.Void)
 
 
+ at not_rpython
 def get_rpy_memory_usage(gcref):
-    "NOT_RPYTHON"
     # approximate implementation using CPython's type info
     Class = type(gcref._x)
     size = Class.__basicsize__
@@ -592,8 +593,8 @@
         size += Class.__itemsize__ * len(gcref._x)
     return size
 
+ at not_rpython
 def get_rpy_type_index(gcref):
-    "NOT_RPYTHON"
     from rpython.rlib.rarithmetic import intmask
     Class = gcref._x.__class__
     return intmask(id(Class))
@@ -607,33 +608,33 @@
     else:
         return id(gcref._x)
 
+ at not_rpython
 def dump_rpy_heap(fd):
-    "NOT_RPYTHON"
     raise NotImplementedError
 
+ at not_rpython
 def get_typeids_z():
-    "NOT_RPYTHON"
     raise NotImplementedError
 
+ at not_rpython
 def get_typeids_list():
-    "NOT_RPYTHON"
     raise NotImplementedError
 
+ at not_rpython
 def has_gcflag_extra():
-    "NOT_RPYTHON"
     return True
 has_gcflag_extra._subopnum = 1
 
 _gcflag_extras = set()
 
+ at not_rpython
 def get_gcflag_extra(gcref):
-    "NOT_RPYTHON"
     assert gcref   # not NULL!
     return gcref in _gcflag_extras
 get_gcflag_extra._subopnum = 2
 
+ at not_rpython
 def toggle_gcflag_extra(gcref):
-    "NOT_RPYTHON"
     assert gcref   # not NULL!
     try:
         _gcflag_extras.remove(gcref)
@@ -801,12 +802,12 @@
         return hop.genop('gc_get_rpy_type_index', vlist,
                          resulttype = hop.r_result)
 
+ at not_rpython
 def _is_rpy_instance(gcref):
-    "NOT_RPYTHON"
     raise NotImplementedError
 
+ at not_rpython
 def _get_llcls_from_cls(Class):
-    "NOT_RPYTHON"
     raise NotImplementedError
 
 class Entry(ExtRegistryEntry):
diff --git a/rpython/rlib/rgil.py b/rpython/rlib/rgil.py
--- a/rpython/rlib/rgil.py
+++ b/rpython/rlib/rgil.py
@@ -3,6 +3,7 @@
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
 from rpython.rtyper.extregistry import ExtRegistryEntry
+from rpython.rlib.objectmodel import not_rpython
 
 # these functions manipulate directly the GIL, whose definition does not
 # escape the C code itself
@@ -58,8 +59,8 @@
 
 _emulated_after_thread_switch = None
 
+ at not_rpython
 def _after_thread_switch():
-    """NOT_RPYTHON"""
     if _emulated_after_thread_switch is not None:
         _emulated_after_thread_switch()
 
diff --git a/rpython/rlib/rposix_stat.py b/rpython/rlib/rposix_stat.py
--- a/rpython/rlib/rposix_stat.py
+++ b/rpython/rlib/rposix_stat.py
@@ -17,7 +17,7 @@
 from rpython.rtyper.error import TyperError
 
 from rpython.rlib._os_support import _preferred_traits, string_traits
-from rpython.rlib.objectmodel import specialize, we_are_translated
+from rpython.rlib.objectmodel import specialize, we_are_translated, not_rpython
 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 from rpython.rlib.rarithmetic import intmask
@@ -240,9 +240,9 @@
 
 s_StatResult = SomeStatResult()
 
-
+ at not_rpython
 def make_stat_result(tup):
-    """NOT_RPYTHON: Turn a tuple into an os.stat_result object."""
+    """Turn a tuple into an os.stat_result object."""
     assert len(tup) == len(STAT_FIELDS)
     assert float not in [type(x) for x in tup]
     positional = []
diff --git a/rpython/rlib/rsre/rsre_core.py b/rpython/rlib/rsre/rsre_core.py
--- a/rpython/rlib/rsre/rsre_core.py
+++ b/rpython/rlib/rsre/rsre_core.py
@@ -3,7 +3,7 @@
 from rpython.rlib.unroll import unrolling_iterable
 from rpython.rlib.rsre import rsre_char
 from rpython.tool.sourcetools import func_with_new_name
-from rpython.rlib.objectmodel import we_are_translated
+from rpython.rlib.objectmodel import we_are_translated, not_rpython
 from rpython.rlib import jit
 from rpython.rlib.rsre.rsre_jit import install_jitdriver, install_jitdriver_spec
 
@@ -121,16 +121,18 @@
         assert result >= 0
         return result
 
+    @not_rpython
     def str(self, index):
-        """NOT_RPYTHON: Must be overridden in a concrete subclass.
+        """Must be overridden in a concrete subclass.
         The tag ^^^ here is used to generate a translation-time crash
         if there is a call to str() that is indirect.  All calls must
         be direct for performance reasons; you need to specialize the
         caller with @specializectx."""
         raise NotImplementedError
 
+    @not_rpython
     def lowstr(self, index):
-        """NOT_RPYTHON: Similar to str()."""
+        """Similar to str()."""
         raise NotImplementedError
 
     def get_mark(self, gid):
diff --git a/rpython/rlib/rsre/rsre_re.py b/rpython/rlib/rsre/rsre_re.py
--- a/rpython/rlib/rsre/rsre_re.py
+++ b/rpython/rlib/rsre/rsre_re.py
@@ -2,7 +2,7 @@
 This is not used in a PyPy translation, but it can be used
 in RPython code.  It exports the same interface as the
 Python 're' module.  You can call the functions at the start
-of the module (expect the ones with NOT_RPYTHON for now).
+of the module (expect the ones with @not_rpython for now).
 They must be called with a *constant* pattern string.
 """
 import re, sys
@@ -10,6 +10,7 @@
 from rpython.rlib.rsre.rpy import get_code as _get_code
 from rpython.rlib.unicodedata import unicodedb
 from rpython.rlib.objectmodel import specialize, we_are_translated
+from rpython.rlib.objectmodel import not_rpython
 rsre_char.set_unicode_db(unicodedb)
 
 
@@ -37,12 +38,12 @@
 def finditer(pattern, string, flags=0):
     return compile(pattern, flags).finditer(string)
 
+ at not_rpython
 def sub(pattern, repl, string, count=0):
-    "NOT_RPYTHON"
     return compile(pattern).sub(repl, string, count)
 
+ at not_rpython
 def subn(pattern, repl, string, count=0):
-    "NOT_RPYTHON"
     return compile(pattern).subn(repl, string, count)
 
 @specialize.call_location()
@@ -103,8 +104,8 @@
                 break
             yield match
 
+    @not_rpython
     def subn(self, repl, string, count=0):
-        "NOT_RPYTHON"
         filter = repl
         if not callable(repl) and "\\" in repl:
             # handle non-literal strings; hand it over to the template compiler
@@ -151,8 +152,8 @@
             item = "".join(sublist)
         return item, n
 
+    @not_rpython
     def sub(self, repl, string, count=0):
-        "NOT_RPYTHON"
         item, n = self.subn(repl, string, count)
         return item
 
diff --git a/rpython/rlib/rstrategies/rstrategies.py b/rpython/rlib/rstrategies/rstrategies.py
--- a/rpython/rlib/rstrategies/rstrategies.py
+++ b/rpython/rlib/rstrategies/rstrategies.py
@@ -2,7 +2,7 @@
 import weakref, sys
 from rpython.rlib.rstrategies import logger
 from rpython.rlib import jit, objectmodel, rerased
-from rpython.rlib.objectmodel import specialize
+from rpython.rlib.objectmodel import specialize, not_rpython
 
 def make_accessors(strategy='strategy', storage='storage'):
     """
@@ -155,6 +155,7 @@
                 return strategy_type
         raise ValueError("Could not find strategy to handle: %s" % objects)
 
+    @not_rpython
     def decorate_strategies(self, transitions):
         """
         As an alternative to decorating all strategies with @strategy,
@@ -162,7 +163,6 @@
         calling __init__. transitions is a dict mapping all strategy classes to
         their 'generalize' list parameter (see @strategy decorator).
         """
-        "NOT_RPYTHON"
         for strategy_class, generalized in transitions.items():
             strategy(generalized)(strategy_class)
 
@@ -217,8 +217,8 @@
     # Internal methods
     # =============================
 
+    @not_rpython
     def _patch_strategy_class(self, strategy_class, root_class):
-        "NOT_RPYTHON"
         # Patch root class: Add default handler for visitor
         def _convert_storage_from_OTHER(self, w_self, previous_strategy):
             self._convert_storage_from(w_self, previous_strategy)
@@ -231,16 +231,16 @@
             getattr(new_strategy, funcname)(w_self, self)
         strategy_class._convert_storage_to = _convert_storage_to
 
+    @not_rpython
     def _collect_subclasses(self, cls):
-        "NOT_RPYTHON"
         subclasses = []
         for subcls in cls.__subclasses__():
             subclasses.append(subcls)
             subclasses.extend(self._collect_subclasses(subcls))
         return subclasses
 
+    @not_rpython
     def _order_strategies(self):
-        "NOT_RPYTHON"
         def get_generalization_depth(strategy, visited=None):
             if visited is None:
                 visited = set()
diff --git a/rpython/rlib/rstring.py b/rpython/rlib/rstring.py
--- a/rpython/rlib/rstring.py
+++ b/rpython/rlib/rstring.py
@@ -6,7 +6,7 @@
     SomeInteger, SomeUnicodeCodePoint, SomeUnicodeString, SomePBC)
 from rpython.rtyper.llannotation import SomePtr
 from rpython.rlib import jit
-from rpython.rlib.objectmodel import newlist_hint, resizelist_hint, specialize
+from rpython.rlib.objectmodel import newlist_hint, resizelist_hint, specialize, not_rpython
 from rpython.rlib.rarithmetic import ovfcheck, LONG_BIT as BLOOM_WIDTH
 from rpython.rlib.buffer import Buffer
 from rpython.rlib.unicodedata import unicodedb_5_2_0 as unicodedb
@@ -516,37 +516,37 @@
 class AbstractStringBuilder(object):
     # This is not the real implementation!
 
+    @not_rpython
     def __init__(self, init_size=INIT_SIZE):
-        "NOT_RPYTHON"
         self._l = []
         self._size = 0
 
+    @not_rpython
     def _grow(self, size):
-        "NOT_RPYTHON"
         self._size += size
 
+    @not_rpython
     def append(self, s):
-        "NOT_RPYTHON"
         assert isinstance(s, self._tp)
         self._l.append(s)
         self._grow(len(s))
 
+    @not_rpython
     def append_slice(self, s, start, end):
-        "NOT_RPYTHON"
         assert isinstance(s, self._tp)
         assert 0 <= start <= end <= len(s)
         s = s[start:end]
         self._l.append(s)
         self._grow(len(s))
 
+    @not_rpython
     def append_multiple_char(self, c, times):
-        "NOT_RPYTHON"
         assert isinstance(c, self._tp)
         self._l.append(c * times)
         self._grow(times)
 
+    @not_rpython
     def append_charpsize(self, s, size):
-        "NOT_RPYTHON"
         assert size >= 0
         l = []
         for i in xrange(size):
@@ -554,15 +554,15 @@
         self._l.append(self._tp("").join(l))
         self._grow(size)
 
+    @not_rpython
     def build(self):
-        "NOT_RPYTHON"
         result = self._tp("").join(self._l)
         assert len(result) == self._size
         self._l = [result]
         return result
 
+    @not_rpython
     def getlength(self):
-        "NOT_RPYTHON"
         return self._size
 
 
diff --git a/rpython/rlib/rthread.py b/rpython/rlib/rthread.py
--- a/rpython/rlib/rthread.py
+++ b/rpython/rlib/rthread.py
@@ -5,7 +5,7 @@
 from rpython.rlib import jit, rgc
 from rpython.rlib.debug import ll_assert
 from rpython.rlib.objectmodel import we_are_translated, specialize
-from rpython.rlib.objectmodel import CDefinedIntSymbolic
+from rpython.rlib.objectmodel import CDefinedIntSymbolic, not_rpython
 from rpython.rtyper.lltypesystem.lloperation import llop
 from rpython.rtyper.tool import rffi_platform
 from rpython.rtyper.extregistry import ExtRegistryEntry
@@ -37,8 +37,8 @@
     return rffi.llexternal(name, args, result, compilation_info=eci,
                            **kwds)
 
+ at not_rpython
 def _emulated_start_new_thread(func):
-    "NOT_RPYTHON"
     import thread
     try:
         ident = thread.start_new_thread(func, ())
@@ -319,8 +319,9 @@
 
 
 class ThreadLocalField(object):
+    @not_rpython
     def __init__(self, FIELDTYPE, fieldname, loop_invariant=False):
-        "NOT_RPYTHON: must be prebuilt"
+        "must be prebuilt"
         try:
             from thread import _local
         except ImportError:
@@ -328,7 +329,7 @@
                 pass
         self.FIELDTYPE = FIELDTYPE
         self.fieldname = fieldname
-        self.local = _local()      # <- NOT_RPYTHON
+        self.local = _local()      # <- not rpython
         zero = rffi.cast(FIELDTYPE, 0)
         offset = CDefinedIntSymbolic('RPY_TLOFS_%s' % self.fieldname,
                                      default='?')
@@ -381,8 +382,9 @@
     # leak the objects when a thread finishes; see threadlocal.c.)
     _COUNT = 1
 
+    @not_rpython
     def __init__(self, Cls, loop_invariant=False):
-        "NOT_RPYTHON: must be prebuilt"
+        "must be prebuilt"
         self.Cls = Cls
         unique_id = ThreadLocalReference._COUNT
         ThreadLocalReference._COUNT += 1
@@ -454,8 +456,9 @@
     tlfield_rpy_lasterror = ThreadLocalField(rwin32.DWORD, "rpy_lasterror")
     tlfield_alt_lasterror = ThreadLocalField(rwin32.DWORD, "alt_lasterror")
 
+ at not_rpython
 def _threadlocalref_seeme(field):
-    "NOT_RPYTHON"
+    pass
 
 class _Entry(ExtRegistryEntry):
     _about_ = _threadlocalref_seeme
diff --git a/rpython/rlib/rurandom.py b/rpython/rlib/rurandom.py
--- a/rpython/rlib/rurandom.py
+++ b/rpython/rlib/rurandom.py
@@ -6,6 +6,7 @@
 import errno
 
 from rpython.rtyper.lltypesystem import lltype, rffi
+from rpython.rlib.objectmodel import not_rpython
 
 
 if sys.platform == 'win32':
@@ -46,8 +47,9 @@
         compilation_info=eci,
         save_err=rffi.RFFI_SAVE_LASTERROR)
 
+    @not_rpython
     def init_urandom():
-        """NOT_RPYTHON
+        """
         Return an array of one HCRYPTPROV, initialized to NULL.
         It is filled automatically the first time urandom() is called.
         """
@@ -84,9 +86,8 @@
                 raise ValueError("RAND_pseudo_bytes")
             return buf.str(n)
 else:  # Posix implementation
+    @not_rpython
     def init_urandom():
-        """NOT_RPYTHON
-        """
         return None
 
     def urandom(context, n):
diff --git a/rpython/rlib/rvmprof/rvmprof.py b/rpython/rlib/rvmprof/rvmprof.py
--- a/rpython/rlib/rvmprof/rvmprof.py
+++ b/rpython/rlib/rvmprof/rvmprof.py
@@ -1,5 +1,5 @@
 import sys, os
-from rpython.rlib.objectmodel import specialize, we_are_translated
+from rpython.rlib.objectmodel import specialize, we_are_translated, not_rpython
 from rpython.rlib import jit, rposix, rgc
 from rpython.rlib.rvmprof import cintf
 from rpython.rtyper.annlowlevel import cast_instance_to_gcref
@@ -35,8 +35,9 @@
 
     use_weaklist = True # False for tests
 
+    @not_rpython
     def __init__(self):
-        "NOT_RPYTHON: use _get_vmprof()"
+        "use _get_vmprof()"
         self._code_classes = set()
         self._gather_all_code_objs = lambda: None
         self._cleanup_()
@@ -66,8 +67,9 @@
             elif self.use_weaklist:
                 code._vmprof_weak_list.add_handle(code)
 
+    @not_rpython
     def register_code_object_class(self, CodeClass, full_name_func):
-        """NOT_RPYTHON
+        """
         Register statically the class 'CodeClass' as containing user
         code objects.
 
diff --git a/rpython/rlib/streamio.py b/rpython/rlib/streamio.py
--- a/rpython/rlib/streamio.py
+++ b/rpython/rlib/streamio.py
@@ -35,7 +35,7 @@
 # return value of tell(), but not as argument to read().
 
 import os, sys, errno
-from rpython.rlib.objectmodel import specialize, we_are_translated
+from rpython.rlib.objectmodel import specialize, we_are_translated, not_rpython
 from rpython.rlib.rarithmetic import r_longlong, intmask
 from rpython.rlib import rposix, nonconst, _rsocket_rffi as _c
 from rpython.rlib.rstring import StringBuilder
@@ -394,8 +394,8 @@
 class MMapFile(Stream):
     """Standard I/O basis stream using mmap."""
 
+    @not_rpython
     def __init__(self, fd, mmapaccess):
-        """NOT_RPYTHON"""
         self.fd = fd
         self.access = mmapaccess
         self.pos = 0
@@ -1157,8 +1157,8 @@
 class DecodingInputFilter(Stream):
     """Filtering input stream that decodes an encoded file."""
 
+    @not_rpython
     def __init__(self, base, encoding="utf8", errors="strict"):
-        """NOT_RPYTHON"""
         self.base = base
         self.do_read = base.read
         self.encoding = encoding
@@ -1203,8 +1203,8 @@
 class EncodingOutputFilter(Stream):
     """Filtering output stream that writes to an encoded file."""
 
+    @not_rpython
     def __init__(self, base, encoding="utf8", errors="strict"):
-        """NOT_RPYTHON"""
         self.base = base
         self.do_write = base.write
         self.encoding = encoding


More information about the pypy-commit mailing list