[issue17878] There is no way to get a list of available codecs

Dmi Baranov report at bugs.python.org
Thu May 2 17:35:50 CEST 2013


Dmi Baranov added the comment:

My +1 for __iter__ with default `raise StopIteration`, it is more elegant solution than declaration and guarantee of the interfaces (based at collections.abc.Callable and collections.abc.Iterator).
 
Paul, result as iterable of CodecInfo objects is gives much more flexibility than the names of codecs (whats if you will have a few codecs with the same name in different SearchObjects?)

As I see, you would like use this as:

encoded_data = 'abc'
for codecs in codecs.registered_codecs():
 decoded_data = codecs.decode(data)
 if decoded_data == 'cba': # cracked
  break

Whats about backward compatibly with Lib/encoding modules (initial item in interp->codec_search_path)? Can we skip anything in search_path, if its not supports iteration?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17878>
_______________________________________


More information about the Python-bugs-list mailing list