Commits

Tobias Pape  committed b682726 Merge

merge default

  • Participants
  • Parent commits 0365f15, 5a8c87b
  • Branches popen-pclose

Comments (0)

Files changed (15)

File pypy/module/_cffi_backend/newtype.py

 
 # ____________________________________________________________
 
-SF_MSVC_BITFIELDS = 1
-SF_GCC_ARM_BITFIELDS = 2
-SF_GCC_BIG_ENDIAN = 4
-SF_PACKED = 8
+
+SF_MSVC_BITFIELDS     = 0x01
+SF_GCC_ARM_BITFIELDS  = 0x02
+SF_GCC_X86_BITFIELDS  = 0x10
+
+SF_GCC_BIG_ENDIAN     = 0x04
+SF_GCC_LITTLE_ENDIAN  = 0x40
+
+SF_PACKED             = 0x08
+
 
 if sys.platform == 'win32':
-    DEFAULT_SFLAGS = SF_MSVC_BITFIELDS
+    DEFAULT_SFLAGS_PLATFORM = SF_MSVC_BITFIELDS
 else:
     if rffi_platform.getdefined('__arm__', ''):
-        DEFAULT_SFLAGS = SF_GCC_ARM_BITFIELDS
+        DEFAULT_SFLAGS_PLATFORM = SF_GCC_ARM_BITFIELDS
     else:
-        DEFAULT_SFLAGS = 0
-    if sys.byteorder == 'big':
-        DEFAULT_SFLAGS |= SF_GCC_BIG_ENDIAN
+        DEFAULT_SFLAGS_PLATFORM = SF_GCC_X86_BITFIELDS
+
+if sys.byteorder == 'big':
+    DEFAULT_SFLAGS_ENDIAN = SF_GCC_BIG_ENDIAN
+else:
+    DEFAULT_SFLAGS_ENDIAN = SF_GCC_LITTLE_ENDIAN
+
+
+def complete_sflags(sflags):
+    # add one of the SF_xxx_BITFIELDS flags if none is specified
+    if not (sflags & (SF_MSVC_BITFIELDS | SF_GCC_ARM_BITFIELDS |
+                      SF_GCC_X86_BITFIELDS)):
+        sflags |= DEFAULT_SFLAGS_PLATFORM
+    # add one of SF_GCC_xx_ENDIAN if none is specified
+    if not (sflags & (SF_GCC_BIG_ENDIAN | SF_GCC_LITTLE_ENDIAN)):
+        sflags |= DEFAULT_SFLAGS_ENDIAN
+    return sflags
+
+# ____________________________________________________________
+
 
 @unwrap_spec(name=str)
 def new_struct_type(space, name):
 @unwrap_spec(w_ctype=ctypeobj.W_CType, totalsize=int, totalalignment=int,
              sflags=int)
 def complete_struct_or_union(space, w_ctype, w_fields, w_ignored=None,
-                             totalsize=-1, totalalignment=-1,
-                             sflags=DEFAULT_SFLAGS):
+                             totalsize=-1, totalalignment=-1, sflags=0):
+    sflags = complete_sflags(sflags)
     if (not isinstance(w_ctype, ctypestruct.W_CTypeStructOrUnion)
             or w_ctype.size >= 0):
         raise OperationError(space.w_TypeError,

File pypy/module/_cffi_backend/test/_backend_test_c.py

                                        ('b1', BInt, 9),
                                        ('b2', BUInt, 7),
                                        ('c', BChar, -1)], -1, -1, -1, flag)
-    if flag % 2 == 0:   # gcc, any variant
+    if not (flag & SF_MSVC_BITFIELDS):   # gcc, any variant
         assert typeoffsetof(BStruct, 'c') == (BChar, 3)
         assert sizeof(BStruct) == 4
     else:               # msvc
     p.c = b'\x9D'
     raw = buffer(p)[:]
     if sys.byteorder == 'little':
-        if flag == 0 or flag == 2:  # gcc, little endian
+        if flag & SF_MSVC_BITFIELDS:
+            assert raw == b'A\x00\x00\x007\xC7\x00\x00\x9D\x00\x00\x00'
+        elif flag & SF_GCC_LITTLE_ENDIAN:
             assert raw == b'A7\xC7\x9D'
-        elif flag == 1: # msvc
-            assert raw == b'A\x00\x00\x007\xC7\x00\x00\x9D\x00\x00\x00'
-        elif flag == 4: # gcc, big endian
+        elif flag & SF_GCC_BIG_ENDIAN:
             assert raw == b'A\xE3\x9B\x9D'
         else:
             raise AssertionError("bad flag")
     else:
