Author: Alex Gaynor <[email protected]>
Branch: inline-virtualref
Changeset: r60368:36fae7dd9821
Date: 2013-01-23 05:12 -0800
http://bitbucket.org/pypy/pypy/changeset/36fae7dd9821/

Log:    merged default in

diff --git a/lib-python/conftest.py b/lib-python/conftest.py
--- a/lib-python/conftest.py
+++ b/lib-python/conftest.py
@@ -17,8 +17,8 @@
 from pypy.conftest import option as pypy_option 
 
 from pypy.tool.pytest import appsupport 
-from pypy.tool.pytest.confpath import pypydir, testdir, testresultdir
-from pypy.config.parse import parse_info
+from pypy.tool.pytest.confpath import pypydir, rpythondir, testdir, 
testresultdir
+from rpython.config.parse import parse_info
 
 pytest_plugins = "resultlog",
 rsyncdirs = ['.', '../pypy/']
@@ -40,7 +40,7 @@
                     dest="unittest_filter",  help="Similar to -k, XXX")
 
 def gettimeout(timeout): 
-    from test import pystone
+    from rpython.translator.test import rpystone
     if timeout.endswith('mp'): 
         megapystone = float(timeout[:-2])
         t, stone = pystone.Proc0(10000)
@@ -584,7 +584,7 @@
             watchdog_name = 'watchdog_nt.py'
         else:
             watchdog_name = 'watchdog.py'
-        watchdog_script = pypydir.join('tool', watchdog_name)
+        watchdog_script = rpythondir.join('tool', watchdog_name)
 
         regr_script = pypydir.join('tool', 'pytest', 
                                    'run-script', 'regrverbose.py')
diff --git a/pypy/doc/arm.rst b/pypy/doc/arm.rst
--- a/pypy/doc/arm.rst
+++ b/pypy/doc/arm.rst
@@ -130,15 +130,7 @@
   export SB2=/srv/chroot/precise_arm
   export SB2OPT='-t ARM'
 
-Once this is set, you can call the translator 
-
-::
-
-  pypy ~/path_to_pypy_checkout/pypy/translator/goal/translate.py -O1 
--platform=arm target.py
-
-If everything worked correctly this should yield an ARM binary. Running this 
binary in the ARM chroot or on an ARM device should produce the output ``"Hello 
World"``.
-
-.. _`this`:
+Once this is set, you can call the translator. For example save this file 
 
 ::
 
@@ -148,3 +140,22 @@
 
   def target(*args):
       return main, None
+
+and call the translator
+
+::
+
+  pypy ~/path_to_pypy_checkout/pypy/translator/goal/translate.py -O1 
--platform=arm target.py
+
+If everything worked correctly this should yield an ARM binary. Running this 
binary in the ARM chroot or on an ARM device should produce the output ``"Hello 
World"``.
+
+To translate the full python pypy interpreter with a jit, you can cd into 
pypy/goal and call      
+
+::
+
+  pypy <path to rpython>/rpython/translator/goal/translate.py -Ojit 
--platform=arm --gcrootfinder=shadowstack --jit-backend=arm 
targetpypystandalone.py
+
+The gcrootfinder option is needed to work around `issue 1377`_ and the 
jit-backend works around `issue 1376`_
+
+.. _`issue 1377`: https://bugs.pypy.org/issue1377
+.. _`issue 1376`: https://bugs.pypy.org/issue1376
diff --git a/pypy/goal/__init__.py b/pypy/goal/__init__.py
new file mode 100644
--- /dev/null
+++ b/pypy/goal/__init__.py
@@ -0,0 +1,1 @@
+#empty
diff --git a/pypy/interpreter/astcompiler/codegen.py 
b/pypy/interpreter/astcompiler/codegen.py
--- a/pypy/interpreter/astcompiler/codegen.py
+++ b/pypy/interpreter/astcompiler/codegen.py
@@ -904,8 +904,9 @@
 
     def visit_Set(self, s):
         self.update_position(s.lineno)
+        elt_count = len(s.elts) if s.elts is not None else 0
         self.visit_sequence(s.elts)
-        self.emit_op_arg(ops.BUILD_SET, len(s.elts))
+        self.emit_op_arg(ops.BUILD_SET, elt_count)
 
     def visit_Name(self, name):
         self.update_position(name.lineno)
diff --git a/pypy/interpreter/test2/test_app_main.py 
b/pypy/interpreter/test2/test_app_main.py
--- a/pypy/interpreter/test2/test_app_main.py
+++ b/pypy/interpreter/test2/test_app_main.py
@@ -84,7 +84,7 @@
 
     def check(self, argv, **expected):
         import StringIO
-        from rpython.translator.goal import app_main
+        from pypy.interpreter import app_main
         saved_sys_argv = sys.argv[:]
         saved_sys_stdout = sys.stdout
         saved_sys_stderr = sys.stdout
@@ -825,7 +825,7 @@
 class TestAppMain:
     
     def test_print_info(self):
-        from rpython.translator.goal import app_main
+        from pypy.interpreter import app_main
         import sys, cStringIO
         prev_so = sys.stdout
         prev_ti = getattr(sys, 'pypy_translation_info', 'missing')
diff --git a/pypy/interpreter/test2/test_targetpypy.py 
b/pypy/interpreter/test2/test_targetpypy.py
--- a/pypy/interpreter/test2/test_targetpypy.py
+++ b/pypy/interpreter/test2/test_targetpypy.py
@@ -1,6 +1,6 @@
 
 import py
-from goal.targetpypystandalone import get_entry_point
+from pypy.goal.targetpypystandalone import get_entry_point
 from pypy.config.pypyoption import get_pypy_config
 
 class TestTargetPyPy(object):
diff --git a/pypy/module/_ast/test/test_ast.py 
b/pypy/module/_ast/test/test_ast.py
--- a/pypy/module/_ast/test/test_ast.py
+++ b/pypy/module/_ast/test/test_ast.py
@@ -290,6 +290,12 @@
         ])
         exec compile(body, '<string>', 'exec')
 
+    def test_empty_set(self):
+        import ast
+        m = ast.Module(body=[ast.Expr(value=ast.Set(elts=[]))])
+        ast.fix_missing_locations(m)
+        compile(m, "<test>", "exec")
+
     def test_invalid_sum(self):
         import _ast as ast
         pos = dict(lineno=2, col_offset=3)
diff --git a/pypy/module/cpyext/classobject.py 
b/pypy/module/cpyext/classobject.py
--- a/pypy/module/cpyext/classobject.py
+++ b/pypy/module/cpyext/classobject.py
@@ -22,6 +22,12 @@
         w_result.setdict(space, w_dict)
     return w_result
 
+@cpython_api([PyObject, PyObject, PyObject], PyObject)
+def PyInstance_New(space, w_cls, w_arg, w_kw):
+    """Create a new instance of a specific class.  The parameters arg and kw 
are
+    used as the positional and keyword parameters to the object's 
constructor."""
+    return space.call(w_cls, w_arg, w_kw)
+
 @cpython_api([PyObject, PyObject], PyObject, error=CANNOT_FAIL)
 def _PyInstance_Lookup(space, w_instance, w_name):
     name = space.str_w(w_name)
diff --git a/pypy/module/cpyext/include/ceval.h 
b/pypy/module/cpyext/include/ceval.h
new file mode 100644
--- /dev/null
+++ b/pypy/module/cpyext/include/ceval.h
@@ -0,0 +1,1 @@
+/* empty */
diff --git a/pypy/module/cpyext/stubs.py b/pypy/module/cpyext/stubs.py
--- a/pypy/module/cpyext/stubs.py
+++ b/pypy/module/cpyext/stubs.py
@@ -176,12 +176,6 @@
     """Return true if klass is a subclass of base. Return false in all other 
cases."""
     raise NotImplementedError
 
