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.
Created on 2008年06月05日 02:22 by jkankiewicz, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| tarfile.TarFileCompat.patch | jkankiewicz, 2008年06月05日 02:22 | Patch against r63744 of python/trunk/Lib/tarfile.py | ||
| Messages (2) | |||
|---|---|---|---|
| msg67708 - (view) | Author: Jason Kankiewicz (jkankiewicz) | Date: 2008年06月05日 02:22 | |
tarfile.TarFileCompat.writestr( self, zinfo, bytes ) raises
AttributeError("'ZipInfo' object has no attribute 'name'") because an
analog to the tarfile.TarInfo.name attribute cannot be monkeypatched
into the zinfo argument value when it's an instance of zipfile.ZipInfo.
The zipfile.ZipInfo class' attributes are slots, so no ad hoc attributes
can be monkeypatched into an instance of it.
I've replaced the monkeypatching of zinfo with the creation of a new
tarfile.TarInfo object, tinfo, which receives its relevant values instead.
This revealed another problem with the assignment of zinfo.file_size to
tinfo.size: if zinfo.file_size has not been assigned a value then an
AttributeError("file_size") will be raised because the slotted attribute
doesn't exist.
Being that the documentation for zipfile.ZipFile.writestr( self,
zinfo_or_arcname, bytes ) claims that a zipfile.ZipInfo object value for
zinfo_or_arcname must contain "at least the filename, date and time",
it's highly likely that zinfo.file_size will be unassigned in ordinary use.
I fixed this problem by ignoring the value of zinfo.file_size and using
the value of len(bytes) instead, just like the implementation of
zipfile.ZipFile.writestr.
I would have provided a patch for tarfile.TarFileCompat.writestr's unit
test suite, but it doesn't appear to exist.
|
|||
| msg70626 - (view) | Author: Lars Gustäbel (lars.gustaebel) * (Python committer) | Date: 2008年08月02日 11:48 | |
Thank you very much for your patch, I applied it to the trunk as r65402. However, I decided to remove the TarFileCompat class from the Python 3.0 branch, see http://mail.python.org/pipermail/python-3000/2008-July/014448.html for details. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:35 | admin | set | github: 47289 |
| 2008年08月02日 11:48:35 | lars.gustaebel | set | status: open -> closed resolution: accepted messages: + msg70626 |
| 2008年06月05日 12:02:14 | lars.gustaebel | set | assignee: lars.gustaebel nosy: + lars.gustaebel |
| 2008年06月05日 02:22:46 | jkankiewicz | create | |