Carl Friedrich Bolz avatar Carl Friedrich Bolz committed 7315d59

rename pypymagic -> __pypy__, step 1

Comments (0)

Files changed (29)

pypy/config/pypyoption.py

 default_modules.update(dict.fromkeys(
     ["_codecs", "gc", "_weakref", "array", "marshal", "errno",
      "math", "_sre", "_pickle_support", "operator",
-     "recparser", "symbol", "_random", "pypymagic"]))
+     "recparser", "symbol", "_random", "__pypy__"]))
 
 
 working_modules = default_modules.copy()
                    default=False,
                    requires=[("objspace.std.withtypeversion", True)]),
         BoolOption("withmethodcachecounter",
-                   "try to cache methods and provide a counter in pypymagic. "
+                   "try to cache methods and provide a counter in __pypy__. "
                    "for testing purposes only.",
                    default=False,
                    requires=[("objspace.std.withmethodcache", True)]),

pypy/doc/config/objspace.usemodules.__pypy__.txt

+Use the '__pypy__' module. 
+This module is expected to be working and is included by default.
+It contains special PyPy-specific functionality.
+For example most of the special functions described in the `object space proxies`
+document are in the module.
+
+.. _`object space proxy`: ../objspace-proxies.html

pypy/doc/config/objspace.usemodules.pypymagic.txt

-Use the 'pypymagic' module. 
-This module is expected to be working and is included by default.
-It contains special (sometimes slightly magic) PyPy-specific functionality.
-For example most of the special functions described in the `object space proxies`
-document are in the module.
-
-.. _`object space proxy`: ../objspace-proxies.html

pypy/lib/distributed/protocol.py

 """
 
 try:
-    from pypymagic import tproxy as proxy
-    from pypymagic import get_tproxy_controller
+    from __pypy__ import tproxy as proxy
+    from __pypy__ import get_tproxy_controller
 except ImportError:
     raise ImportError("Cannot work without transparent proxy functionality")
 
 3. Support inheritance and recursive types
 """
 
-from pypymagic import pypy_repr
+from __pypy__ import pypy_repr
 
 import types
 from marshal import dumps

