On 10 June 2016 at 03:13, Barry Warsaw <ba...@python.org> wrote: > In my own experience, and IIRC Amber had a similar experience, the ease of > porting to Python 3 really comes down to how bytes/unicode clean your code > base is. Almost all the other pieces are either pretty manageable or fairly > easily automated. But if you're code isn't bytes-clean you're in for a world > of hurt because you first have to decide how to represent those things. > Twisted's job is especially fun because it's all about wire protocols, which I > think Amber described as (paraphrasing) bytes that happen to have contents > that look like strings.
Although I have much less experience with porting than many others in this thread, that's my experience as well. Get a clear and well-understood separation of bytes and strings, and the rest of the porting exercise is (relatively!) straightforward. But if you just once think "I'm not quite sure, but I think I just need to decode here to be safe" and you'll be fighting Unicode errors for ever. My hope is that static typing tools like MyPy could help here. I typically review Python 2 code by mentally categorising which functions (theoretically) take bytes, which take strings, and which are confused. And sort things out from there. Type annotations seem like they'd help that process. But I've yet to use typing in practice, so it may not be that simple. Paul _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com