SDist raises TypeError when initializing

Bug #733827 reported by rubik
258
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pkginfo
Fix Released
Undecided
Tres Seaver

Bug Description

When I try to initialize a sdist distribution a TypeError is raised:
>>> p = SDist('Sphinx-1.0.7.tar.gz')

---------------------------------------------------------------------------
TypeError Traceback (most recent call last)

/home/miki/<ipython console> in <module>()

/usr/local/lib/python2.7/dist-packages/pkginfo/sdist.pyc in __init__(self, filename, metadata_version)
     10 self.filename = filename
     11 self.metadata_version = metadata_version
---> 12 self.extractMetadata()
     13
     14 def read(self):

/usr/local/lib/python2.7/dist-packages/pkginfo/distribution.pyc in extractMetadata(self)
    108 def extractMetadata(self):
    109 data = self.read()
--> 110 self.parse(data)
    111
    112 def read(self):

/usr/local/lib/python2.7/dist-packages/pkginfo/distribution.pyc in parse(self, data)
    117
    118 def parse(self, data):
--> 119 fp = StringIO(data)
    120 msg = parse(fp)
    121

TypeError: initial_value must be unicode or None, not str

Related branches

rubik (michelelacchia)
visibility: private → public
Revision history for this message
Tres Seaver (tseaver) wrote :

Thanks for the bug report. It looks like Python 2.7's io backport broke us
here..

Changed in pkginfo:
assignee: nobody → Tres Seaver (tseaver)
status: New → In Progress
Tres Seaver (tseaver)
Changed in pkginfo:
status: In Progress → Fix Released
Revision history for this message
rubik (michelelacchia) wrote :

I saw that adding unicode() in distribution.py:119 it works:

    fp = StringIO(unicode(data))

Revision history for this message
Sridhar Ratnakumar (srid) wrote :

Looks like this introduced a regression in 0.8:

    def __init__(self):
> self.extractMetadata()

pypm/grail/veneer.py:297:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <pypm.grail.veneer.Distribution2 object at 0x101e5be10>

    def extractMetadata(self):
        data = self.read()
> self.parse(data)

lib/python2.7/site-packages/pkginfo/distribution.py:110:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <pypm.grail.veneer.Distribution2 object at 0x101e5be10>
data = u'Metadata-Version: 1.0\nName: zope.interface\nVersion: 3.6.1\nSummary: Interf....1\nClassifier: Topic :: Software Development :: Libraries :: Python Modules\n'

    def parse(self, data):
> fp = StringIO(data)
E TypeError: 'unicode' does not have the buffer interface

lib/python2.7/site-packages/pkginfo/distribution.py:119: TypeError

Revision history for this message
Tres Seaver (tseaver) wrote :

I'm sorry, but your report doesn't give me enough information to figure out whether / how the fix released for this bug caused a regression. Please provide the full traceback, as well as the command line you used to provoke the error.

Revision history for this message
Tres Seaver (tseaver) wrote :

OK, I've managed to reconstruct the error: you are constructing a unicode literal and
passing it to 'parse()'. I have added code which checks for that and converts it using 'str()',
which will work only if you have no non-encodable characters in the unicode (given the
default system encoding).

 http://bazaar.launchpad.net/~tseaver/pkginfo/trunk/revision/69

To post a comment you must log in.
This report contains Public Security information  
Everyone can see this security related information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.