You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fixing tarfile._mode when using gzip via ":gz" #62775
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2013-07-28.08:35:14.482>labels= ['type-bug', 'library']
title='Fixing tarfile._mode when using gzip via ":gz"'updated_at=<Date2013-09-20.19:24:34.339>user='https://bugs.python.org/edulix'
A TarFile object constructor accepts a fileobj argument. When this argument is set and it has a "mode" property, tarfile._mode is blindly copied from there. Otherwise, mode is set using the mode argument in the constructor.
This usually works, but in the case where fileobj is a gzip.GzipFile, the "mode" property is not a string like "rb" or "wb" but an integer, which is not expected in TarFile.
This has not been noticed before probably because the TarFile._mode property is usually unused internally, but in my case it's a problem when using it together with tarfile multivolume mode provided in issue bpo-18321.
Activity
edulix commentedon Jul 28, 2013
A TarFile object constructor accepts a fileobj argument. When this argument is set and it has a "mode" property, tarfile._mode is blindly copied from there. Otherwise, mode is set using the mode argument in the constructor.
This usually works, but in the case where fileobj is a gzip.GzipFile, the "mode" property is not a string like "rb" or "wb" but an integer, which is not expected in TarFile.
This has not been noticed before probably because the TarFile._mode property is usually unused internally, but in my case it's a problem when using it together with tarfile multivolume mode provided in issue bpo-18321.
edulix commentedon Jul 28, 2013
Fixing gzip.patch, it was using basestring (python2) instead of str
serhiy-storchaka commentedon Sep 20, 2013
Perhaps we should rather change GzipFile.mode to be a string?
serhiy-storchaka commentedon Apr 21, 2024
It is now a string since #115961.