-        if flag == 0 or flag == 2:  # gcc
+        if flag & SF_MSVC_BITFIELDS:
+            assert raw == b'A\x00\x00\x00\x00\x00\xC77\x9D\x00\x00\x00'
+        elif flag & SF_GCC_LITTLE_ENDIAN:
             assert raw == b'A\xC77\x9D'
-        elif flag == 1: # msvc
-            assert raw == b'A\x00\x00\x00\x00\x00\xC77\x9D\x00\x00\x00'
-        elif flag == 4: # gcc, big endian
+        elif flag & SF_GCC_BIG_ENDIAN:
             assert raw == b'A\x9B\xE3\x9D'
         else:
             raise AssertionError("bad flag")
                                        ('',  BShort, 9),
                                        ('c', BChar, -1)], -1, -1, -1, flag)
     assert typeoffsetof(BStruct, 'c') == (BChar, 4)
-    if flag == 0:   # gcc
+    if flag & SF_MSVC_BITFIELDS:
+        assert sizeof(BStruct) == 6
+        assert alignof(BStruct) == 2
+    elif flag & SF_GCC_X86_BITFIELDS:
         assert sizeof(BStruct) == 5
         assert alignof(BStruct) == 1
-    elif flag == 1: # msvc
+    elif flag & SF_GCC_ARM_BITFIELDS:
         assert sizeof(BStruct) == 6
         assert alignof(BStruct) == 2
-    elif flag == 2: # gcc ARM
-        assert sizeof(BStruct) == 6
-        assert alignof(BStruct) == 2
-    elif flag == 4: # gcc, big endian
-        assert sizeof(BStruct) == 5
-        assert alignof(BStruct) == 1
     else:
         raise AssertionError("bad flag")
     #
                                        ('',  BInt, 0),
                                        ('',  BInt, 0),
                                        ('c', BChar, -1)], -1, -1, -1, flag)
-    if flag == 0:    # gcc
+    if flag & SF_MSVC_BITFIELDS:
+        assert typeoffsetof(BStruct, 'c') == (BChar, 1)
+        assert sizeof(BStruct) == 2
+        assert alignof(BStruct) == 1
+    elif flag & SF_GCC_X86_BITFIELDS:
         assert typeoffsetof(BStruct, 'c') == (BChar, 4)
         assert sizeof(BStruct) == 5
         assert alignof(BStruct) == 1
-    elif flag == 1:  # msvc
-        assert typeoffsetof(BStruct, 'c') == (BChar, 1)
-        assert sizeof(BStruct) == 2
-        assert alignof(BStruct) == 1
-    elif flag == 2:  # gcc ARM
+    elif flag & SF_GCC_ARM_BITFIELDS:
         assert typeoffsetof(BStruct, 'c') == (BChar, 4)
         assert sizeof(BStruct) == 8
         assert alignof(BStruct) == 4
-    elif flag == 4:  # gcc, big endian
-        assert typeoffsetof(BStruct, 'c') == (BChar, 4)
-        assert sizeof(BStruct) == 5
-        assert alignof(BStruct) == 1
     else:
         raise AssertionError("bad flag")
 
 
-def test_bitfield_as_gcc():
-    _test_bitfield_details(flag=0)
+SF_MSVC_BITFIELDS     = 0x01
+SF_GCC_ARM_BITFIELDS  = 0x02
+SF_GCC_X86_BITFIELDS  = 0x10
+
+SF_GCC_BIG_ENDIAN     = 0x04
+SF_GCC_LITTLE_ENDIAN  = 0x40
+
+SF_PACKED             = 0x08
+
+def test_bitfield_as_x86_gcc():
+    _test_bitfield_details(flag=SF_GCC_X86_BITFIELDS|SF_GCC_LITTLE_ENDIAN)
 
 def test_bitfield_as_msvc():
-    _test_bitfield_details(flag=1)
+    _test_bitfield_details(flag=SF_MSVC_BITFIELDS|SF_GCC_LITTLE_ENDIAN)
 
 def test_bitfield_as_arm_gcc():
-    _test_bitfield_details(flag=2)
+    _test_bitfield_details(flag=SF_GCC_ARM_BITFIELDS|SF_GCC_LITTLE_ENDIAN)
 
-def test_bitfield_as_big_endian():
-    _test_bitfield_details(flag=4)
+def test_bitfield_as_ppc_gcc():
+    # PowerPC uses the same format as X86, but is big-endian
+    _test_bitfield_details(flag=SF_GCC_X86_BITFIELDS|SF_GCC_BIG_ENDIAN)
 
 
 def test_struct_array_no_length():
     complete_struct_or_union(BStruct, [('a1', BLong, -1),
                                        ('a2', BChar, -1),
                                        ('a3', BShort, -1)],
-                             None, -1, -1, 8)   # SF_PACKED==8
+                             None, -1, -1, SF_PACKED)
     d = BStruct.fields
     assert len(d) == 3
     assert d[0][0] == 'a1'
                    complete_struct_or_union,
                    BStruct, [('a1', BLong, 30),
                              ('a2', BChar, 5)],
-                   None, -1, -1, 8)   # SF_PACKED==8
+                   None, -1, -1, SF_PACKED)
 
 def test_version():
     # this test is here mostly for PyPy

File pypy/module/_rawffi/structure.py

-
 """ Interpreter-level implementation of structure, exposing ll-structure
 to app-level with apropriate interface
 """
 from rpython.rlib.rarithmetic import intmask, signedtype, widen
 from rpython.rlib.rarithmetic import r_uint, r_ulonglong, r_longlong
 
+
 def unpack_fields(space, w_fields):
     fields_w = space.unpackiterable(w_fields)
     fields = []

File pypy/module/gc/__init__.py

 from pypy.interpreter.mixedmodule import MixedModule
-    
+
+
 class Module(MixedModule):
     interpleveldefs = {
         'collect': 'interp_gc.collect',
         'isenabled': 'interp_gc.isenabled',
         'enable_finalizers': 'interp_gc.enable_finalizers',
         'disable_finalizers': 'interp_gc.disable_finalizers',
-        'garbage' : 'space.newlist([])',
+        'garbage': 'space.newlist([])',
         #'dump_heap_stats': 'interp_gc.dump_heap_stats',
     }
-    appleveldefs = {
-    }
+    appleveldefs = {}
 
     def __init__(self, space, w_name):
         if (not space.config.translating or
-            space.config.translation.gctransformer == "framework"):
+                space.config.translation.gctransformer == "framework"):
             self.appleveldefs.update({
                 'dump_rpy_heap': 'app_referents.dump_rpy_heap',
                 })

File pypy/module/pypyjit/test_pypy_c/test_generators.py

 
 
 class TestGenerators(BaseTestPyPyC):
-    def test_simple_generator(self):
+    def test_simple_generator1(self):
         def main(n):
             def f():
                 for i in range(10000):
             jump(..., descr=...)
             """)
         assert loop.match_by_id("subtract", """
-            setfield_gc(p7, 35, descr=<.*last_instr .*>)     # XXX bad, kill me
+            i2 = int_sub(i1, 42)
+            """)
+
+    def test_simple_generator2(self):
+        def main(n):
+            def f():
+                for i in range(1, 10000):
+                    i -= 1
+                    i -= 42    # ID: subtract
+                    yield i
+
+            def g():
+                for i in f():  # ID: generator
+                    pass
+
+            g()
+
+        log = self.run(main, [500])
+        loop, = log.loops_by_filename(self.filepath)
+        assert loop.match_by_id("generator", """
+            cond_call(..., descr=...)
+            i16 = force_token()
+            p45 = new_with_vtable(ConstClass(W_IntObject))
+            setfield_gc(p45, i29, descr=<FieldS .*>)
+            setarrayitem_gc(p8, 0, p45, descr=<ArrayP .>)
+            i47 = arraylen_gc(p8, descr=<ArrayP .>) # Should be removed by backend
+            jump(..., descr=...)
+            """)
+        assert loop.match_by_id("subtract", """
+            setfield_gc(p7, 38, descr=<.*last_instr .*>)     # XXX bad, kill me
             i2 = int_sub_ovf(i1, 42)
             guard_no_overflow(descr=...)
             """)

File pypy/module/pypyjit/test_pypy_c/test_misc.py

         jump(..., descr=...)
         """)
 
-    def test_range_iter(self):
+    def test_range_iter_simple(self):
         def main(n):
             def g(n):
                 return range(n)
             guard_not_invalidated?
             i16 = int_ge(i11, i12)
             guard_false(i16, descr=...)
+            i20 = int_add(i11, 1)
+            i21 = force_token()
+            setfield_gc(p4, i20, descr=<.* .*W_AbstractSeqIterObject.inst_index .*>)
+            guard_not_invalidated?
+            i25 = int_ge(i11, i9)
+            guard_false(i25, descr=...)
+            i27 = int_add_ovf(i7, i11)
+            guard_no_overflow(descr=...)
+            --TICK--
+            jump(..., descr=...)
+        """)
+
+    def test_range_iter_normal(self):
+        def main(n):
+            def g(n):
+                return range(n)
+            s = 0
+            for i in range(1, n):  # ID: for
+                tmp = g(n)
+                s += tmp[i]     # ID: getitem
+                a = 0
+            return s
+        #
+        log = self.run(main, [1000])
+        assert log.result == 1000 * 999 / 2
+        loop, = log.loops_by_filename(self.filepath)
+        assert loop.match("""
+            guard_not_invalidated?
+            i16 = int_ge(i11, i12)
+            guard_false(i16, descr=...)
             i17 = int_mul(i11, i14)
             i18 = int_add(i15, i17)
             i20 = int_add(i11, 1)

File pypy/module/select/test/test_select.py

 class AppTestSelectWithSockets(_AppTestSelect):
     """Same tests with connected sockets.
     socket.socketpair() does not exists on win32,
-    so we start our own server."""
+    so we start our own server.
+    """
     spaceconfig = {
         "usemodules": ["select", "_socket", "rctime", "thread"],
     }
             except OperationError, e:   # should get a "Permission denied"
                 if not e.match(space, space.getattr(w_socketmod, space.wrap("error"))):
                     raise
-                print e
+                print e.errorstr(space)
             except cls.w_sock_err, e:   # should get a "Permission denied"
                 print e
             else:
         thread.start_new_thread(s2.connect, (self.sockaddress,))
         s1, addr2 = self.sock.accept()
 
+        # speed up the tests that want to fill the buffers
+        s1.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 4096)
+        s2.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 4096)
+
         return s1, s2

File pypy/objspace/std/intobject.py

 from rpython.rlib.rarithmetic import (
     LONG_BIT, is_valid_int, ovfcheck, r_longlong, r_uint, string_to_int)
 from rpython.rlib.rbigint import rbigint
+from rpython.rlib.rfloat import DBL_MANT_DIG
 from rpython.rlib.rstring import (
     InvalidBaseError, ParseStringError, ParseStringOverflowError)
 from rpython.tool.sourcetools import func_renamer, func_with_new_name
 
 
 def _truediv(space, x, y):
+    if not y:
+        raise oefmt(space.w_ZeroDivisionError, "division by zero")
+
+    if (DBL_MANT_DIG < LONG_BIT and
+        (r_uint(abs(x)) >> DBL_MANT_DIG or r_uint(abs(y)) >> DBL_MANT_DIG)):
+        # large x or y, use long arithmetic
+        raise OverflowError
+
+    # both ints can be exactly represented as doubles, do a
+    # floating-point division
     a = float(x)
     b = float(y)
-    if b == 0.0:
-        raise oefmt(space.w_ZeroDivisionError, "division by zero")
     return space.wrap(a / b)
 
 
 
     descr_floordiv, descr_rfloordiv = _make_descr_binop(_floordiv)
     descr_div, descr_rdiv = _make_descr_binop(_div)
-    descr_truediv, descr_rtruediv = _make_descr_binop(_truediv, ovf=False)
+    descr_truediv, descr_rtruediv = _make_descr_binop(_truediv)
     descr_mod, descr_rmod = _make_descr_binop(_mod)
     descr_divmod, descr_rdivmod = _make_descr_binop(
         _divmod, ovf2small=_divmod_ovf2small)

File pypy/objspace/std/listobject.py

         storage = strategy.erase(None)
     elif start == 0 and step == 1:
         strategy = space.fromcache(SimpleRangeListStrategy)
-        assert length > 0
         storage = strategy.erase((length,))
     else:
         strategy = space.fromcache(RangeListStrategy)
 
 
 class W_ListObject(W_Root):
-
     strategy = None
 
     def __init__(self, space, wrappeditems, sizehint=-1):
 
     def _getitem_unwrapped(self, w_list, i):
         length = self.unerase(w_list.lstorage)[0]
-        assert length > 0
-        if 0 <= i < length:
-            return i
-        else:
+        if i < 0:
+            i += length
+            if i < 0:
+                raise IndexError
+        elif i >= length:
             raise IndexError
+        return i
 
     @specialize.arg(2)
     def _getitems_range(self, w_list, wrap_items):

File pypy/objspace/std/test/test_intobject.py

         base = MyInt(24)
         assert int('10', base) == 24
 
+    def test_truediv(self):
+        import operator
+        x = 1000000
+        a = x / 2
+        assert a == 500000
+        a = operator.truediv(x, 2)
+        assert a == 500000.0
+
+        x = 63050394783186940
+        a = x / 7
+        assert a == 9007199254740991
+        a = operator.truediv(x, 7)
+        assert a == 9007199254740991.0
+        exec("from __future__ import division; "
+             "a = x / 7; b = operator.truediv(x, 7)")
+        assert a == 9007199254740991.0
+        assert b == 9007199254740991.0
+
+
 class AppTestIntShortcut(AppTestInt):
     spaceconfig = {"objspace.std.intshortcut": True}
 

File pypy/objspace/std/test/test_listobject.py

             self.space.setitem(w_lhslist, w_slice, w_rhslist)
             assert self.space.unwrap(w_lhslist) == expected
 
-
         test1([5,7,1,4], 1, 3, [9,8],  [5,9,8,4])
         test1([5,7,1,4], 1, 3, [9],    [5,9,4])
         test1([5,7,1,4], 1, 3, [9,8,6],[5,9,8,6,4])
                            self.space.w_True)
         assert self.space.eq_w(self.space.eq(w_list2, w_list3),
                            self.space.w_False)
+
     def test_ne(self):
         w = self.space.wrap
 
                            self.space.w_False)
         assert self.space.eq_w(self.space.ne(w_list2, w_list3),
                            self.space.w_True)
+
     def test_lt(self):
         w = self.space.wrap
 
         with py.test.raises(ValueError):
             intlist.find(w(4), 0, 2)
 
+
 class AppTestW_ListObject(object):
     def setup_class(cls):
         import platform
         raises(IndexError, "l[1]")
 
     def test_setitem(self):
-
         l = []
         raises(IndexError, "l[1] = 2")
 
         raises(TypeError, "[0]*MyInt(3)")
         raises(TypeError, "[0]*MyIndex(MyInt(3))")
 
-
     def test_index(self):
         c = range(10)
         assert c.index(0) == 0
         assert ([5] >= [N]) is False
 
     def test_resizelist_hint(self):
+        if self.on_cpython:
+            skip('pypy-only test')
         import __pypy__
         l2 = []
         __pypy__.resizelist_hint(l2, 100)
         assert len(l1) == 0
 
     def test_use_method_for_wrong_object(self):
+        if self.on_cpython:
+            skip('pypy-only test')
         raises(TypeError, list.append.im_func, 1, 2)
 
     def test_ne_NotImplemented(self):
 
     def test_getitem(self):
         l = range(5)
-        raises(IndexError, "l[-10]")
+        raises(IndexError, "l[-6]")
+        raises(IndexError, "l[5]")
+        assert l[0] == 0
+        assert l[-1] == 4
+        assert l[-2] == 3
+        assert l[-5] == 0
+
+        l = range(1, 5)
+        raises(IndexError, "l[-5]")
+        raises(IndexError, "l[4]")
+        assert l[0] == 1
+        assert l[-1] == 4
+        assert l[-2] == 3
+        assert l[-4] == 1
 
     def test_append(self):
         l = range(5)
         notshared = l[:]
         assert notshared == []
 
+
 class AppTestListFastSubscr:
     spaceconfig = {"objspace.std.optimized_list_getitem": True}
 

File rpython/rlib/rfile.py

-
 """ This file makes open() and friends RPython. Note that RFile should not
 be used directly and instead it's magically appearing each time you call
 python builtin open()
 def llexternal(*args, **kwargs):
     return rffi.llexternal(*args, compilation_info=eci, **kwargs)
 
-FILE = lltype.Struct('FILE') # opaque type maybe
-
 class CConfig(object):
     _compilation_info_ = eci
 
     off_t = platform.SimpleType('off_t')
 
+config = platform.configure(CConfig)
 
-CC = platform.configure(CConfig)
-OFF_T = CC['off_t']
+OFF_T = config['off_t']
+FILE = lltype.Struct('FILE')  # opaque type maybe
+
 c_open = llexternal('fopen', [rffi.CCHARP, rffi.CCHARP], lltype.Ptr(FILE))
 c_close = llexternal('fclose', [lltype.Ptr(FILE)], rffi.INT)
 c_fwrite = llexternal('fwrite', [rffi.CCHARP, rffi.SIZE_T, rffi.SIZE_T,
-                                     lltype.Ptr(FILE)], rffi.SIZE_T)
+                                 lltype.Ptr(FILE)], rffi.SIZE_T)
 c_fread = llexternal('fread', [rffi.CCHARP, rffi.SIZE_T, rffi.SIZE_T,
-                                   lltype.Ptr(FILE)], rffi.SIZE_T)
+                               lltype.Ptr(FILE)], rffi.SIZE_T)
 c_feof = llexternal('feof', [lltype.Ptr(FILE)], rffi.INT)
 c_ferror = llexternal('ferror', [lltype.Ptr(FILE)], rffi.INT)
 c_clearerror = llexternal('clearerr', [lltype.Ptr(FILE)], lltype.Void)
 c_fseek = llexternal('fseek', [lltype.Ptr(FILE), rffi.LONG, rffi.INT],
-                          rffi.INT)
+                     rffi.INT)
 c_tmpfile = llexternal('tmpfile', [], lltype.Ptr(FILE))
 c_fileno = llexternal('fileno', [lltype.Ptr(FILE)], rffi.INT)
 c_ftell = llexternal('ftell', [lltype.Ptr(FILE)], rffi.LONG)
 BASE_BUF_SIZE = 4096
 BASE_LINE_SIZE = 100
 