pypy/lib/tputil.py

 the proxied object. 
 
 """
-from pypymagic import tproxy 
+from __pypy__ import tproxy 
 from types import MethodType
 
 _dummy = object()

pypy/module/__pypy__/__init__.py

+
+# Package initialisation
+from pypy.interpreter.mixedmodule import MixedModule
+
+class Module(MixedModule):
+    appleveldefs = {
+    }
+
+    interpleveldefs = {
+        'pypy_repr'             : 'interp_magic.pypy_repr',
+    }
+
+    def setup_after_space_initialization(self):
+        if not self.space.config.translating:
+            self.extra_interpdef('isfake', 'interp_magic.isfake')
+            self.extra_interpdef('interp_pdb', 'interp_magic.interp_pdb')
+        if self.space.config.objspace.std.withmethodcachecounter:
+            self.extra_interpdef('method_cache_counter',
+                                 'interp_magic.method_cache_counter')
+            self.extra_interpdef('reset_method_cache_counter',
+                                 'interp_magic.reset_method_cache_counter')
+

pypy/module/__pypy__/interp_magic.py

+from pypy.interpreter.error import OperationError
+from pypy.interpreter.gateway import ObjSpace
+from pypy.rlib.objectmodel import we_are_translated
+
+def pypy_repr(space, w_object):
+    return space.wrap('%r' % (w_object,))
+
+def isfake(space, w_obj):
+    """Return whether the argument is faked (stolen from CPython). This is
+    always False after translation."""
+    if we_are_translated():
+        return space.w_False
+    return space.wrap(bool(w_obj.typedef.fakedcpytype))
+    #return space.wrap(bool(getattr(w_obj.typedef, 'fakedcpytype', None)))
+
+def interp_pdb(space):
+    """Run an interp-level pdb.
+    This is not available in translated versions of PyPy."""
+    assert not we_are_translated()
+    import pdb
+    pdb.set_trace()
+
+def method_cache_counter(space, name):
+    """Return a tuple (method_cache_hits, method_cache_misses) for calls to
+    methods with the name."""
+    assert space.config.objspace.std.withmethodcachecounter
+    ec = space.getexecutioncontext()
+    return space.newtuple([space.newint(ec.method_cache_hits.get(name, 0)),
+                           space.newint(ec.method_cache_misses.get(name, 0)),])
+method_cache_counter.unwrap_spec = [ObjSpace, str]
+
+def reset_method_cache_counter(space):
+    """Reset the method cache counter to zero for all method names."""
+    assert space.config.objspace.std.withmethodcachecounter
+    ec = space.getexecutioncontext()
+    ec.method_cache_misses = {}
+    ec.method_cache_hits = {}
+

pypy/module/__pypy__/test/__init__.py

+#

pypy/module/__pypy__/test/test_special.py

+import py
+from pypy.conftest import gettestobjspace, option
+
+class AppTest(object):
+    def setup_class(cls):
+        if option.runappdirect:
+            py.test.skip("does not make sense on pypy-c")
+        cls.space = gettestobjspace(**{"objspace.usemodules.select": False})
+
+    def test__isfake(self):
+        from __pypy__ import isfake
+        assert not isfake(map)
+        assert not isfake(object)
+        assert not isfake(isfake)
+
+    def test__isfake_currently_true(self):
+        from __pypy__ import isfake
+        import select
+        assert isfake(select)

pypy/module/pypymagic/__init__.py

-
-# Package initialisation
-from pypy.interpreter.mixedmodule import MixedModule
-
-class Module(MixedModule):
-    appleveldefs = {
-    }
-
-    interpleveldefs = {
-        'pypy_repr'             : 'interp_magic.pypy_repr',
-    }
-
-    def setup_after_space_initialization(self):
-        if not self.space.config.translating:
-            self.extra_interpdef('isfake', 'interp_magic.isfake')
-            self.extra_interpdef('interp_pdb', 'interp_magic.interp_pdb')
-        if self.space.config.objspace.std.withmethodcachecounter:
-            self.extra_interpdef('method_cache_counter',
-                                 'interp_magic.method_cache_counter')
-            self.extra_interpdef('reset_method_cache_counter',
-                                 'interp_magic.reset_method_cache_counter')
-

pypy/module/pypymagic/interp_magic.py

-from pypy.interpreter.error import OperationError
-from pypy.interpreter.gateway import ObjSpace
-from pypy.rlib.objectmodel import we_are_translated
-
-def pypy_repr(space, w_object):
-    return space.wrap('%r' % (w_object,))
-
-def isfake(space, w_obj):
-    """Return whether the argument is faked (stolen from CPython). This is
-    always False after translation."""
-    if we_are_translated():
-        return space.w_False
-    return space.wrap(bool(w_obj.typedef.fakedcpytype))
-    #return space.wrap(bool(getattr(w_obj.typedef, 'fakedcpytype', None)))
-
-def interp_pdb(space):
-    """Run an interp-level pdb.
-    This is not available in translated versions of PyPy."""
-    assert not we_are_translated()
-    import pdb
-    pdb.set_trace()
-
-def method_cache_counter(space, name):
-    """Return a tuple (method_cache_hits, method_cache_misses) for calls to
-    methods with the name."""
-    assert space.config.objspace.std.withmethodcachecounter
-    ec = space.getexecutioncontext()
-    return space.newtuple([space.newint(ec.method_cache_hits.get(name, 0)),
-                           space.newint(ec.method_cache_misses.get(name, 0)),])
-method_cache_counter.unwrap_spec = [ObjSpace, str]
-
-def reset_method_cache_counter(space):
-    """Reset the method cache counter to zero for all method names."""
-    assert space.config.objspace.std.withmethodcachecounter
-    ec = space.getexecutioncontext()
-    ec.method_cache_misses = {}
-    ec.method_cache_hits = {}
-

pypy/module/pypymagic/test/__init__.py

-#

pypy/module/pypymagic/test/test_special.py

-import py
-from pypy.conftest import gettestobjspace, option
-
-class AppTest(object):
-    def setup_class(cls):
-        if option.runappdirect:
-            py.test.skip("does not make sense on pypy-c")
-        cls.space = gettestobjspace(**{"objspace.usemodules.select": False})
-
-    def test__isfake(self):
-        from pypymagic import isfake
-        assert not isfake(map)
-        assert not isfake(object)
-        assert not isfake(isfake)
-
-    def test__isfake_currently_true(self):
-        from pypymagic import isfake
-        import select
-        assert isfake(select)

pypy/module/rsocket/test/test_sock_app.py

         import errno
         try:
             s = socket(AF_INET, SOCK_STREAM)
-            import pypymagic
-            print pypymagic.pypy_repr(s)
+            import __pypy__
+            print __pypy__.pypy_repr(s)
             s.accept()
         except Exception, e:
             assert len(e.args) == 2

pypy/objspace/std/benchmark/bench_dict.py

 
 if __name__ == '__main__':
     test_d = bench_simple_dict()
-    import pypymagic
-    print pypymagic.pypy_repr(test_d)
-    print pypymagic.pypy_repr(test_d.iterkeys())
+    import __pypy__
+    print __pypy__.pypy_repr(test_d)
+    print __pypy__.pypy_repr(test_d.iterkeys())

pypy/objspace/std/objspace.py

         self.setup_builtin_modules()
         # Adding transparent proxy call
         if self.config.objspace.std.withtproxy:
-            w_pypymagic = self.getbuiltinmodule("pypymagic")
+            w___pypy__ = self.getbuiltinmodule("__pypy__")
             from pypy.objspace.std.transparent import app_proxy, app_proxy_controller
         
-            self.setattr(w_pypymagic, self.wrap('tproxy'),
+            self.setattr(w___pypy__, self.wrap('tproxy'),
                           self.wrap(app_proxy))
-            self.setattr(w_pypymagic, self.wrap('get_tproxy_controller'),
+            self.setattr(w___pypy__, self.wrap('get_tproxy_controller'),
                           self.wrap(app_proxy_controller))
 
     def enable_old_style_classes_as_default_metaclass(self):

pypy/objspace/std/test/test_listmultiobject.py

         assert l2 == range(1, 19, 2)
 
     def test_strlist_literal(self):
-        import pypymagic
+        import __pypy__
         l = ["1", "2", "3", "4", "5"]
-        assert "StrListImplementation" in pypymagic.pypy_repr(l)
+        assert "StrListImplementation" in __pypy__.pypy_repr(l)
 
     def test_strlist_delitem(self):
         l = ["1", "2"]
         assert l == ["2"]
 
     def test_strlist_append(self):
-        import pypymagic
+        import __pypy__
         l = []
         l.append("a")
-        assert "StrListImplementation" in pypymagic.pypy_repr(l)
+        assert "StrListImplementation" in __pypy__.pypy_repr(l)
         l.extend(["b", "c", "d"])
         l += ["e", "f"]
         assert l == ["a", "b", "c", "d", "e", "f"]
-        assert "StrListImplementation" in pypymagic.pypy_repr(l)
+        assert "StrListImplementation" in __pypy__.pypy_repr(l)
 
 class AppTestRangeImplementation(AppTestRangeListObject):
 
     def setup_class(cls):
         cls.space = gettestobjspace(**{"objspace.std.withmultilist": True})
         cls.w_not_forced = cls.space.appexec([], """():
