From 9cc03988645d7c7671625823a7f587da6da9488b Mon Sep 17 00:00:00 2001 From: jaraco <> Date: Mon, 15 Feb 2021 18:19:21 +0000 Subject: [PATCH] Update fourth step again, this time to delete all instances of from builtins import name [Imported from Trac: page Python3, version 75] --- Python3.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Python3.md b/Python3.md index 88fce5f..6e7256d 100644 --- a/Python3.md +++ b/Python3.md @@ -119,10 +119,12 @@ if PY2: This adds builtins that match Python 3's semantics. The `#noqa: F401` keeps flake8/pyflakes from complaining about unused imports. We do unused imports so that people changing code later don't have to manually check if `map()` is old style or new style. +Then, delete any instances of `from builtins import `. + Consider using this sed command to execute the above: ``` -$ sed -ie '/from future import standard_library/d;/standard_library.install_aliases()/d;/from builtins import str/d;s/from builtins import \*/from future.utils import PY2\\nif PY2:\\n from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401/' src/allmydata/test/test_runner.py +$ sed -ie '/from future import standard_library/d;/standard_library.install_aliases()/d;s/from builtins import \*/from future.utils import PY2\\nif PY2:\\n from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401/;/from builtins import .*/d' path/to/file.py ``` **Fourth**, manually review the code. Futureize is nice, but it very definitely doesn't catch everything, or it makes wrong decisions.