[Bug 5633] New: Python 3 __past__ bytes hack doesn't work with mercurial.extensions.loadpath()

mercurial-bugs at mercurial-scm.org mercurial-bugs at mercurial-scm.org
Wed Jul 26 04:45:54 UTC 2017


https://bz.mercurial-scm.org/show_bug.cgi?id=5633

            Bug ID: 5633
           Summary: Python 3 __past__ bytes hack doesn't work with
                    mercurial.extensions.loadpath()
           Product: Mercurial
           Version: 3.8-rc
          Hardware: PC
                OS: Mac OS
            Status: UNCONFIRMED
          Severity: feature
          Priority: wish
         Component: Mercurial
          Assignee: bugzilla at mercurial-scm.org
          Reporter: durin42 at gmail.com
                CC: mercurial-devel at mercurial-scm.org

Normal import is fine:

augie% python3.6 -c 'import mercurial ; from hgext import mq ; print(mq)'
<module 'hgext.mq' from '/Users/augie/Programming/hg/crew/hgext/mq.py'>



But try and dig it up with loadpath() and it gets str/bytes confusion due to
our __past__ hackery.

augie% python3.6 -c 'import mercurial.extensions;
print(mercurial.extensions.loadpath(b"hgext/mq.py", b"hgext.mq"))'
Traceback (most recent call last):
  File "hgext/mq.py", line 113, in <module>
    stripext = extensions.find('strip')
  File "/Users/augie/Programming/hg/crew/mercurial/extensions.py", line 68, in
find
    raise KeyError(name)
KeyError: 'strip'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/augie/Programming/hg/crew/mercurial/extensions.py", line 83, in
loadpath
    return imp.load_source(module_name, path)
  File
"/opt/homebrew/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/imp.py",
line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 675, in _load
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "hgext/mq.py", line 120, in <module>
    stripext = extensions.load(dummyui(), 'strip', '')
  File "/Users/augie/Programming/hg/crew/mercurial/extensions.py", line 148, in
load
    if name.startswith('hgext.') or name.startswith('hgext/'):
TypeError: startswith first arg must be str or a tuple of str, not bytes

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Mercurial-devel mailing list