-            import pypymagic
+            import __pypy__
             def f(r):
                 return (isinstance(r, list) and
-                        "RangeImplementation" in pypymagic.pypy_repr(r))
+                        "RangeImplementation" in __pypy__.pypy_repr(r))
             return f
         """)
 
         cls.space = gettestobjspace(**{"objspace.std.withfastslice": True})
 
     def test_lazy_slice(self):
-        import pypymagic
+        import __pypy__
         l = [i for i in range(100)] # force it to not be a range impl
         l2 = l[1:-1]
-        assert "SliceTrackingListImplementation" in pypymagic.pypy_repr(l)
-        assert "SliceListImplementation" in pypymagic.pypy_repr(l2)
+        assert "SliceTrackingListImplementation" in __pypy__.pypy_repr(l)
+        assert "SliceListImplementation" in __pypy__.pypy_repr(l2)
         result = 0
         for i in l2:
             result += i
         # didn't force l2
-        assert "SliceListImplementation" in pypymagic.pypy_repr(l2)
+        assert "SliceListImplementation" in __pypy__.pypy_repr(l2)
         # force l2:
         l2.append(10)
         assert l2 == range(1, 99) + [10]
 
     def test_append_extend_dont_force(self):
-        import pypymagic
+        import __pypy__
         l = [i for i in range(100)] # force it to not be a range impl
         l2 = l[1:-1]
-        assert "SliceTrackingListImplementation" in pypymagic.pypy_repr(l)
-        assert "SliceListImplementation" in pypymagic.pypy_repr(l2)
+        assert "SliceTrackingListImplementation" in __pypy__.pypy_repr(l)
+        assert "SliceListImplementation" in __pypy__.pypy_repr(l2)
         l.append(100)
         l.extend(range(101, 110))
         assert l == range(110)
-        assert "SliceTrackingListImplementation" in pypymagic.pypy_repr(l)
-        assert "SliceListImplementation" in pypymagic.pypy_repr(l2)
+        assert "SliceTrackingListImplementation" in __pypy__.pypy_repr(l)
+        assert "SliceListImplementation" in __pypy__.pypy_repr(l2)
 
     def test_slice_of_slice(self):
-        import pypymagic
+        import __pypy__
         l = [i for i in range(100)] # force it to not be a range impl
         l2 = l[1:-1]
         l3 = l2[1:-1]
         assert l2 == range(1, 99)
         assert l3 == range(2, 98)
         assert l4 == range(3, 97)
-        assert "SliceListImplementation" in pypymagic.pypy_repr(l4)
+        assert "SliceListImplementation" in __pypy__.pypy_repr(l4)
         l2[3] = 4
-        assert "SliceListImplementation" not in pypymagic.pypy_repr(l2)
-        assert "SliceListImplementation" in pypymagic.pypy_repr(l4)
+        assert "SliceListImplementation" not in __pypy__.pypy_repr(l2)
+        assert "SliceListImplementation" in __pypy__.pypy_repr(l4)
 
     def test_delitem_to_empty(self):
-        import pypymagic
+        import __pypy__
         l = [i for i in range(100)] # force it to not be a range impl
         l1 = l[1:-1]
         del l1[:]
-        assert "EmptyListImplementation" in pypymagic.pypy_repr(l1)
+        assert "EmptyListImplementation" in __pypy__.pypy_repr(l1)
 
 class TestSliceListImplementation(object):
     def setup_method(self,method):

pypy/objspace/std/test/test_proxy.py

         return Controller
         """)
         self.w_proxy = self.space.appexec([], """():
-        from pypymagic import tproxy
+        from __pypy__ import tproxy
         return tproxy
         """)
 

