Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:

The test failure is reproducible on the PR 12271 merging master branch on 
Ubuntu with -R 3:3 test_socket. Sorry, I tried it initially on master thinking 
it was a master branch problem. I don't see C related code in the PR. There was 
a merge commit [0] after which the failure is consistently reproducible. I 
tried reverting parts of the PR to narrow down the failure and happened to come 
across the below statement in the diff where the test object and elapsed test 
for time are stored to be printed later. Commenting out the call makes tests 
pass for test_socket and much more baffling is that changing the code to use 
list instead of tuple causes the error to go away. Also I tried changing append 
to use extend or just to append test object instead of a tuple of test object 
and elapsed time which all pass. Instead of using test object in tuple just 
using (object(), elapsed) as a tuple also causes failure. I guess there is 
something with tuples here but it doesn't make much sense.

On trying to bisect the merge commit I have narrowed down the below commits 
where the PR passes with tuple itself and then fails. In between the success 
and failure commit there were some changes made to hunterleaks and 
socket.create_server utility was added.

 f66e336f45 (success)
 58721a9030 (success)
 2b00db68554422ec37faba2a80179a0172df6349 (fails)

# Sample failure on PR's HEAD on Ubuntu 

⋊> ~/cpython on pr_12271  ./python -m test --fail-env-changed -R 3:3 
test_socket                                                                     
                                               05:45:52
Run tests sequentially
0:00:00 load avg: 0.22 [1/1] test_socket
beginning 6 repetitions
123456
Warning -- threading_cleanup() failed to cleanup 0 threads (count: 0, dangling: 
5)
Dangling thread: <Thread(Thread-3, stopped 140152613795584)>
Dangling thread: <Thread(Thread-1, stopped 140152613795584)>
Dangling thread: <Thread(Thread-4, stopped 140152613795584)>
Dangling thread: <Thread(Thread-2, stopped 140152613795584)>
Dangling thread: <_MainThread(MainThread, started 140152731227904)>
......
test_socket failed (env changed) in 3 min 6 sec

== Tests result: ENV CHANGED ==

1 test altered the execution environment:
    test_socket

Total duration: 3 min 6 sec
Tests result: ENV CHANGED

The below patch on the PR to use list causes the tests to pass but I am highly 
confused over how changing to tuple to list fixes this and this might 
potentially be hiding a bug.

$ git diff
diff --git a/Lib/unittest/result.py b/Lib/unittest/result.py
index 273ca3beef..b8fd714679 100644
--- a/Lib/unittest/result.py
+++ b/Lib/unittest/result.py
@@ -160,7 +160,7 @@ class TestResult(object):

     def addDuration(self, test, elapsed):
         """Called when a test finished to run, regardless of its outcome."""
-        self.collectedDurations.append((test, elapsed))
+        self.collectedDurations.append([test, elapsed])

     def wasSuccessful(self):
         """Tells whether or not this result was a success."""

[0] 
https://github.com/python/cpython/commit/3c4af91c1e7c02561efa752885011ff642725bd8

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36750>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to