Skip to content

port api/send.py to Python 3 - #1837

Open
HrachShah wants to merge 1 commit into
OmniLayer:masterfrom
HrachShah:fix/send-python3-imports
Open

HrachShah wants to merge 1 commit into
OmniLayer:masterfrom
HrachShah:fix/send-python3-imports

Conversation

@HrachShah

Copy link
Copy Markdown

Summary

api/send.py still uses three Python 2 idioms that prevent the file from being imported on Python 3 (and therefore prevent the entire WSGI app from starting, since msc_apps.py imports this module transitively):

  1. import urlparse — the module was renamed to urllib.parse in Python 3. Raises ModuleNotFoundError: No module named 'urlparse' at import time. The module is never referenced in this file (only urlparse.parse_qs is used in msc_apps.py, which is a separate module already covered by an earlier PR), so the line is just removed.
  2. response_dict.has_key(field).has_key() was removed from dicts in Python 3 (use in instead). Two call sites.
  3. Six print statements without parentheses — Python 3 only supports the function form.

This is the same Python 2 → 3 migration that earlier sessions applied to armory_service.py, pending.py, msc_apps.py, rpcclient.py, and pushtx.py in the api package.

Verification

ast.parse() on the patched file succeeds. No remaining Python 2 patterns (import urlparse, has_key, unparenthesized print) in the file. Behavior is unchanged for the Python 2 call sites (the in operator matches .has_key() semantics, the print function matches the Python 2 print statement semantics for the simple cases used here).

…odule was renamed to urllib.parse in Python 3, and this file never references urlparse anyway), switch the two has_key() calls to the in operator (has_key was removed in Python 3), and parenthesize the six print statements. This is the same Python 2 → 3 migration that earlier sessions applied to armory_service.py, pending.py, msc_apps.py, rpcclient.py, and pushtx.py in the api package, and lets the WSGI entry point (msc_apps.py, which imports this module transitively) start under Python 3
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