Author martin.panter
Recipients lars.gustaebel, markgrandi, martin.panter, pitrou, r.david.murray
Date 2015-03-24.03:36:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
If you read the documentation it is clear that gettarfile() requires an OS file, so won’t work with an internal Python-only file object. Maybe the documentation could be tweaked, but I don’t think the gettarfile() implementation should be changed. To me the whole point of it is to call fstat() on the file and fill in the TarInfo attributes appropriately.

Instead, perhaps an enhancement could be made that allowed something like this:

metadata = TarInfo.make_file('helloworld.txt', len(b))
tarFileObj.addfile(metadata, io.BytesIO(b))

The corresponding TarInfo class could grow new presets looking something like:

class TarInfo:
    def make_file(cls, name, size):  # Name and size are mandatory
        self = cls(name)
        self.type = REGTYPE
        self.size = size
        self.mtime = None  # Force addfile() to set it to some default time.time() value
        self.mode = 0o644
        return self
    def make_executable(cls, name, size):
        self.mode = 0o755
    def make_directory(cls, name):
        self.type = DIRTYPE
    def make_hard_link(cls, name, target)
    def make_symlink(cls, name, target)
    def make_block_device(cls, name, major, minor)  # Set undocumented attributes
    def make_char_device(cls, name, major, minor)
Date User Action Args
2015-03-24 03:36:29martin.pantersetrecipients: + martin.panter, lars.gustaebel, pitrou, r.david.murray, markgrandi
2015-03-24 03:36:29martin.pantersetmessageid: <>
2015-03-24 03:36:29martin.panterlinkissue22208 messages
2015-03-24 03:36:28martin.pantercreate