rarfile history¶
Version 2.7 (2014-11-23)¶
Allow use of bsdtar as decompression backend. It sits on top of libarchive, which has support for reading RAR archives.
Limitations of
libarchiveRAR backend:- Does not support solid archives.
- Does not support password-protected archives.
- Does not support “parsing filters” used for audio/image/executable data, so few non-solid, non-encrypted archives also fail.
Now
rarfilechecks ifunrarand if not then triesbsdtar. If that works, then keeps using it. If not then configuration stays withunrarwhich will then appear in error messages.
Both
RarFileandis_rarfile()now accept file-like object. Eg.io.BytesIO. Only requirement is that the object must be seekable. This mirrors similar funtionality in zipfile.Based on patch by Chase Zhang.
Uniform error handling.
RarFileacceptserrors="strict"argument.Allow user to tune whether parsing and missing file errors will raise exception. If error is not raised, the error string can be queried with
RarFile.strerror()method.
Version 2.6 (2013-04-10)¶
- Add context manager support for
RarFileclass. BothRarFileandRarExtFilesupportwithstatement now. (Wentao Han) RarFile.volumelist()method, returns filenames of archive volumes.- Re-throw clearer error in case
unraris not found inPATH. - Sync new unrar4.x error code from
rar.txt. - Use Sphinx for documentation, push docs to rtfd.org
Version 2.5 (2012-01-19)¶
Fixes:
RarExtFile.read()andRarExtFile.readinto()now do looping read to work properly on short reads. Important for Python 3.2+ where read from pipe can return short result even on blocking file descriptor.- Proper error reporting in
RarFile.extract(),RarFile.extractall()andRarFile.testrar(). RarExtFile.read()from unrar pipe: prefer to return unrar error code, if thats not available, do own error checks.- Avoid string addition in
RarExtFile.read(), instead use always list+join to merge multi-part reads. - dumprar: dont re-encode byte strings (Python 2.x). This avoids unneccessary failure when printing invalid unicode.
Version 2.4 (2011-11-05)¶
Fixes:
USE_DATETIME: survive bad values from RAR- Fix bug in corrupt unicode filename handling
- dumprar: make unicode chars work with both pipe and console
Version 2.3 (2011-07-03)¶
Features:
- Support .seek() method on file streams. (Kristian Larsson)
- Support .readinto() method on file streams. Optimized implementation
is available on Python 2.6+ where
memoryviewis available. - Support file comments -
RarInfo.commentcontains decompressed data if available. - File objects returned by
RarFile.open()areio.RawIOBase-compatible. They can further wrapped withio.BufferedReaderandio.TextIOWrapper. - Now .getinfo() uses dict lookup instead of sequential scan when searching archive entry. This speeds up prococessing for archives that have many entries.
- Option
UNICODE_COMMENTSto decode both archive and file comments to unicode. It usesTRY_ENCODINGSfor list of encodings to try. If off, comments are left as byte strings. Default: 0 - Option
PATH_SEPto change path separator. Default:r'\', setrarfile.PATH_SEP='/'to be compatibe with zipfile. - Option
USE_DATETIMEto convert timestamps to datetime objects. Default: 0, timestamps are tuples. - Option
TRY_ENCODINGSto allow tuning attempted encoding list. - Reorder
RarInfofiels to better show zipfile-compatible fields. - Standard regtests to make sure various features work
Compatibility:
- Drop
RarInfo.unicode_filename, plainRarInfo.filenameis already unicode since 2.0. - .read(-1) reads now until EOF. Previously it returned empty buffer.
Fixes:
- Make encrypted headers work with Python 3.x bytes() and with old 2.x ‘sha’ module.
- Simplify
subprocess.Popenusage when launchingunrar. Previously it tried to optimize and work around OS/Python bugs, but this is not maintainable. - Use temp rar file hack on multi-volume archives too.
- Always .wait() on unrar, to avoid zombies
- Convert struct.error to BadRarFile
- Plug some fd leaks. Affected: Jython, PyPy.
- Broken archives are handled more robustly.
Version 2.2 (2010-08-19)¶
Fixes:
- Relaxed volume naming. Now it just calculates new volume name by finding number in old one and increasing it, without any expectations what that number should be.
- Files with 4G of compressed data in one colume were handled wrong. Fix.
- DOS timestamp seconds need to be multiplied with 2.
- Correct EXTTIME parsing.
Cleanups:
- Compressed size is per-volume, sum them together, so that user sees complete compressed size for files split over several volumes.
- dumprar: Show unknown bits.
- Use
struct.Structto cache unpack formats. - Support missing
os.devnull. (Python 2.3)
Version 2.1 (2010-07-31)¶
Features:
- Minimal implmentation for
RarFile.extract(),RarFile.extractall(),RarFile.testrar(). They are simple shortcuts tounrarinvocation. - Accept
RarInfoobject where filename is expected. - Include
dumprar.pyin .tgz. It can be used to visualize RAR structure and test module. - Support for encrypted file headers.
Fixes:
- Don’t read past ENDARC, there could be non-RAR data there.
- RAR 2.x: It does not write ENDARC, but our volume code expected it. Fix that.
- RAR 2.x: Support more than 200 old-style volumes.
Cleanups:
- Load comment only when requested.
- Cleanup of internal config variables. They should have now final names.
RarFile.open(): Add mode=r argument to match zipfile.- Doc and comments cleanup, minimize duplication.
- Common wrappers for both compressed and uncompressed files,
now
RarFile.open()also does CRC-checking.
Version 2.0 (2010-04-29)¶
Features:
- Python 3 support. Still works with 2.x.
- Parses extended time fields. (.mtime, .ctime, .atime)
RarFile.open()method. This makes possible to process large entries that do not fit into memory.- Supports password-protected archives.
- Supports archive comments.
Cleanups:
- Uses
subprocessmodule to launchunrar. - .filename is always Unicode string, .unicode_filename is now deprecated.
- .CRC is unsigned again, as python3 crc32() is unsigned.
Version 1.1 (2008-08-31)¶
Fixes:
- Replace
os.tempnam()withtempfile.mkstemp(). (Jason Moiron) - Fix infinite loop in _extract_hack on unexpected EOF
RarInfo.CRCis now signed value to match crc32()RarFile.read()now checks file crc
Cleanups:
- more docstrings
- throw proper exceptions (subclasses of
rarfile.Error) - RarInfo has fields pre-initialized, so they appear in help()
- rename RarInfo.data to RarInfo.header_data
- dont use “print” when header parsing fails
- use try/finally to delete temp rar
Version 1.0 (2005-08-08)¶
- First release.