pypy/objspace/std/test/test_proxy_function.py

                 return getattr(self.obj, name)(*args, **kwargs)
         def get_proxy(f):
             import types
-            from pypymagic import tproxy as proxy
+            from __pypy__ import tproxy as proxy
             return proxy(types.FunctionType, Controller(f).perform)
         return get_proxy
         """)
         class AA:
             pass
         
-        from pypymagic import tproxy as proxy
+        from __pypy__ import tproxy as proxy
         a = A()
         class X:
             def __init__(self, x):

pypy/objspace/std/test/test_proxy_internals.py

             def perform(self, name, *args, **kwargs):
                 return getattr(self.obj, name)(*args, **kwargs)
         def get_proxy(f):
-            from pypymagic import tproxy as proxy
+            from __pypy__ import tproxy as proxy
             return proxy(type(f), Controller(f).perform)
         return get_proxy
         """)
         import traceback
         
         def get_proxy(f):
-            from pypymagic import tproxy as proxy
+            from __pypy__ import tproxy as proxy
             return proxy(type(f), Controller(f).perform)
         
         class FakeTb(object):
         assert traceback.format_tb(last_tb) == traceback.format_tb(e[2])
     
     def test_proxy_get(self):
-        from pypymagic import tproxy, get_tproxy_controller
+        from __pypy__ import tproxy, get_tproxy_controller
         l = [1,2,3]
         def f(name, *args, **kwargs):
             return getattr(l, name)(*args, **kwargs)

pypy/objspace/std/test/test_proxy_object.py

         return A
         """)
         self.w_proxy = self.space.appexec([], """():
-        from pypymagic import tproxy
+        from __pypy__ import tproxy
         return tproxy
         """)
     
         return A
         """)
         self.w_proxy = self.space.appexec([], """():
-        from pypymagic import tproxy
+        from __pypy__ import tproxy
         return tproxy
         """)
 

