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

ValueError in 1.3 python version #2

Closed
dbtsai opened this issue Aug 24, 2012 · 4 comments
Closed

ValueError in 1.3 python version #2

dbtsai opened this issue Aug 24, 2012 · 4 comments

Comments

@dbtsai
Copy link
Collaborator

dbtsai commented Aug 24, 2012

What steps will reproduce the problem?
In [3]: mimeparse.parse_mime_type("text/html, image/gif, image/jpeg, ; q=.2, */; q=.2")

What is the expected output? What do you see instead?

In [3]: mimeparse.parse_mime_type("text/html, image/gif, image/jpeg, ; q=.2, */; q=.2")

ValueError Traceback (most recent call last)
/tmp/ in ()
/tmp/mimeparse.py in parse_mime_type(mime_type)
36 # Turn it into a legal wildcard.
37 if full_type == '': full_type = '/*'
---> 38 (type, subtype) = full_type.split("/")
39 return (type.strip(), subtype.strip(), params)
40
ValueError: too many values to unpack

What version of the product are you using? On what operating system?
1.3

Please provide any additional information below.
https://bitbucket.org/benoitc/django-authopenid/issue/54/type-subtype-parts-0-split-valueerror-too#comment-483268

@dbtsai
Copy link
Collaborator Author

dbtsai commented Aug 24, 2012

Yup, also: '/,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,image/png,;q=0.5, application/vnd.nokia.headwrapper'

@dbtsai
Copy link
Collaborator Author

dbtsai commented Aug 24, 2012

Specifically, this breaks the parser: /,text/xml

@zbyte64
Copy link

zbyte64 commented Dec 4, 2012

I get the same issue:

>>> import mimeparse
>>> mimeparse.parse_mime_type('text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/jason/Repos/hyperadmindemo/local/lib/python2.7/site-packages/mimeparse.py", line 38, in parse_mime_type
    (type, subtype) = full_type.split("/")
ValueError: too many values to unpack

@pjz
Copy link

pjz commented Oct 9, 2013

parse_mime_type() is for parsing one mime type, possibly with quality metrics, not for parsing a list of mime types. If you want to parse a list, split the list on commas then feed each result to parse_mime_type(), like:

types = [ mimeparse.parse_mime_type(t) for t in "/,text/html".split('.') ]

@dbtsai dbtsai closed this as completed Feb 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants