Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tarfile module does not correctly choose compression algorithms #67609

Closed
wdv4758h mannequin opened this issue Feb 9, 2015 · 11 comments
Closed

tarfile module does not correctly choose compression algorithms #67609

wdv4758h mannequin opened this issue Feb 9, 2015 · 11 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@wdv4758h
Copy link
Mannequin

wdv4758h mannequin commented Feb 9, 2015

BPO 23421
Nosy @berkerpeksag, @serhiy-storchaka
Files
  • fix_compressions_dict.patch: fix compressions dict in tarfile module
  • add_tarfile_cli_filetype_test.patch: tests for tarfile CLI
  • add_tarfile_cli_filetype_test_refactor.patch: fix compressions dict in tarfile module (refactored)
  • 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 = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2015-02-10.06:49:38.549>
    created_at = <Date 2015-02-09.13:03:37.079>
    labels = ['type-bug', 'library']
    title = 'tarfile module does not correctly choose compression algorithms'
    updated_at = <Date 2015-02-10.06:49:38.548>
    user = 'https://bugs.python.org/wdv4758h'

    bugs.python.org fields:

    activity = <Date 2015-02-10.06:49:38.548>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2015-02-10.06:49:38.549>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2015-02-09.13:03:37.079>
    creator = 'wdv4758h'
    dependencies = []
    files = ['38056', '38059', '38079']
    hgrepos = ['297', '298', '299']
    issue_num = 23421
    keywords = ['patch']
    message_count = 11.0
    messages = ['235604', '235606', '235608', '235609', '235611', '235623', '235626', '235668', '235669', '235671', '235672']
    nosy_count = 4.0
    nosy_names = ['python-dev', 'berker.peksag', 'serhiy.storchaka', 'wdv4758h']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue23421'
    versions = ['Python 3.4', 'Python 3.5']

    @wdv4758h
    Copy link
    Mannequin Author

    wdv4758h mannequin commented Feb 9, 2015

    The command "python -m tarfile -c test.tar.bz2 test/" should create a file that is compressed by bzip2,
    but actually the detection of compression algorithm that should be used is broken (for gz, xz, bz2).

    fix it by prepending a dot to the keys of the dictionary

    @wdv4758h wdv4758h mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Feb 9, 2015
    @serhiy-storchaka
    Copy link
    Member

    Thank you for your patch. Could you provide tests?

    @wdv4758h
    Copy link
    Mannequin Author

    wdv4758h mannequin commented Feb 9, 2015

    yes

    just wanna know is there a standard way to get file type by libmagic ?

    @serhiy-storchaka
    Copy link
    Member

    No need to use libmagic. tarfile.TarFile.gzopen() should fail if the file is not gzipped tar file. There CLI tests in Lib/test/test_tarfile.py. New test should create tar file with file name that ends with the '.gz' extension and check that it can be open and read with gzopen().

    @wdv4758h
    Copy link
    Mannequin Author

    wdv4758h mannequin commented Feb 9, 2015

    Oh, I can use it.
    thx

    @wdv4758h
    Copy link
    Mannequin Author

    wdv4758h mannequin commented Feb 9, 2015

    Here is the tests.

    @serhiy-storchaka
    Copy link
    Member

    In general LGTM, but I have added few nitpicks on Rietveld.

    @serhiy-storchaka serhiy-storchaka self-assigned this Feb 9, 2015
    @wdv4758h
    Copy link
    Mannequin Author

    wdv4758h mannequin commented Feb 10, 2015

    Attached factored patch for tests.

    It looks much better. :)

    @wdv4758h
    Copy link
    Mannequin Author

    wdv4758h mannequin commented Feb 10, 2015

    s/factored/refactored/

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Feb 10, 2015

    New changeset 2a06379f6562 by Serhiy Storchaka in branch '3.4':
    Issue bpo-23421: Fixed compression in tarfile CLI. Patch by wdv4758h.
    https://hg.python.org/cpython/rev/2a06379f6562

    New changeset 5b70eb1cfad0 by Serhiy Storchaka in branch 'default':
    Issue bpo-23421: Fixed compression in tarfile CLI. Patch by wdv4758h.
    https://hg.python.org/cpython/rev/5b70eb1cfad0

    @serhiy-storchaka
    Copy link
    Member

    Thank you for your contribution.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant