<br><div><span class="gmail_quote">On 5/8/06, <b class="gmail_sendername">Neal Norwitz</b> &lt;<a href="mailto:neal@metaslash.com">neal@metaslash.com</a>&gt; wrote:</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
test_ctypes<br>test test_ctypes failed -- Traceback (most recent call last):<br>&nbsp;&nbsp;File &quot;/home/neal/python/trunk/Lib/ctypes/test/test_python_api.py&quot;, line 41, in test_PyInt_Long<br>&nbsp;&nbsp;&nbsp;&nbsp;self.failUnlessEqual(grc(42), ref42)
<br>AssertionError: 336 != 337<br></blockquote></div><br>We've been seeing this error for a while now, and given the test, it isn't entirely surprising. The test tries to do what regrtest -R:: also does: check for refcount leakage. I'm not entirely sure why it's failing as I can't reproduce it (although it could be because 42's refcount is actually 42 :) but it does seem to me that this kind of refleak-checking is somewhat redundant in the Python testsuite, and it is obvious to me that the breakage is precisely because it's being run in the Python testsuite (which is a lot less reliable an environment than ctypes' own, standalone testsuite.)
<br><br>Thomas, given the refcount-leakage-coverage the ctypes tests are getting in the Python distribution, do you want to keep running these tests? Is there a way to not run them in the Python testsuite, but still keep them for the standalone tests? (If you want that, that is.) Alternatively, we could try to fix the test. If the problem is indeed what I think it is (42's refcount being 42 or 41 or 43 at the first grc() call there; I'm not sure) we could perhaps work around it, using something like:
<br clear="all"><br>Index: Lib/ctypes/test/test_python_api.py<br>===================================================================<br>--- Lib/ctypes/test/test_python_api.py&nbsp; (revision 45940)<br>+++ Lib/ctypes/test/test_python_api.py&nbsp; (working copy)
<br>@@ -35,6 +35,11 @@<br><br>&nbsp;&nbsp;&nbsp;&nbsp; def test_PyInt_Long(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ref42 = grc(42)<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ref42 == 42:<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # 42's refcount was 42, but since grc() returned 42, it's now 43.<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # We want to adjust ref42 without tossing our own reference to 42
<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # (or the refcount will go back down to 42.)<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; old42, ref42 = ref42, ref42 + 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pythonapi.PyInt_FromLong.restype = py_object<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.failUnlessEqual(pythonapi.PyInt_FromLong
(42), 42)<br><br>(Untested, since I can't reproduce, but I think I have it right.)<br><br>-- <br>Thomas Wouters &lt;<a href="mailto:thomas@python.org">thomas@python.org</a>&gt;<br><br>Hi! I'm a .signature virus! copy me into your .signature file to help me spread!