Patchwork [Bug,5208] New: demandimport py3 fails for module with unimported intermediate modules

login
register
mail settings
Submitter mercurial-bugs@selenic.com
Date April 17, 2016, 3:39 p.m.
Message ID <bug-5208-285@https.bz.mercurial-scm.org/>
Download mbox | patch
Permalink /patch/14705/
State Not Applicable
Headers show

Comments

mercurial-bugs@selenic.com - April 17, 2016, 3:39 p.m.
https://bz.mercurial-scm.org/show_bug.cgi?id=5208

            Bug ID: 5208
           Summary: demandimport py3 fails for module with unimported
                    intermediate modules
           Product: Mercurial
           Version: default branch
          Hardware: PC
                OS: Windows
            Status: UNCONFIRMED
          Severity: feature
          Priority: wish
         Component: Mercurial
          Assignee: bugzilla@selenic.com
          Reporter: timeless@gmail.com
                CC: mercurial-devel@selenic.com

(py)[timeless@gcc2-power8 crew]$ python
Python 2.7.8 (default, Jul  8 2015, 18:13:08)
[GCC 4.9.2 20150212 (Red Hat 4.9.2-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import email
>>> import email.mime.text
>>> email.mime.text.MIMEText
<class email.mime.text.MIMEText at 0x3fff8b390c18>
>>>
(py)[timeless@gcc2-power8 crew]$ python
Python 2.7.8 (default, Jul  8 2015, 18:13:08)
[GCC 4.9.2 20150212 (Red Hat 4.9.2-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mercurial.demandimport
>>> mercurial.demandimport.enable()
>>> import email
>>> import email.mime.text
>>> email.mime.text.MIMEText
<class email.mime.text.MIMEText at 0x3fff9b2d6258>
>>>

(py3)[timeless@gcc2-power8 crew]$ python
Python 3.5.1 (default, Mar  1 2016, 07:19:18)
[GCC 4.9.2 20141101 (Red Hat 4.9.2-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import email
>>> import email.mime.text
>>> email.mime.text.MIMEText
<class 'email.mime.text.MIMEText'>
>>>
(py3)[timeless@gcc2-power8 crew]$ python
Python 3.5.1 (default, Mar  1 2016, 07:19:18)
[GCC 4.9.2 20141101 (Red Hat 4.9.2-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mercurial.demandimport
>>> mercurial.demandimport.enable()
>>> import email
>>> import email.mime.text
>>> email.mime.text.MIMEText
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/timeless/hg/crew/mercurial/demandimport.py", line 133, in
__getattribute__
    self._load()
  File "/home/timeless/hg/crew/mercurial/demandimport.py", line 99, in _load
    mod = _hgextimport(_import, head, globals, locals, None, level)
  File "/home/timeless/hg/crew/mercurial/demandimport.py", line 54, in
_hgextimport
    return importfunc(name, globals, *args, **kwargs)
ImportError: No module named 'mime'

I hit this trying to get all the way through py3 support.
I can work around this with:


But I shouldn't need to.

Patch

--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -123,6 +123,7 @@  except AttributeError:
     import email.generator
     import email.header
     import email.message
+    import email.mime
     import email.mime.text
     import email.mime.base
     import email.mime.multipart