Page MenuHomePhabricator

[electrum] fix import of urllib in web.py
ClosedPublic

Authored by PiRK on Jan 22 2024, 16:29.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Project
Commits
rABC41f1819e5604: [electrum] fix import of urllib in web.py
Summary

The previous import should not have worked, urllib is just a namespace and does not import other modules under it. I suppose that it works by chance because other modules in Electrum ABC properly import urllibe.parse and urllib.request

The issue can be reproduced by attempting to run the test_util suite on its own:

$ python -m electrumabc.tests.test_util
s.........s.........sEEEEEE..EE...........
======================================================================
ERROR: test_parse_URI_address (__main__.TestUtil)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/pierre/dev/bitcoin-abc/electrum/electrumabc/tests/test_util.py", line 165, in test_parse_URI_address
    self._do_test_parse_URI(
  File "/home/pierre/dev/bitcoin-abc/electrum/electrumabc/tests/test_util.py", line 161, in _do_test_parse_URI
    result = parse_URI(uri)
  File "/home/pierre/dev/bitcoin-abc/electrum/electrumabc/web.py", line 248, in parse_URI
    u = urllib.parse.urlparse(uri)
AttributeError: module 'urllib' has no attribute 'parse'

Or simply

$ python -c "import urllib; urllib.parse"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'urllib' has no attribute 'parse'
Test Plan

python -m electrumabc.tests.test_util

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable