This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_imp.py test failures on Py3K Mac OS X
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.2
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: barry Nosy List: barry, brett.cannon, ezio.melotti, flox, michael.foord, tim.golden
Priority: normal Keywords:

Created on 2010-05-01 10:38 by michael.foord, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (17)
msg104702 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-05-01 10:38
I get the following failure running test_imp on py3k, Mac OS X 10.6.3.


======================================================================
ERROR: test_package___file__ (__main__.PEP3147Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Lib/test/test_imp.py", line 303, in test_package___file__
    support.forget('pep3147')
  File "/compile/python-trunk3/Lib/test/support.py", line 227, in forget
    unlink(source + 'c')
  File "/compile/python-trunk3/Lib/test/support.py", line 186, in unlink
    os.unlink(filename)
OSError: [Errno 20] Not a directory: '/dev/null/lib/python32.zip/pep3147.pyc'
msg104705 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-05-01 10:49
I see similar failures (failing to unlink weird paths from support.py) in: test_imp.py, test_import.py, test_pydoc.py, test_runpy.py,
msg104706 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-05-01 10:54
So I'm assuming issue 8587 (same failure in test_import.py) is a duplicate of this. I'll close 8587.
msg104830 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-05-03 10:30
I'm seeing a "similar" (but not identical) failure on py3k / Windows 7 in test_marshal. Failure in the same code path in support.py:

======================================================================
ERROR: test_floats (__main__.FloatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "../Lib/test/test_marshal.py", line 14, in helper
    f = open(support.TESTFN, "wb")
IOError: [Errno 13] Permission denied: '@test_5324_tmp'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "../Lib/test/test_marshal.py", line 88, in test_floats
    self.helper(f)
  File "../Lib/test/test_marshal.py", line 26, in helper
    support.unlink(support.TESTFN)
  File "C:\compile\py3k\lib\test\support.py", line 186, in unlink
    os.unlink(filename)
WindowsError: [Error 5] Access is denied: '@test_5324_tmp'

----------------------------------------------------------------------
msg104831 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2010-05-03 10:45
This is basically issue 7743 which is a combination of:

* Using the same filename for all tests in one process
* Something (TSvn / Virus Checker) having a delete-share handle
* Not renaming the file before removing it in test.support.unlink

MvL suggested a change to the underlying unlink. I'm unconvinced
that this would solve the issue, but I haven't put together the
test cases needed to show this. For this current issue, I believe
that patching test.support.unlink to rename (to a guid-based
name in the same directory, say) before deleting would solve
all this.

It's fairly reproducible; there's a mini-test harness on
that other call which will throw up these errors often
enough to be useful.
msg104840 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2010-05-03 14:35
Surely not bug 7743 "Additional potential string -> float conversion issues."
msg104853 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2010-05-03 16:40
Sorry, typing too fast:

   http://bugs.python.org/issue7443 - test.support.unlink issue on Windows platform

at least insofar as the issue applies to Windows. I imagine that the
OS X thingis completely different.
msg104881 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2010-05-03 20:50
I cannot reproduce this on my 10.6.3 machine either running the full test suite, or running:

./python.exe Lib/test/test_imp.py
./python.exe -m unittest test.test_imp
msg104882 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-05-03 20:54
Hmm... happens reliably for me.
msg104885 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2010-05-03 21:14
How odd.  I'm on r80727 in py3k.
msg104887 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-05-03 21:35
Yep, same here.
msg104961 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-05-04 17:59
Any idea where this path comes from? I can go spelunking through the code myself to investigate.
msg104962 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-05-04 18:10
Ok, so the cause of the bug is 'simple' - not sure what the best fix is.

When I run python from a freshly built py3k I have the following as sys.path:

['', '/dev/null/lib/python32.zip', '/compile/python-trunk3/Lib', '/compile/python-trunk3/Lib/plat-darwin', '/compile/python-trunk3/build/lib.macosx-10.4-x86_64-3.2-pydebug', '/Volumes/Second Drive/michael/.local/lib/python/3.2/site-packages']

Note that weird second entry!

support.forget(...) trys to unlink the supplied name (+.py + c|o) from every path in sys.path.

The unlink function catches OSError, but *only* if the errno is errno.ENOENT. On my system the specific error raises is:

OSError: [Errno 20] Not a directory
msg104963 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2010-05-04 18:12
Maybe you just want to relax the test in the except clause of test.support.unlink()?  Or change the test to

if error.errno not in (errno.ENOENT, errno.ENOTDIR)

?
msg104964 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-05-04 18:14
On trunk the definition of unlink is:


def unlink(filename):
    try:
        os.unlink(filename)
    except OSError:
        pass

:-)

Changing it as you suggest fixes the problem though. Ok to commit?
msg104967 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2010-05-04 18:22
+1
msg104981 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-05-04 22:37
Committed revision 80771.
History
Date User Action Args
2022-04-11 14:57:00adminsetgithub: 52832
2010-05-04 22:37:45michael.foordsetstatus: open -> closed
messages: + msg104981

assignee: michael.foord -> barry
resolution: accepted -> works for me
stage: needs patch -> resolved
2010-05-04 18:22:07barrysetassignee: barry -> michael.foord
resolution: works for me -> accepted
messages: + msg104967
2010-05-04 18:14:49michael.foordsetmessages: + msg104964
2010-05-04 18:12:13barrysetmessages: + msg104963
2010-05-04 18:10:43michael.foordsetmessages: + msg104962
2010-05-04 17:59:30michael.foordsetmessages: + msg104961
2010-05-03 21:35:12michael.foordsetmessages: + msg104887
2010-05-03 21:14:52barrysetmessages: + msg104885
2010-05-03 20:54:27michael.foordsetmessages: + msg104882
2010-05-03 20:50:59barrysetresolution: works for me
messages: + msg104881
2010-05-03 16:40:19tim.goldensetmessages: + msg104853
2010-05-03 14:35:18barrysetmessages: + msg104840
2010-05-03 10:45:21tim.goldensetnosy: + tim.golden
title: test.support errors (py3k) -> test_imp.py test failures on Py3K Mac OS X
messages: + msg104831
2010-05-03 10:33:54michael.foordsettitle: test_imp.py test failures on Py3K Mac OS X -> test.support errors (py3k)
2010-05-03 10:30:04michael.foordsetmessages: + msg104830
2010-05-01 14:10:42r.david.murraysetassignee: barry
2010-05-01 13:56:28r.david.murraysetassignee: barry -> (no value)

nosy: + ezio.melotti, flox
2010-05-01 11:07:56pitrousetassignee: barry

nosy: + barry
components: + Tests
stage: test needed -> needs patch
2010-05-01 10:54:16michael.foordsetmessages: + msg104706
2010-05-01 10:49:46michael.foordsetmessages: + msg104705
2010-05-01 10:38:13michael.foordcreate