Re:Mercurial’s journey to and reflections on Python 3
by acdha on Monday January 13, 2020 @09:13PM
(#22041176)
That example works fine in both Python 2 and 3 if you’re not mixing types incorrectly. If you are, it will appears to work on Python 2 before failing the first time you encounter non-ASCII data and tends to greatly confuse people with errors which would have been caught immediately on Python 3. I’ve seen teams waste hours trying to track down errors like that.
[ Parent
| on HN ]
Re:Mercurial’s journey to and reflections on Python 3
by zo1 on Tuesday January 14, 2020 @02:06AM
(#22042532)
Exactly this. The amount of times I saw juniors fixing thses sort of obscure subtle bugs with str_var.decode("utf-8").encode("latin-1") and this after attempting every which combination of the above two de/encode operations is mind boggling.
Re:Mercurial’s journey to and reflections on Python 3
by reubenmorais on Tuesday January 14, 2020 @04:59AM
(#22043349)
It works after Python 3.5. From the article:
> Another feature was % formatting of strings. Python 2 allowed use of the % formatting operator on both its string types. But Python 3 initially removed the implementation of % from bytes. Why, I have no clue. It is perfectly reasonable to splice byte sequences into a buffer via use of a formatting string. But the Python language maintainers insisted otherwise. And it wasn't until the community complained about its absence loudly enough that this feature was restored in Python 3.5, which was released in September 2015.