Skip to content

Add Python 2/3 dual-compatibility for Python 3.6 integration - #45

Open
noahzaozao wants to merge 1 commit into
lt-masterfrom
py36-py2-3-compat
Open

Add Python 2/3 dual-compatibility for Python 3.6 integration#45
noahzaozao wants to merge 1 commit into
lt-masterfrom
py36-py2-3-compat

Conversation

@noahzaozao

Copy link
Copy Markdown

The Learningtribes fork imports cleanly but crashes at runtime on Python 3 in the discovery/index paths, blocking the py36 lock. Fix the Py2-only idioms so the fork runs under both 2.7 and 3.6:

  • utils: basestring -> six.string_types; collections.Iterable ->
    collections.abc fallback import
  • result_processor: dict.itervalues() -> six.itervalues(); exception .message -> six.text_type(); shlex.split() unicode handling guarded by six.PY2 (Py3 splits unicode directly)
  • api: isinstance(x, (str, unicode, ...)) -> six.string_types + (bytes, bytearray)
  • elastic: exception .message -> six.text_type() (6 sites, including two broken '...%s'.format(e.message) logging calls)
  • tests/mock_search_engine + test_views: basestring/unicode() ->
    six; bytes.translate(None, str) -> unicode filter
  • setup.py/tox.ini: declare Python 3.6, add six dependency, add py36 tox env
  • add standard from future header to modernized modules

Verified: compileall clean, 0 Py2-only patterns, and real-module runtime checks pass under Python 3.

The Learningtribes fork imports cleanly but crashes at runtime on
Python 3 in the discovery/index paths, blocking the py36 lock. Fix the
Py2-only idioms so the fork runs under both 2.7 and 3.6:

- utils: basestring -> six.string_types; collections.Iterable ->
  collections.abc fallback import
- result_processor: dict.itervalues() -> six.itervalues(); exception
  .message -> six.text_type(); shlex.split() unicode handling guarded
  by six.PY2 (Py3 splits unicode directly)
- api: isinstance(x, (str, unicode, ...)) -> six.string_types +
  (bytes, bytearray)
- elastic: exception .message -> six.text_type() (6 sites, including
  two broken '...%s'.format(e.message) logging calls)
- tests/mock_search_engine + test_views: basestring/unicode() ->
  six; bytes.translate(None, str) -> unicode filter
- setup.py/tox.ini: declare Python 3.6, add six dependency,
  add py36 tox env
- add standard from __future__ header to modernized modules

Verified: compileall clean, 0 Py2-only patterns, and real-module
runtime checks pass under Python 3.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant