Issue 30843: [2.7] Lib/test/bisect.py conflicts with Lib/bisect.py when running tests (original) (raw)
I added Lib/test/bisect.py in the commit d7955b8196578306e9d86f6c61c9cb3ee72edab0, bpo-29512.
When a test is loaded by Lib/test/regrtest.py when regrtest.py runs with "python -m test", test files like Lib/test/test_bisect.py are created with package = ['test']. In this case, "import bisect" loads Lib/test/bisect.py rather than Lib/bisect.py. For test_bisect.py, I worked around the issue using "from future import absolute_import".
But then I saw this bug:
Run tests in parallel using 2 child processes (...) 0:02:41 [144/403/1] test_multiprocessing failed test test_multiprocessing failed -- Traceback (most recent call last): File "/usr/home/buildbot/python/2.7.koobs-freebsd-current.nondebug/build/Lib/test/test_multiprocessing.py", line 1669, in test_connection self.assertEqual(poll(TIMEOUT1), True) AssertionError: False != True (...) Re-running test 'test_multiprocessing' in verbose mode (...)
ERROR: test_array (test.test_multiprocessing.WithProcessesTestArray)
Traceback (most recent call last): File "/usr/home/buildbot/python/2.7.koobs-freebsd-current.nondebug/build/Lib/test/test_multiprocessing.py", line 1027, in test_array arr = self.Array('i', seq) File "/usr/home/buildbot/python/2.7.koobs-freebsd-current.nondebug/build/Lib/multiprocessing/init.py", line 260, in Array return Array(typecode_or_type, size_or_initializer, **kwds) File "/usr/home/buildbot/python/2.7.koobs-freebsd-current.nondebug/build/Lib/multiprocessing/sharedctypes.py", line 120, in Array obj = RawArray(typecode_or_type, size_or_initializer) File "/usr/home/buildbot/python/2.7.koobs-freebsd-current.nondebug/build/Lib/multiprocessing/sharedctypes.py", line 93, in RawArray result = new_value(type) File "/usr/home/buildbot/python/2.7.koobs-freebsd-current.nondebug/build/Lib/multiprocessing/sharedctypes.py", line 68, in _new_value wrapper = heap.BufferWrapper(size) File "/usr/home/buildbot/python/2.7.koobs-freebsd-current.nondebug/build/Lib/multiprocessing/heap.py", line 243, in init block = BufferWrapper._heap.malloc(size) File "/usr/home/buildbot/python/2.7.koobs-freebsd-current.nondebug/build/Lib/multiprocessing/heap.py", line 223, in malloc (arena, start, stop) = self._malloc(size) File "/usr/home/buildbot/python/2.7.koobs-freebsd-current.nondebug/build/Lib/multiprocessing/heap.py", line 115, in _malloc i = bisect.bisect_left(self._lengths, size) AttributeError: 'module' object has no attribute 'bisect_left'
The wrong bisect module was picked when test_multiprocessing was run for the second time.
The first run was done in a slave process. The second run was done in the main regrtest process.