Hacker News new | ask | show | jobs
by walrus1066 2701 days ago
Imagine that's part of the challenge. Since python is dynamically typed/duck typed, it's hard to audit all usages of a variable. I.e. If I see a py2 string declared, how can I be 100% sure I don't break downstream components by making it a bytes or py3 unicode string? Some might be using it as the former, others the latter.

You'd need insane test coverage, of all possible code paths, to be 100% confident.

1 comments

I was responsible for the Python 2 to 3 migration for various code bases at work. I used 2to3 to check for issues, but did most of the code rewrites by hand.

Most of the conversion difficulties were related to Unicode/text/binary string handling in Python 3, and 2to3 didn't catch all of them. This was the biggest challenge of the entire process. Stuff would fail in production because due to improper string handling. Python 2 was remarkably permissive (i.e. loosy goosey), whereas Python 3 is stricter and arguably more correct, but this strictness has a cost.

The other class of problems is the restructure of certain std libs, like urllib. We took the opportunity to move away from "urllib" to "requests".

This site [1] was invaluable in understanding the migration issues.

All in all, apart from breaking Unicode issues, the migration process was fairly easy.

[1] http://python3porting.com/problems.html