Commits

Anonymous committed 18a9b67

ok

Comments (0)

Files changed (2)

pypy/module/builtin.py

         return w_character
 
 # redirecting certain things to the real builtins
-
 _b = __builtins__
 
-def compile(*args, **kwds):
-    c = _b.compile(*args, **kwds)
+def compile(*args, **kwargs):
+    import types
+    if type(_b) == types.ModuleType:
+       fun = _b.compile
+    else:
+       fun = _b['compile']
+    c = fun(*args, **kwargs)
     res = PyCode()
     res._from_code(c)
     return res
 
-compile.__doc__ = _b.compile.__doc__
+print compile("def bla(): return None", "?", "exec")

pypy/module/test/test_builtins.py

 import unittest
-from pypy.module.builtin import compile as compile
+from pypy.module.builtin import compile
 
 class TestCompile(unittest.TestCase):
    """It makes basicaly not much sense, but we want to check,
    """
 
    def test_f(self):
-      testcode = """
-def main():
-    aStr = 'hello world'
-    print len(aStr)
-                 """
-      codeobject = compile(testcode, '?', 'exec')
-      print codeobject
-      self.assertEquals(codeobject.co_name, 'main')
-
-
-
-
+      codeobject = compile("def main(): return None", '?', 'exec')
+      self.assertEquals(codeobject.co_names[0], 'main')
 
 if __name__ == '__main__':
     unittest.main()