# HG changeset patch # User Gregory Szorc # Date 1452564998 28800 # Node ID e4b512bb6386f73acb3f04918aa2ffc07eb78f73 # Parent 89f49813526cfd0ea2a14f3f1ac4d97dd5ef7842 debugshell: disable demand importer when importing debugger For reasons I can't explain (but likely have something to do with a combination of __import__ inferring default values for arguments and the demand importer mechanism further assuming defaults), the demand importer isn't playing well with IPython. Without this patch, we get a failure "ValueError: Attempted relative import in non-package" when attempting to import "IPython." The stack has numerous demandimport calls on it and adding "IPython" to the exclude list in demandimport isn't enough to make the problem go away, which means the issue is likely somewhere in the bowells of IPython. It's easier to just disable the demand importer when importing the debugger. diff -r 89f49813526c -r e4b512bb6386 contrib/debugshell.py --- a/contrib/debugshell.py Mon Jan 04 10:13:29 2016 -0800 +++ b/contrib/debugshell.py Mon Jan 11 18:16:38 2016 -0800 @@ -4,7 +4,10 @@ import sys import mercurial import code -from mercurial import cmdutil +from mercurial import ( + cmdutil, + demandimport, +) cmdtable = {} command = cmdutil.command(cmdtable) @@ -45,7 +48,8 @@ # if IPython doesn't exist, fallback to code.interact try: - __import__(pdbmap[debugger]) + with demandimport.deactivated(): + __import__(pdbmap[debugger]) except ImportError: ui.warn("%s debugger specified but %s module was not found\n" % (debugger, pdbmap[debugger]))