Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
api/send.pystill 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):import urlparse— the module was renamed tourllib.parsein Python 3. RaisesModuleNotFoundError: No module named 'urlparse'at import time. The module is never referenced in this file (onlyurlparse.parse_qsis used in msc_apps.py, which is a separate module already covered by an earlier PR), so the line is just removed.response_dict.has_key(field)—.has_key()was removed from dicts in Python 3 (useininstead). Two call sites.printstatements 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, andpushtx.pyin the api package.Verification
ast.parse()on the patched file succeeds. No remaining Python 2 patterns (import urlparse,has_key, unparenthesizedprint) in the file. Behavior is unchanged for the Python 2 call sites (theinoperator matches.has_key()semantics, the print function matches the Python 2 print statement semantics for the simple cases used here).