[issue8401] Strange behavior of bytearray slice assignment

Eugene Kapun report at bugs.python.org
Sat Apr 17 16:15:44 CEST 2010


Eugene Kapun <abacabadabacaba at gmail.com> added the comment:

-1 on special-casing string without an encoding. Current code does (almost) this:
...
if argument_is_a_string:
	if not encoding_is_given: # Special case
		raise TypeError("string argument without an encoding")
	encode_argument()
	return
if encoding_is_given:
	raise TypeError("encoding or errors without a string argument")
...
IMO, it should do this instead:
...
if encoding_is_given:
	if not argument_is_a_string:
		raise TypeError("encoding or errors without a string argument")
	encode_argument()
	return
...
This way, bytearray("") would work without any special cases.

----------

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


More information about the Python-bugs-list mailing list