[PATCH] setup.py: Adjustments to make setup.py run in py3k
Antoine Pitrou
solipsis at pitrou.net
Tue Jun 15 12:54:36 CDT 2010
Renato Cunha <renatoc <at> gmail.com> writes:
>
> +try:
> + bytes
> +except NameError:
> + def bytes(str, encoding=None):
> + return str
For consistency with 2.6+, it should return str.encode(encoding) instead.
Also, you shouldn't put a default value for `encoding`, because it doesn't match
the py3k API (if you create a bytes() object from an str() object, you /have/ to
specify the encoding in py3k):
>>> bytes("abc")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: string argument without an encoding
>>> bytes("abc", "utf-8")
b'abc'
Regards
Antoine.
More information about the Mercurial-devel
mailing list