pypy/objspace/std/test/test_rangeobject.py

     def setup_class(cls):
         cls.space = gettestobjspace(**{"objspace.std.withrangelist": True})
         cls.w_not_forced = cls.space.appexec([], """():
-            import pypymagic
+            import __pypy__
             def f(r):
                 return (isinstance(r, list) and
-                        "W_ListObject" not in pypymagic.pypy_repr(r))
+                        "W_ListObject" not in __pypy__.pypy_repr(r))
             return f
         """)
 

pypy/objspace/std/test/test_shadowtracking.py

             **{"objspace.std.withmethodcachecounter": True})
 
     def test_mix_classes(self):
-        import pypymagic
+        import __pypy__
         class A(object):
             def f(self):
                 return 42
             def f(self):
                 return 44
         l = [A(), B(), C()] * 10
-        pypymagic.reset_method_cache_counter()
+        __pypy__.reset_method_cache_counter()
         for i, a in enumerate(l):
             assert a.f() == 42 + i % 3
-        cache_counter = pypymagic.method_cache_counter("f")
+        cache_counter = __pypy__.method_cache_counter("f")
         assert cache_counter[0] >= 15
         assert cache_counter[1] >= 3 # should be (27, 3)
         assert sum(cache_counter) == 30
 
     def test_class_that_cannot_be_cached(self):
-        import pypymagic
+        import __pypy__
         class metatype(type):
             pass
         class A(object):
             def f(self):
                 return 44
         l = [A(), B(), C()] * 10
-        pypymagic.reset_method_cache_counter()
+        __pypy__.reset_method_cache_counter()
         for i, a in enumerate(l):
             assert a.f() == 42 + i % 3
-        cache_counter = pypymagic.method_cache_counter("f")
+        cache_counter = __pypy__.method_cache_counter("f")
         assert cache_counter[0] >= 9
         assert cache_counter[1] >= 2 # should be (18, 2)
         assert sum(cache_counter) == 20
  
     def test_change_methods(self):
-        import pypymagic
+        import __pypy__
         class A(object):
             def f(self):
                 return 42
         l = [A()] * 10
-        pypymagic.reset_method_cache_counter()
+        __pypy__.reset_method_cache_counter()
         for i, a in enumerate(l):
             assert a.f() == 42 + i
             A.f = eval("lambda self: %s" % (42 + i + 1, ))
-        cache_counter = pypymagic.method_cache_counter("f")
+        cache_counter = __pypy__.method_cache_counter("f")
         assert cache_counter == (0, 10)
 
     def test_subclasses(self):
-        import pypymagic
+        import __pypy__
         class A(object):
             def f(self):
                 return 42
         class C(A):
             pass
         l = [A(), B(), C()] * 10
-        pypymagic.reset_method_cache_counter()
+        __pypy__.reset_method_cache_counter()
         for i, a in enumerate(l):
             assert a.f() == 42 + (i % 3 == 1)
-        cache_counter = pypymagic.method_cache_counter("f")
+        cache_counter = __pypy__.method_cache_counter("f")
         assert cache_counter[0] >= 15
         assert cache_counter[1] >= 3 # should be (27, 3)
         assert sum(cache_counter) == 30
   
     def test_many_names(self):
-        import pypymagic
+        import __pypy__
         class A(object):
             foo = 5
             bar = 6
                       if not name.startswith('_')]
         names_repeated = names * 10
         result = []
-        pypymagic.reset_method_cache_counter()
+        __pypy__.reset_method_cache_counter()
         for name in names_repeated:
             result.append(getattr(a, name))
