Description
We need to move the deprecated StringIO.StringIO and cStringIO.StringIO usages in the Python codebase to modern io.BytesIO. Weirdly, if we do that, the interop tests will fail, because we shadow Python's builtin io module with avro.io by invoking tool.py directly from within the python package with e.g. python lang/py/build/src/avro/tool.py rpcsend.
When you invoke a python script directly, Python prepends the script's path to the sys.path. Since avro's io.py is in the same path as tool.py, the standard library's io module becomes inaccessible.
There are a couple of ways we can resolve this, but none are entirely transparent to end users:
- Move tool.py into a subdirectory so it isn't in the same path as io.py}}.
- Guide users not to invoke tool.py directly, but instead to call python -m avro.tool.
- Install tool.py into the PATH via setuptools' console_scripts entrypoint.
Option #1 would require a significant code change and still require updating documentation and unconfusing users.
Option #3 would be tricky to implement given how our current codebase expects to install with both and and setuptools.
So my suggestion is that we go with Option #2, and introduce a warning into tool.py so that folks get a helpful message right before the crash.
Attachments
Issue Links
- links to