[New-bugs-announce] [issue14013] tarfile should expose supported formats

Éric Araujo report at bugs.python.org
Tue Feb 14 17:27:27 CET 2012

New submission from Éric Araujo <merwok at netwok.org>:

shutil contains high-level functions to create a zipfile or a tarball.  When a new format is added to the tarfile module, then shutil needs to be updated manually.  If tarfile exposed the names of the compressors it supports, then shutil could just automatically support everything that tarfile supports instead of having to re-do import dances for optional modules (bz2, lzma, zlib) and also duplicate formats in its doc.

This may also be useful for other code wanting to do some introspection.

Attached patch implements tarfile.formats, a list of strings (I thought about using a frozenset but then followed the precedent set by the 3.3 crypt module).  Tests and docs not updated, I wanted to get Lars’ approval on the principle first.

One could argue that this is not needed: compression modules are not added often; updating shutil after updating tarfile is not hard; it is not that useful to have access to the list of supported formats.

assignee: docs at python
components: Documentation, Library (Lib)
messages: 153350
nosy: docs at python, eric.araujo, lars.gustaebel, nadeem.vawda
priority: normal
severity: normal
stage: patch review
status: open
title: tarfile should expose supported formats
type: enhancement
versions: Python 3.3

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list