Commits

Ronny Pfannschmidt committed 18283de Merge

merge from default

  • Participants
  • Parent commits 5852b6a, b901441
  • Branches pytest

Comments (0)

Files changed (10)

pypy/goal/__init__.py

+#empty

pypy/interpreter/astcompiler/codegen.py

 
     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)

pypy/interpreter/test2/test_app_main.py

 
     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
 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')

pypy/interpreter/test2/test_targetpypy.py

 
 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):

pypy/module/_ast/test/test_ast.py

         ])
         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)

pypy/module/cpyext/classobject.py

         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)

pypy/module/cpyext/include/ceval.h

+/* empty */

pypy/module/cpyext/stubs.py

     """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.

pypy/module/cpyext/test/conftest.py

 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"

pypy/module/cpyext/test/test_classobject.py

         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
         """)
 
         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: