Skip to content

Tron 2293: Clean up relics from Python 2 migration - #1132

Open
asolorioatyelp wants to merge 4 commits into
masterfrom
u/asolorio/TRON-2293-clean-up-relics-from-python-2-migration
Open

asolorioatyelp wants to merge 4 commits into
masterfrom
u/asolorio/TRON-2293-clean-up-relics-from-python-2-migration

Conversation

@asolorioatyelp

Copy link
Copy Markdown
Contributor

Back in #426 maybe_decode/maybe_encode calls were added throughout Tron, plus a custom Py2Shelf, to handle the bytes/str differences between Python 2 and Python 3. We only run Python 3 now, so this PR removes them.

Changes

  • Removed maybe_decode / maybe_encode. Most call sites already receive a str, so the wrapper is simply dropped. A few places do deal with bytes, and those now use an explicit .encode()/.decode().
  • Replaced Py2Shelf with BsdDbShelf. This is a small subclass of the standard shelve.Shelf that is still backed by bsddb3, so existing state files keep opening.
  • Small cleanups: removed __nonzero__ (we already have __bool__) and the (object) bases in docstrings.

Known risks

  • Shelve files written by the old class still load. I checked this by writing a file with the old Py2Shelf and reading it back with the new class.
  • Pickles that Python 2 wrote with non-ASCII str or datetime values will no longer load. Production uses DynamoDB/JSON, so I don't think this would be a big issue (maybe just notify others).

Ticket: TRON-2293

Note: Formatted this description using Claude Code.

@asolorioatyelp
asolorioatyelp requested a review from a team as a code owner October 26, 2026 17:30
@asolorioatyelp
asolorioatyelp marked this pull request as draft October 26, 2026 17:40
@asolorioatyelp
asolorioatyelp marked this pull request as ready for review October 26, 2026 18:01
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