matllubos / mimeparse

Automatically exported from code.google.com/p/mimeparse
MIT License
0 stars 0 forks source link

Poor error message for invalid mime types #21

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

mhaase@ubuntu:~$ python
Python 2.7.3 (default, Aug  1 2012, 05:14:39) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mimeparse
>>> mimeparse.best_match(['text/plain', 'application/json'], 'foo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/mimeparse.py", line 153, in best_match
    parsed_header = [parse_media_range(r) for r in split_header]
  File "/usr/local/lib/python2.7/dist-packages/mimeparse.py", line 67, in parse_media_range
    (type, subtype, params) = parse_mime_type(range)
  File "/usr/local/lib/python2.7/dist-packages/mimeparse.py", line 48, in parse_mime_type
    (type, subtype) = full_type.split('/')
ValueError: need more than 1 value to unpack

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

There should be a specific type of exception indicating a malformed content 
type.

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

>>> mimeparse.__version__
'0.1.4'

Original issue reported on code.google.com by meha...@gmail.com on 11 Jun 2013 at 9:14