lebauce / quodlibet

Automatically exported from code.google.com/p/quodlibet
1 stars 0 forks source link

EasyID3 - .has_key() with keys not in valid_keys throw exception - ducktypting? #170

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
from mutagen.easyid3 import EasyID3

m = EasyID3("test.mp3")

'certainlyNot' in m

# This throws an error!
# It seems, that keys that are not in "valid_keys"
# behave badly, this is uncool for ducktypting
# This happens with mutagen released with quodliet 2.0

Original issue reported on code.google.com by army.of....@gmail.com on 1 Apr 2009 at 3:53

GoogleCodeExporter commented 9 years ago
While I love ducktyping, here is not a good place for it, as an invalid key can 
never 
be added to an EasyID3 instance. Allowing silent checks for it would result in 
code 
setting a default like below failing late. If you want to support arbitrary 
keys in 
some other fashion, wrap EasyID3, or wrap ID3 directly (like EasyID3 does).
{{{
if key not in m:
    m[key] = 'blah'
}}}

Original comment by mur...@gmail.com on 2 Apr 2009 at 2:35