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: tarfile: path problem in arcname under windows
Type: behavior Stage:
Components: Library (Lib), Windows Versions: Python 2.6, Python 2.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: lars.gustaebel Nosy List: amaury.forgeotdarc, ellioh, lars.gustaebel, loewis
Priority: normal Keywords:

Created on 2009-03-17 15:36 by ellioh, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
reproduce_issue5500.zip ellioh, 2009-03-19 14:37 How to reproduce
Messages (7)
msg83680 - (view) Author: Elijah Merkin (ellioh) Date: 2009-03-17 15:35
Tested on Python 2.5.4.

1. Use tarfile.open("fname", "w|gz") to create an archive.
2. Add a file using TarFile.add(name, arcname=None, recursive=True,
exclude=None) by specifying 2 params: absolute path to a source file as
'name' and something containing one or more directories, e.g.
'test/myfile.txt' as 'arcname'.
3. Close the archive.

On Linux file is added as 'test/myfile.txt'. On Windows the full path
specified as 'name' is used (e.g. 'D:\\MyDir\\myfile.txt'). When I use
'w|bz2' everything works correctly.

Probably this bug is somewhat similar to a bug #4750, though it happens
under Windows and doesn't happen under Linux.
msg83692 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-03-17 19:38
Lars, what do you think?
msg83775 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2009-03-18 20:47
At the moment, I am unable to reproduce the problem you describe. I
tried several combinations of what I think you could have meant, but
everything seems to work okay here.
Could you please provide some stand-alone testcase or code to illustrate
that issue?
msg83810 - (view) Author: Elijah Merkin (ellioh) Date: 2009-03-19 14:37
Tested again under Python 2.6.1 on Windows XP (added Python 2.6 to
versions).

An archive I attached to the issue contains a .py file that reproduces
the bug and an archive created by it.

In my case I just put the .py file to C:\testtarfile\ directory and run it.

When I open the file by any archive manager I have in Windows, I see.
When I view the file contents in a hex viewer, I also see
'C:\\testtarfile\...', so the problem really exists. However, when
uncompressing the archive on Linux (tar -xzf ...) I get
'test/testtarfile.py' as initially expected.

 The archive is created, and the path in the archive is
'C:\\testtarfile\\testtarfile.py', not 'test/testtarfile.py' as I would
expect.
msg83811 - (view) Author: Elijah Merkin (ellioh) Date: 2009-03-19 14:50
Sorry for not explaining properly, I was distracted.

1. The absolute path really exists in the .tar.gz file when I view it in
a hex editor.
2. Windows archive managers I tried see that absolute path.
3. Linux tar utility, however, somehow manages to extract the file
correctly to the original relative path.

That's very strange...
msg93431 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-10-02 09:44
> The archive is created, and the path in the archive is 
> 'C:\\testtarfile\\testtarfile.py', not 'test/testtarfile.py' 
> as I would expect.

I don't see the path you mention. Which archive manager do you use?
I tried with 7-zip, and it shows that I can browse to a path named
C:\testtarfile\tarfiletst.tar.gz\C:\testtarfile\tarfiletst.tar\test\
which contains testtarfile.py.

C:\testtarfile\tarfiletst.tar.gz contains
"C:\testtarfile\tarfiletst.tar", which itselfs contains
"test\testtarfile.py"

IOW, 7-zip simply fails to understand the .tar.gz format as a single
compressed archive.
To extract it properly, it's easy enough to browse the content until you
open the content of the .tar.
msg94652 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2009-10-29 09:57
I suppose this issue is related to issue4750 which I have just closed.
If not, please reopen this issue.
History
Date User Action Args
2022-04-11 14:56:46adminsetgithub: 49750
2009-10-29 09:57:59lars.gustaebelsetstatus: open -> closed
resolution: duplicate
messages: + msg94652
2009-10-02 09:44:27amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg93431
2009-03-19 14:50:18elliohsetmessages: + msg83811
2009-03-19 14:37:08elliohsetfiles: + reproduce_issue5500.zip

messages: + msg83810
versions: + Python 2.6
2009-03-18 20:47:57lars.gustaebelsetmessages: + msg83775
2009-03-17 19:38:15loewissetassignee: lars.gustaebel

messages: + msg83692
nosy: + loewis, lars.gustaebel
2009-03-17 15:36:00elliohcreate