[Imported from Trac: page Python3, version 39]

itamarst 2020-10-15 13:45:15 +00:00
parent bd3c3dd30d
commit 136ea76380

@ -142,3 +142,14 @@ One of them is the `bytes` objects:
## Don't leak Future objects
Leaking Future objects (newints, new dicts, new bytes) in module API can break existing code on Python 2. So need to be careful not to do that. For that reason int isn't in the suggested `from builtins import ...` list above.
## Dealing with utility modules
Often you will have some utility module with lots of random code, some of which doesn't work on Python 3, or which even involves imports of non-Python-3-compatbile code (Nevow, in this case).
Options:
1. Create new `util_py3.py` module, move just the things you need, have `util.py` import code from there.
2. Add conditional imports/declarations to `util.py` so it imports on Python 3 and at least some of the code can be made to work.
Originally we went with first approach, but plausibly second approach is better.