[PATCH 01 of 10] py3: use unicode literals in encoding.py

Yuya Nishihara yuya at tcha.org
Thu Aug 4 08:42:22 EDT 2016


On Thu, 04 Aug 2016 00:18:19 +0900, FUJIWARA Katsunori wrote:
> If (almost) all of operations with string literal in target source
> code requires unicode-ness on Python 3.x, this omitting can reduce
> adding explicit 'u' prefix to existing string literals.
> 
> For example, all operations with string literal in demandimport.py are
> related to APIs below, which accept only unicode (as str) on Python
> 3.x.
> 
>   - manipulate module name
>     split(), formatting with "%s", __contains__(), and so on
>   - access to attributes by name
>   - access to values in os.environ
>   - access to values in sys.builtin_module_names
> 
> pycompat.py and i18n.py also seem to work with this omitting. At short
> glance, maybe, pure/osutil.py does, too ? (a few extra explicit 'b'
> prefix might be needed, though)

i18n.setdatapath() would need b'locale', and pure.osutil.posixfile() would
need b'r', b'w', etc. because u'r' != b'r' on Python 3.

I don't think it's good idea to switch b''/u'' requirement per file.


More information about the Mercurial-devel mailing list