1. Benoit Chesneau
  2. django-authopenid

Commits

Ross Poulton  committed 864b143

Implement fix for #54 - "ValueError: too many values to unpack"
Uses fix from @ramusus, https://bitbucket.org/benoitc/django-authopenid/issue/54/type-subtype-parts-0-split-valueerror-too

  • Participants
  • Parent commits b0e654e
  • Branches trunk

Comments (0)

Files changed (1)

File django_authopenid/utils/mimeparse.py

View file
 
        ('application', 'xhtml', {'q', '0.5'})
        """
-    parts = mime_type.split(";")
-    params = dict([tuple([s.strip() for s in param.split("=")])\
-            for param in parts[1:] ])
-    (type, subtype) = parts[0].split("/")
+    import re
+    parts = re.split(r'[,|;]', mime_type)
+    params = dict([tuple([s.strip() for s in param.split("=")]) for param in parts[1:] if param.count("=")])
+    (type, subtype) = parts[0].split("/") if parts[0].count("/") else (parts[0], parts[0])
     return (type.strip(), subtype.strip(), params)
 
 def parse_media_range(range):
             # match using a wildcard for both requested and supported 
             self.assertEqual(best_match(mime_types_supported, 'image/*'), 'image/*')
 
-    unittest.main() 
+    unittest.main()