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_tarfile failing (file in use when deleting) on Windows buildbots
Type: resource usage Stage: patch review
Components: Library (Lib), Tests Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: lars.gustaebel Nosy List: lars.gustaebel, paul.moore, pitrou
Priority: normal Keywords: buildbot, patch

Created on 2009-11-17 19:50 by paul.moore, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
tarfile.patch pitrou, 2009-11-17 21:01
issue7341-3.x.diff lars.gustaebel, 2009-11-18 12:11
Messages (12)
msg95395 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2009-11-17 19:50
Windows 3.x buildbots are failing in test_tarfile.

The problem, as best I can diagnose it, appears to be a failure
somewhere in the tarfile module to close files on exceptions. The error
is "WindowsError: [Error 32] The process cannot access the file because
it is being used by another process", but I am pretty sure it's actually
the *same* process which still has an open handle on the file. The
problem occurs around  test_append_gz, which tries to open the tarfile
but expects an error. I think when the call raises the error, it is
leaving a filehandle open, which is what causes the delete in setUp to fail.
msg95402 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-11-17 21:01
This is a problem in the Tarfile class, which keeps the underlying
`fileobj` open even when the constructor fails. Here is a possible patch.
msg95425 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2009-11-18 12:11
Any idea why the 2.x buildbots aren't failing? The code is basically the
same. Coincidence?

The patch is okay. Still, I have attached another version of it with a
slightly smaller try-except clause. Is it feasible to test if the patch
actually solves the problem?
msg95428 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-11-18 13:43
Le mercredi 18 novembre 2009 à 12:11 +0000, Lars Gustäbel a écrit :
> Lars Gustäbel <lars@gustaebel.de> added the comment:
> 
> Any idea why the 2.x buildbots aren't failing? The code is basically the
> same. Coincidence?

No, the difference is that exception objects carry the traceback with
them in 3.x, which keeps alive a reference cycle long enough for
`fileobj` not to be garbage collected before the next test run.
msg95429 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2009-11-18 15:59
I can run a test on my buildbot - but I may not have a chance until
tomorrow. I'll do that and report back unless someone else reports
that they have managed to run a test before me.
msg95432 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-11-18 17:07
> Still, I have attached another version of it with a
> slightly smaller try-except clause. Is it feasible to test if the patch
> actually solves the problem?

Yes, it does.
msg95435 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2009-11-18 17:51
I can confirm it fixes the issue, too.
msg95449 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2009-11-18 20:34
Alright then. I applied the change to the trunk (r76381) and py3k
(r76383). What about release26-maint and release31-maint? IMO this is
not necessary.
msg95450 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-11-18 20:36
> Alright then. I applied the change to the trunk (r76381) and py3k
> (r76383). What about release26-maint and release31-maint? IMO this is
> not necessary.

Unless it might cause compatibility concerns I think it would be better
to backport it.
In general it's bad to rely on reference counting to automatically close
files. The object could be hanging on a traceback, or you could be
running on a Python implementation with a different GC strategy.
msg95451 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2009-11-18 20:52
I have always tried to be very conservative with backporting stuff that
is not clearly a bugfix but alters any kind of behaviour. I am always
very concerned about compatibility, especially if code has been around
for as long as this code has.
But as I don't want to waste anybody's time with a lengthy discussion,
just say a word and I apply it to 2.6 and 3.1 as well ;-)
msg95452 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-11-18 20:54
> I have always tried to be very conservative with backporting stuff that
> is not clearly a bugfix but alters any kind of behaviour. I am always
> very concerned about compatibility, especially if code has been around
> for as long as this code has.
> But as I don't want to waste anybody's time with a lengthy discussion,
> just say a word and I apply it to 2.6 and 3.1 as well ;-)

What if I say chocolate?
Regardless, I think you should backport it at least to 3.1, and that it
makes sense to backport it to 2.6 too.
msg95454 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2009-11-18 21:00
Mmm, chocolate... ;-)

Okay, consider it done.
History
Date User Action Args
2022-04-11 14:56:54adminsetgithub: 51590
2009-11-18 21:00:44lars.gustaebelsetstatus: open -> closed
resolution: accepted
messages: + msg95454
2009-11-18 20:54:24pitrousetmessages: + msg95452
2009-11-18 20:52:00lars.gustaebelsetmessages: + msg95451
2009-11-18 20:36:31pitrousetmessages: + msg95450
2009-11-18 20:34:26lars.gustaebelsetmessages: + msg95449
2009-11-18 17:51:13paul.mooresetmessages: + msg95435
2009-11-18 17:07:26pitrousetmessages: + msg95432
2009-11-18 15:59:28paul.mooresetmessages: + msg95429
2009-11-18 13:43:43pitrousetmessages: + msg95428
2009-11-18 12:11:31lars.gustaebelsetfiles: + issue7341-3.x.diff

messages: + msg95425
2009-11-17 21:01:21pitrousetfiles: + tarfile.patch

type: resource usage
assignee: lars.gustaebel
versions: + Python 2.6, Python 2.7
keywords: + patch
nosy: + lars.gustaebel, pitrou

messages: + msg95402
stage: patch review
2009-11-17 19:50:15paul.moorecreate