Armin Rigo avatar Armin Rigo committed 63f16c0 Merge

merge heads

Comments (0)

Files changed (7)

pypy/module/cpyext/iterator.py

     cannot be iterated."""
     return space.iter(w_obj)
 
-@cpython_api([PyObject], PyObject, error=CANNOT_FAIL)
+@cpython_api([PyObject], PyObject)
 def PyIter_Next(space, w_obj):
     """Return the next value from the iteration o.  If the object is an
     iterator, this retrieves the next value from the iteration, and returns

pypy/module/cpyext/test/test_iterator.py

         assert space.unwrap(api.PyIter_Next(w_iter)) == 3
         assert api.PyIter_Next(w_iter) is None
         assert not api.PyErr_Occurred()
+
+    def test_iternext_error(self,space, api):
+        assert api.PyIter_Next(space.w_None) is None
+        assert api.PyErr_Occurred() is space.w_TypeError
+        api.PyErr_Clear()

pypy/module/cpyext/test/test_unicodeobject.py

 
     def test_tailmatch(self, space, api):
         w_str = space.wrap(u"abcdef")
-        assert api.PyUnicode_Tailmatch(w_str, space.wrap("cde"), 2, 10, 1) == 1
-        assert api.PyUnicode_Tailmatch(w_str, space.wrap("cde"), 1, 5, -1) == 1
+        assert api.PyUnicode_Tailmatch(w_str, space.wrap("cde"), 2, 10, -1) == 1
+        assert api.PyUnicode_Tailmatch(w_str, space.wrap("cde"), 1, 5, 1) == 1
         self.raises(space, api, TypeError,
                     api.PyUnicode_Tailmatch, w_str, space.wrap(3), 2, 10, 1)
 

pypy/module/cpyext/unicodeobject.py

     suffix match), 0 otherwise. Return -1 if an error occurred."""
     str = space.unicode_w(w_str)
     substr = space.unicode_w(w_substr)
-    if rffi.cast(lltype.Signed, direction) >= 0:
+    if rffi.cast(lltype.Signed, direction) <= 0:
         return stringtype.stringstartswith(str, substr, start, end)
     else:
         return stringtype.stringendswith(str, substr, start, end)

pypy/objspace/std/test/test_methodcache.py

             assert a.f() == 42 + i
             A.f = eval("lambda self: %s" % (42 + i + 1, ))
         cache_counter = __pypy__.method_cache_counter("f")
-        # the cache hits come from A.f = ..., which first does a lookup on A as
-        # well
+        #
+        # a bit of explanation about what's going on.  (1) is the line "a.f()"
+        # and (2) is "A.f = ...".
+        #
+        # at line (1) we do the lookup on type(a).f
+        #
+        # at line (2) we do a setattr on A. However, descr_setattr does also a
+        # lookup of type(A).f i.e. type.f, to check if by chance 'f' is a data
+        # descriptor.
+        #
+        # At the first iteration:
+        # (1) is a miss because it's the first lookup of A.f. The result is cached
+        #
+        # (2) is a miss because it is the first lookup of type.f. The
+        # (non-existant) result is cached. The version of A changes, and 'f'
+        # is changed to be a cell object, so that subsequest assignments won't
+        # change the version of A
+        #
+        # At the second iteration:
+        # (1) is a miss because the version of A changed just before
+        # (2) is a hit, because type.f is cached. The version of A no longer changes
+        #
+        # At the third and subsequent iterations:
+        # (1) is a hit, because the version of A did not change
+        # (2) is a hit, see above
         assert cache_counter == (17, 3)
 
     def test_subclasses(self):

pypy/rpython/module/ll_os.py

             DIRENTP = lltype.Ptr(DIRENT)
             os_opendir = self.llexternal('opendir', [rffi.CCHARP], DIRP,
                                          compilation_info=compilation_info)
+            # XXX macro=True is hack to make sure we get the correct kind of
+            # dirent struct (which depends on defines)
             os_readdir = self.llexternal('readdir', [DIRP], DIRENTP,
-                                         compilation_info=compilation_info)
+                                         compilation_info=compilation_info,
+                                         macro=True)
             os_closedir = self.llexternal('closedir', [DIRP], rffi.INT,
                                           compilation_info=compilation_info)
 

pypy/translator/c/extfunc.py

 from pypy.rpython.lltypesystem.rstr import STR, mallocstr
 from pypy.rpython.lltypesystem import rstr
 from pypy.rpython.lltypesystem import rlist
-from pypy.rpython.module import ll_time, ll_os
 
 # table of functions hand-written in src/ll_*.h
 # Note about *.im_func: The annotator and the rtyper expect direct
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.