-        append_counter = pypymagic.method_cache_counter("append")
-        names_counters = [pypymagic.method_cache_counter(name)
+        append_counter = __pypy__.method_cache_counter("append")
+        names_counters = [__pypy__.method_cache_counter(name)
                           for name in names]
         assert append_counter[0] >= 5 * len(names)
         for name, count in zip(names, names_counters):

pypy/objspace/std/test/test_strjoinobject.py

         cls.space = gettestobjspace(**{"objspace.std.withstrjoin": True})
 
     def test_basic(self):
-        import pypymagic
+        import __pypy__
         s = "Hello, " + "World!"
         assert type(s) is str
-        assert 'W_StringJoinObject' in pypymagic.pypy_repr(s)
+        assert 'W_StringJoinObject' in __pypy__.pypy_repr(s)
 
     def test_add_twice(self):
         x = "a" + ""
         assert c == "ab"
 
     def test_add(self):
-        import pypymagic
+        import __pypy__
         all = ""
         for i in range(20):
             all += str(i)
-        assert 'W_StringJoinObject' in pypymagic.pypy_repr(all)
+        assert 'W_StringJoinObject' in __pypy__.pypy_repr(all)
 
     def test_hash(self):
-        import pypymagic
+        import __pypy__
         # check that we have the same hash as CPython for at least 31 bits
         # (but don't go checking CPython's special case -1)
         # disabled: assert hash('') == 0 --- different special case
         def join(s): return s[:len(s) // 2] + s[len(s) // 2:]
         s = join('a' * 101)
-        assert 'W_StringJoinObject' in pypymagic.pypy_repr(s)
+        assert 'W_StringJoinObject' in __pypy__.pypy_repr(s)
         assert hash(s) & 0x7fffffff == 0x7e0bce58
 
     def test_len(self):

pypy/objspace/std/test/test_strsliceobject.py

         cls.w_not_forced = cls.space.wrap(gateway.interp2app(not_forced))
 
     def test_basic(self):
-        import pypymagic
+        import __pypy__
         def slice(s): return (s*3)[len(s):-len(s)]
         s = slice('0123456789' * 20)
         assert len(s) == 200
         assert s[5] == '5'
         assert s[-2] == '8'
         assert s[3:7] == '3456'
-        assert 'W_StringSliceObject' in pypymagic.pypy_repr(s)
+        assert 'W_StringSliceObject' in __pypy__.pypy_repr(s)
         # when the slice is too short, don't use the slice string object
-        assert 'W_StringObject' in pypymagic.pypy_repr("abcdefgh"[3:7])
+        assert 'W_StringObject' in __pypy__.pypy_repr("abcdefgh"[3:7])
         s2 = s.upper()
         assert not self.not_forced(s)
 
     def test_find(self):
-        import pypymagic
+        import __pypy__
         def slice(s): return (s*3)[len(s):-len(s)]
         s = slice('abcdefghiabc' + "X" * 100)
-        assert 'W_StringSliceObject' in pypymagic.pypy_repr(s)
+        assert 'W_StringSliceObject' in __pypy__.pypy_repr(s)
         assert slice('abcdefghiabc' + 'X' * 100) == 'abcdefghiabc' + 'X' * 100
         res = s.find('abc')
         assert res == 0
         assert s.find('def', 4) == -1
 
     def test_index(self):
-        import pypymagic, sys
+        import __pypy__, sys
         m = sys.maxint
         def slice(s): return (s*3)[len(s):-len(s)]
         s = slice('abcdefghiabc' * 20)
-        assert 'W_StringSliceObject' in pypymagic.pypy_repr(s)
+        assert 'W_StringSliceObject' in __pypy__.pypy_repr(s)
         assert s.index('') == 0
         assert s.index('def') == 3
         assert s.index('abc') == 0
         raises(TypeError, slice('abcdefghijklmn' * 20).index, 'abc', -10.0, 30)
 
     def test_rfind(self):
-        import pypymagic
+        import __pypy__
         def slice(s): return (s*3)[len(s):-len(s)]
         s = slice('abcdefghiabc' + "X" * 100)
-        assert 'W_StringSliceObject' in pypymagic.pypy_repr(s)
+        assert 'W_StringSliceObject' in __pypy__.pypy_repr(s)
         assert s.rfind('abc') == 9
         assert s.rfind('') == 112
         assert s.rfind('abcd') == 0
         assert s.rfind('abcz') == -1
 
     def test_rindex(self):
-        import pypymagic
+        import __pypy__
         from sys import maxint
         def slice(s): return (s*3)[len(s):-len(s)]
         s = slice("X" * 100 + 'abcdefghiabc')
-        assert 'W_StringSliceObject' in pypymagic.pypy_repr(s)
+        assert 'W_StringSliceObject' in __pypy__.pypy_repr(s)
         assert s.rindex('') == 112
         assert s.rindex('def') == 103
         assert s.rindex('abc') == 109
                'abc', -10.0, 30)
 
     def test_contains(self):
-        import pypymagic
+        import __pypy__
         def slice(s): return (s*3)[len(s):-len(s)]
         s = slice("abc" + "X" * 100)
-        assert 'W_StringSliceObject' in pypymagic.pypy_repr(s)
+        assert 'W_StringSliceObject' in __pypy__.pypy_repr(s)
         assert '' in s
         assert 'a' in s
         assert 'ab' in s
         raises(TypeError, slice('a' * 100).__contains__, 1)
         
     def test_hash(self):
-        import pypymagic
+        import __pypy__
         # check that we have the same hash as CPython for at least 31 bits
         # (but don't go checking CPython's special case -1)
         # disabled: assert hash('') == 0 --- different special case
         def slice(s): return (s*3)[len(s):-len(s)]
         s = slice('a' * 101)
-        assert 'W_StringSliceObject' in pypymagic.pypy_repr(s)
+        assert 'W_StringSliceObject' in __pypy__.pypy_repr(s)
         assert hash(s) & 0x7fffffff == 0x7e0bce58
 
     def test_split_produces_strslices(self):
-        import pypymagic
+        import __pypy__
         l = ("X" * 100 + "," + "Y" * 100).split(",")
-        assert "W_StringSliceObject" in pypymagic.pypy_repr(l[0])
-        assert "W_StringSliceObject" in pypymagic.pypy_repr(l[1])
+        assert "W_StringSliceObject" in __pypy__.pypy_repr(l[0])
+        assert "W_StringSliceObject" in __pypy__.pypy_repr(l[1])
 
     def test_strip_produces_strslices(self):
-        import pypymagic
+        import __pypy__
         s = ("abc" + "X" * 100 + "," + "Y" * 100 + "abc").strip("abc")
-        assert "W_StringSliceObject" in pypymagic.pypy_repr(s)
+        assert "W_StringSliceObject" in __pypy__.pypy_repr(s)
 
     def test_splitlines_produces_strslices(self):
-        import pypymagic
+        import __pypy__
         l = ("X" * 100 + "\n" + "Y" * 100).splitlines()
-        assert "W_StringSliceObject" in pypymagic.pypy_repr(l[0])
-        assert "W_StringSliceObject" in pypymagic.pypy_repr(l[1])
+        assert "W_StringSliceObject" in __pypy__.pypy_repr(l[0])
+        assert "W_StringSliceObject" in __pypy__.pypy_repr(l[1])
 
     def test_count_does_not_force(self):
         def slice(s): return (s*3)[len(s):-len(s)]

pypy/objspace/taint.py

             self.newtuple([self.w_Exception]),
             w_dict
             )
