diff --git a/Python3.md b/Python3.md index 2d1d8a6..4c5f9f3 100644 --- a/Python3.md +++ b/Python3.md @@ -81,6 +81,17 @@ In particular: **Fifth**, add a note to the module docstring saying it was ported to Python 3. -### Other notes +## Known issues with `future` + +The `from builtins import ` thing gives a decent Python 3 layer for Python 2. For example it'll automatically create `*nonzero*` to wrap a `*bool*`. + +But there are caveats. + +One of them is the `bytes` objects: + +1. `builtins.bytes.translate` are `builtins.bytes.maketrans` buggy on [PyPy](PyPy). One way to fix this is with a `if PY2: translate = string.translate else: translate = bytes.translate`. +2. The behavior with `b"%s" % some_bytes_object` works fine if both objects are Future `builtins.bytes`, or both objects are native Python 2 strings/bytes, but not if you combine them. This has caused bugs. One way to fix this is by exposing only native byte strings for now, see e.g. `allmydata.util.base32`. + +## Other notes If you just want to run the tests from the explicitly ported test modules, you can do `python -m allmydata.util._python3`.