-@cpython_api([PyObject, PyObject, PyObject], PyObject)
-def PyInstance_New(space, cls, arg, kw):
-    """Create a new instance of a specific class.  The parameters arg and kw 
are
-    used as the positional and keyword parameters to the object's 
constructor."""
-    raise NotImplementedError
-
 @cpython_api([PyObject], rffi.INT_real, error=-1)
 def PyCodec_Register(space, search_function):
     """Register a new codec search function.
diff --git a/pypy/module/cpyext/test/conftest.py 
b/pypy/module/cpyext/test/conftest.py
--- a/pypy/module/cpyext/test/conftest.py
+++ b/pypy/module/cpyext/test/conftest.py
@@ -1,6 +1,15 @@
 import py
 import pytest
 
+def pytest_configure(config):
+    from pypy.tool.pytest.objspace import gettestobjspace
+    # For some reason (probably a ll2ctypes cache issue on linux64)
+    # it's necessary to run "import time" at least once before any
+    # other cpyext test, otherwise the same statement will fail in
+    # test_datetime.py.
+    space = gettestobjspace(usemodules=['rctime'])
+    space.getbuiltinmodule("time")
+
 def pytest_ignore_collect(path, config):
     if config.option.runappdirect:
         return True # "cannot be run by py.test -A"
diff --git a/pypy/module/cpyext/test/test_classobject.py 
b/pypy/module/cpyext/test/test_classobject.py
--- a/pypy/module/cpyext/test/test_classobject.py
+++ b/pypy/module/cpyext/test/test_classobject.py
@@ -7,8 +7,10 @@
         w_class = space.appexec([], """():
             class C:
                 x = None
-                def __init__(self):
+                def __init__(self, *args, **kwargs):
                     self.x = 1
+                    self.args = args
+                    self.__dict__.update(kwargs)
             return C
         """)
 
@@ -22,6 +24,13 @@
         assert space.getattr(w_instance, space.wrap('x')) is space.w_None
         assert space.unwrap(space.getattr(w_instance, space.wrap('a'))) == 3
 
+        w_instance = api.PyInstance_New(w_class,
+                                        space.wrap((3,)), 
space.wrap(dict(y=2)))
+        assert space.unwrap(space.getattr(w_instance, space.wrap('x'))) == 1
+        assert space.unwrap(space.getattr(w_instance, space.wrap('y'))) == 2
+        assert space.unwrap(space.getattr(w_instance, space.wrap('args'))) == 
(3,)
+        
+
     def test_lookup(self, space, api):
         w_instance = space.appexec([], """():
             class C:
diff --git a/pypy/module/rctime/interp_time.py 
b/pypy/module/rctime/interp_time.py
--- a/pypy/module/rctime/interp_time.py
+++ b/pypy/module/rctime/interp_time.py
@@ -448,10 +448,6 @@
             raise OperationError(space.w_ValueError,
                 space.wrap("year out of range"))
 
-    if rffi.getintfield(glob_buf, 'c_tm_wday') < 0:
-        raise OperationError(space.w_ValueError,
-                             space.wrap("day of week out of range"))
-
     rffi.setintfield(glob_buf, 'c_tm_year', y - 1900)
     rffi.setintfield(glob_buf, 'c_tm_mon',
                      rffi.getintfield(glob_buf, 'c_tm_mon') - 1)
@@ -460,6 +456,12 @@
     rffi.setintfield(glob_buf, 'c_tm_yday',
                      rffi.getintfield(glob_buf, 'c_tm_yday') - 1)
 
+    # tm_wday does not need checking of its upper-bound since taking "%
+    #  7" in gettmarg() automatically restricts the range.
+    if rffi.getintfield(glob_buf, 'c_tm_wday') < 0:
+        raise OperationError(space.w_ValueError,
+                             space.wrap("day of week out of range"))
+
     return glob_buf
 
 def time(space):
diff --git a/pypy/module/rctime/test/test_rctime.py 
b/pypy/module/rctime/test/test_rctime.py
--- a/pypy/module/rctime/test/test_rctime.py
+++ b/pypy/module/rctime/test/test_rctime.py
@@ -113,6 +113,9 @@
         if os.name != 'nt':
             assert rctime.mktime(rctime.localtime(-1)) == -1
 
+        res = rctime.mktime((2000, 1, 1, 0, 0, 0, -1, -1, -1))
+        assert rctime.ctime(res) == 'Sat Jan  1 00:00:00 2000'
+
     def test_asctime(self):
         import time as rctime
         rctime.asctime()
diff --git a/pypy/pytest-A.cfg b/pypy/pytest-A.cfg
--- a/pypy/pytest-A.cfg
+++ b/pypy/pytest-A.cfg
@@ -1,5 +1,5 @@
 cherrypick = ['interpreter', 'objspace/test', 'objspace/std', 'module']
 
-interp = ['translator/goal/pypy-c']
+interp = ['goal/pypy-c']
 test_driver = ['test_all.py', '-A']
 
diff --git a/pypy/test_all.py b/pypy/test_all.py
--- a/pypy/test_all.py
+++ b/pypy/test_all.py
@@ -23,7 +23,8 @@
     if len(sys.argv) == 1 and os.path.dirname(sys.argv[0]) in '.':
         print >> sys.stderr, __doc__
         sys.exit(2)
-
+    #Add toplevel repository dir to sys.path
+    
sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
     import pytest
     import pytest_cov
     sys.exit(pytest.main(plugins=[pytest_cov]))
diff --git a/pypy/tool/pytest/confpath.py b/pypy/tool/pytest/confpath.py
--- a/pypy/tool/pytest/confpath.py
+++ b/pypy/tool/pytest/confpath.py
@@ -1,8 +1,10 @@
 import py
 import pypy
+import rpython
 from pypy.tool import lib_pypy
 
 pypydir = py.path.local(pypy.__file__).dirpath()
+rpythondir = py.path.local(rpython.__file__).dirpath()
 distdir = pypydir.dirpath()
 testresultdir = distdir.join('testresult') 
 assert pypydir.check(dir=1) 
diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py
--- a/pypy/tool/release/package.py
+++ b/pypy/tool/release/package.py
@@ -11,8 +11,10 @@
 
 import shutil
 import sys
+import os
+#Add toplevel repository dir to sys.path
+sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))))
 import py
-import os
 import fnmatch
 from rpython.tool.udir import udir
 
@@ -43,7 +45,7 @@
 
 def package(basedir, name='pypy-nightly', rename_pypy_c='pypy',
             copy_to_dir = None, override_pypy_c = None):
-    basedir = py.path.local(basedir)
+    basedir = py.path.local('goal', basedir)
     if override_pypy_c is None:
         basename = 'pypy-c'
         if sys.platform == 'win32':
diff --git a/pypy/bin/translatorshell.py b/rpython/bin/translatorshell.py
rename from pypy/bin/translatorshell.py
rename to rpython/bin/translatorshell.py
diff --git a/rpython/jit/backend/arm/test/support.py 
b/rpython/jit/backend/arm/test/support.py
--- a/rpython/jit/backend/arm/test/support.py
+++ b/rpython/jit/backend/arm/test/support.py
@@ -14,6 +14,9 @@
     def check_jumps(self, maxcount):
         pass
 
+if not getattr(os, 'uname', None):
+    pytest.skip('cannot run arm tests on non-posix platform')
+
 if os.uname()[1] == 'llaima.local':
     AS = 
'~/Code/arm-jit/android/android-ndk-r4b//build/prebuilt/darwin-x86/arm-eabi-4.4.0/arm-eabi/bin/as'
 else:
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to