-        w_pypymagic = self.getbuiltinmodule("pypymagic")
-        self.setattr(w_pypymagic, self.wrap('taint'),
+        w___pypy__ = self.getbuiltinmodule("__pypy__")
+        self.setattr(w___pypy__, self.wrap('taint'),
                      self.wrap(app_taint))
-        self.setattr(w_pypymagic, self.wrap('is_tainted'),
+        self.setattr(w___pypy__, self.wrap('is_tainted'),
                      self.wrap(app_is_tainted))
-        self.setattr(w_pypymagic, self.wrap('untaint'),
+        self.setattr(w___pypy__, self.wrap('untaint'),
                      self.wrap(app_untaint))
         self.w_fn_taint_atomic_function = self.wrap(app_taint_atomic_function)
-        self.setattr(w_pypymagic, self.wrap('taint_atomic'),
+        self.setattr(w___pypy__, self.wrap('taint_atomic'),
                      self.wrap(app_taint_atomic))
-        self.setattr(w_pypymagic, self.wrap('TaintError'),
+        self.setattr(w___pypy__, self.wrap('TaintError'),
                      self.w_TaintError)
-        self.setattr(w_pypymagic, self.wrap('_taint_debug'),
+        self.setattr(w___pypy__, self.wrap('_taint_debug'),
                      self.wrap(app_taint_debug))
-        self.setattr(w_pypymagic, self.wrap('_taint_look'),
+        self.setattr(w___pypy__, self.wrap('_taint_look'),
                      self.wrap(app_taint_look))
         patch_space_in_place(self, 'taint', proxymaker)
 

pypy/objspace/test/test_taintobjspace.py

         cls.space = gettestobjspace('taint')
 
     def test_simple(self):
-        from pypymagic import taint, untaint, TaintError
+        from __pypy__ import taint, untaint, TaintError
         x = taint(6)
         x = x * 7
         raises(TaintError, "if x: y = 1")
         raises(TaintError, "untaint(float, x)")
 
     def test_bomb(self):
-        from pypymagic import taint, untaint, TaintError
+        from __pypy__ import taint, untaint, TaintError
         x = taint(6)
         x = x / 0
         raises(TaintError, "if x: y = 1")
         raises(TaintError, "untaint(float, x)")
 
     def test_taint_atomic(self):
-        from pypymagic import taint, untaint, TaintError, taint_atomic
+        from __pypy__ import taint, untaint, TaintError, taint_atomic
         x = taint(6)
         x *= 7
 
         assert untaint(int, y) == 5
 
     def test_taint_atomic_exception(self):
-        from pypymagic import taint, untaint, TaintError, taint_atomic
+        from __pypy__ import taint, untaint, TaintError, taint_atomic
         x = taint(6)
         x *= 7
 
         raises(TaintError, "untaint(int, y)")
 
     def test_taint_atomic_incoming_bomb(self):
-        from pypymagic import taint, untaint, TaintError, taint_atomic
+        from __pypy__ import taint, untaint, TaintError, taint_atomic
         x = taint(6)
         x /= 0
         lst = []

pypy/objspace/test/test_thunkobjspace.py

         cls.space = gettestobjspace('thunk')
 
     def test_simple(self):
-        from pypymagic import thunk, become
+        from __pypy__ import thunk, become
         computed = []
         def f():
             computed.append(True)
         assert computed == [True]
 
     def test_setitem(self):
-        from pypymagic import thunk, become
+        from __pypy__ import thunk, become
         computed = []
         def f(a):
             computed.append(True)
         assert d[7] == [43]
 
     def test_become(self):
-        from pypymagic import thunk, become
+        from __pypy__ import thunk, become
         x = []
         y = []
         assert x is not y
         assert x is y
 
     def test_id(self):
-        from pypymagic import thunk, become
+        from __pypy__ import thunk, become
         # these are the Smalltalk semantics of become().
         x = []; idx = id(x)
         y = []; idy = id(y)
         assert id(x) == id(y) == idy
 
     def test_double_become(self):
-        from pypymagic import thunk, become
+        from __pypy__ import thunk, become
         x = []
         y = []
         z = []
         assert x is y is z
 
     def test_thunk_forcing_while_forcing(self):
-        from pypymagic import thunk, become
+        from __pypy__ import thunk, become
         def f():
             return x+1
         x = thunk(f)
         raises(RuntimeError, 'x+1')
 
     def INPROGRESS_test_thunk_forcing_while_forcing_2(self):
-        from pypymagic import thunk, become
+        from __pypy__ import thunk, become
         def f():
             return x
         x = thunk(f)
         raises(RuntimeError, 'x+1')
 
     def test_is_thunk(self):
-        from pypymagic import thunk, become, is_thunk
+        from __pypy__ import thunk, become, is_thunk
         def f():
             pass
         assert is_thunk(thunk(f))
         assert not is_thunk(42)
 
     def test_lazy(self):
-        from pypymagic import lazy
+        from __pypy__ import lazy
         lst = []
         def f(x):
             lst.append(x)

pypy/objspace/thunk.py

 """Example usage:
 
     $ py.py -o thunk
-    >>> from pypymagic import thunk, lazy, become
+    >>> from __pypy__ import thunk, lazy, become
     >>> def f():
     ...     print 'computing...'
     ...     return 6*7
     from pypy.objspace import std
     space = std.Space(*args, **kwds)
     patch_space_in_place(space, 'thunk', proxymaker)
-    w_pypymagic = space.getbuiltinmodule("pypymagic")
+    w___pypy__ = space.getbuiltinmodule("__pypy__")
     space.w_fn_thunk = space.wrap(app_thunk)
-    space.setattr(w_pypymagic, space.wrap('thunk'),
+    space.setattr(w___pypy__, space.wrap('thunk'),
                   space.w_fn_thunk)
-    space.setattr(w_pypymagic, space.wrap('is_thunk'),
+    space.setattr(w___pypy__, space.wrap('is_thunk'),
                   space.wrap(app_is_thunk))
-    space.setattr(w_pypymagic, space.wrap('become'),
+    space.setattr(w___pypy__, space.wrap('become'),
                  space.wrap(app_become))
-    space.setattr(w_pypymagic, space.wrap('lazy'),
+    space.setattr(w___pypy__, space.wrap('lazy'),
                  space.wrap(app_lazy))
     return space
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.