Bug#642020: python-debian: ArFile (via DebFile) errors when given only a fileobj
Mel Collins
mel at raumkraut.net
Sun Sep 18 16:43:08 UTC 2011
Package: python-debian
Version: 0.1.14ubuntu2
Severity: normal
Tags: patch
Currently (tested using trunk), ArFile assumes that it will always receive a filename, and that filename relates to the local filesystem.
This means that, when instantiating a DebFile using only a fileobj parameter, you get something like:
>>> from debian import debfile
>>> package = debfile.DebFile(fileobj=open('some-package.deb', 'r'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/python_debian-_CHANGELOG_VERSION_-py2.6.egg/debian/debfile.py", line 236, in __init__
self.__version = f.read().strip()
File "/usr/local/lib/python2.6/dist-packages/python_debian-_CHANGELOG_VERSION_-py2.6.egg/debian/arfile.py", line 211, in read
self.__fp = open(self.__fname, "r")
TypeError: coercing to Unicode: need string or buffer, NoneType found
The solution I've come up with will involve DebFile sharing the fileobj among several ArFile instances (is there a way to clone file-like objects?), which means ArFiles keep an internal seek-location, and don't actually close() the file pointer (leaky?).
A patch should be attached, or there is my fork on GitHub:
https://github.com/Raumkraut/python-debian
-- System Information:
Debian Release: squeeze/sid
APT prefers lucid-updates
APT policy: (500, 'lucid-updates'), (500, 'lucid-security'), (500, 'lucid')
Architecture: i386 (i686)
Kernel: Linux 2.6.32-33-generic-pae (SMP w/2 CPU cores)
Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages python-debian depends on:
ii python 2.6.5-0ubuntu1 An interactive high-level object-o
ii python-apt 0.7.94.2ubuntu6.4 Python interface to libapt-pkg
ii python-support 1.0.4ubuntu1 automated rebuilding support for P
python-debian recommends no packages.
Versions of packages python-debian suggests:
ii gpgv 1.4.10-2ubuntu1 GNU privacy guard - signature veri
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fileobj.diff
Type: text/x-diff
Size: 4934 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-python-debian-maint/attachments/20110918/3f3c476a/attachment.diff>
More information about the pkg-python-debian-maint
mailing list