+
+def _error(ll_file):
+    errno = c_ferror(ll_file)
+    c_clearerror(ll_file)
+    raise OSError(errno, os.strerror(errno))
+
+
 def create_file(filename, mode="r", buffering=-1):
     assert buffering == -1
     assert filename is not None
         lltype.free(ll_name, flavor='raw')
     return RFile(ll_f)
 
+
 def create_temp_rfile():
     res = c_tmpfile()
     if not res:
         raise OSError(errno, os.strerror(errno))
     return RFile(res)
 
+
 def create_popen_file(command, type):
     ll_command = rffi.str2charp(command)
     try:
         lltype.free(ll_command, flavor='raw')
     return RPopenFile(ll_f)
 
+
 class RFile(object):
     def __init__(self, ll_file):
         self.ll_file = ll_file
         while raw_buf[strlen] != '\0':
             strlen += 1
         if (strlen == BASE_LINE_SIZE - 1 and
-              raw_buf[BASE_LINE_SIZE - 2] != '\n'):
+                raw_buf[BASE_LINE_SIZE - 2] != '\n'):
             return -1    # overflow!
         # common case
         return strlen
 
 class RPopenFile(RFile):
     _do_close = staticmethod(c_pclose)
-
-
-def _error(ll_file):
-    errno = c_ferror(ll_file)
-    c_clearerror(ll_file)
-    raise OSError(errno, os.strerror(errno))

File rpython/rlib/rposix.py

 from rpython.rlib import jit
 from rpython.translator.platform import platform
 
+
 class CConstantErrno(CConstant):
     # these accessors are used when calling get_errno() or set_errno()
     # on top of CPython
     def __setitem__(self, index, value):
         assert index == 0
         ll2ctypes.TLS.errno = value
+
 if os.name == 'nt':
     if platform.name == 'msvc':
         includes=['errno.h','stdio.h']
 #   with other wrappers that directly handle unicode strings.
 @specialize.argtype(0)
 def open(path, flags, mode):
+    assert path is not None
     if isinstance(path, str):
         return os.open(path, flags, mode)
     else:

File rpython/rtyper/rbuiltin.py

-
 from rpython.annotator import model as annmodel
 from rpython.flowspace.model import Constant
 from rpython.rlib import rarithmetic, objectmodel

File rpython/rtyper/tool/rffi_platform.py

     """
     for attr in ['_includes_', '_libraries_', '_sources_', '_library_dirs_',
                  '_include_dirs_', '_header_']:
-        assert not hasattr(CConfig, attr), "Found legacy attribute %s on CConfig" % (attr,)
+        assert not hasattr(CConfig, attr), \
+            "Found legacy attribute %s on CConfig" % attr
+
     entries = []
     for key in dir(CConfig):
         value = getattr(CConfig, key)
         if isinstance(value, CConfigEntry):
-            entries.append((key, value))            
+            entries.append((key, value))
 
     if entries:   # can be empty if there are only CConfigSingleEntries
         writer = _CWriter(CConfig)