<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Jul 18, 2015 at 1:13 PM, Gregory Szorc <span dir="ltr"><<a href="mailto:gregory.szorc@gmail.com" target="_blank">gregory.szorc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">On Sat, Jul 18, 2015 at 1:07 PM, Gregory Szorc <span dir="ltr"><<a href="mailto:gregory.szorc@gmail.com" target="_blank">gregory.szorc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Thu, Jul 16, 2015 at 10:28 AM, Matt Mackall <span dir="ltr"><<a href="mailto:mpm@selenic.com" target="_blank">mpm@selenic.com</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span><span>On Tue, 2015-07-14 at 13:51 -0700, Gregory Szorc wrote:<br>
> # HG changeset patch<br></span>
> # User Gregory Szorc <<a href="mailto:gregory.szorc@gmail.com" target="_blank">gregory.szorc@gmail.com</a>><div><div><br>
> # Date 1436894831 25200<br>
> #      Tue Jul 14 10:27:11 2015 -0700<br>
> # Node ID 5154b8421ebd670d6155659c5811f193f5fe1555<br>
> # Parent  35fa7c77c754aa4d156c42abfdb61ca178468872<br>
> revlog: use absolute_import<br>
><br>
> This is needed for Python 3 compatibility. We have static analysis<br>
> checks in place to ensure files using absolute_import conform to the<br>
> style adopted by this patch.<br>
<br>
</div></div></span><div><div>More weird test failures on 2.6:<br>
</div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div>
........<br>
--- /home/mpm/hg-test-/tests/test-help.t<br>
+++ /home/mpm/hg-test-/tests/test-help.t.err<br>
@@ -1244,6 +1244,15 @@<br>
<br>
   $ cd "$TESTDIR"/../doc<br>
   $ python check-seclevel.py<br>
+  Traceback (most recent call last):<br>
+    File "check-seclevel.py", line 168, in <module><br>
+      if checkhghelps():<br>
+    File "check-seclevel.py", line 99, in checkhghelps<br>
+      mod = extensions.load(None, name, None)<br>
+    File "../mercurial/extensions.py", line 86, in load<br>
+      ui.debug('could not import hgext.%s (%s): trying %s\n'<br>
+  AttributeError: 'NoneType' object has no attribute 'debug'<br>
+  [1]<br>
   $ cd $TESTTMP<br>
<br>
 #if serve<br>
<br>
ERROR: test-help.t output changed<br>
!......<br>
--- /home/mpm/hg-test-/tests/test-extension.t<br>
+++ /home/mpm/hg-test-/tests/test-extension.t.err<br>
@@ -949,12 +949,15 @@<br>
   $ if [ -z "$hgver" ]; then<br>
   >   echo "unable to fetch a mercurial version. Make sure __version__<br>
is correct";<br>
   > fi<br>
+  unable to fetch a mercurial version. Make sure __version__ is correct<br>
   $ rm -f throw.pyc throw.pyo<br>
   $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'<br>
-  ** unknown exception encountered, please report by visiting<br></div></div>
-  ** <a href="http://mercurial.selenic.com/wiki/BugTracker" rel="noreferrer" target="_blank">http://mercurial.selenic.com/wiki/BugTracker</a><span><br>
-  ** Python * (glob)<br>
-  ** Mercurial Distributed SCM (*) (glob)<br>
+  ** Unknown exception encountered with possibly-broken third-party<br>
extension throw<br>
+  ** which supports versions unknown of Mercurial.<br>
+  ** Please disable throw and try your action again.<br></span>
+  ** If that fixes the bug please report it to <a href="http://example.com/bts" rel="noreferrer" target="_blank">http://example.com/bts</a><span><br>
+  ** Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36) [GCC 4.4.7<br>
20120313 (Red Hat 4.4.7-4)]<br>
+  ** Mercurial Distributed SCM (version +0-)<br>
   ** Extensions loaded: throw<br>
<br>
 Patch version is ignored during compatibility check<br><br></span></blockquote><div><br></div><div>I'm able to reproduce these on Linux with Python 2.6.9. However, the problem goes away if `make local` is executed (both run-tests.py and run-tests.py -l work with a local build in place). However, the failure persists if the local install was built against Python 2.7. It certainly appears like the local install is leaking into the test environment somehow, at least for these tests.<br></div></div></div></div></blockquote><div><br></div></div></div><div>doc/check-seclevels.py is doing weirdness with sys.path foo. The error message about ui not having a "debug" attribute is a red herring because demandimport is mucking about with things. This is the actual error:<br><br>$ HGDEMANDIMPORT=disable ~/.pyenv/versions/2.6.9/bin/python check-seclevel.py<span class=""><br>Traceback (most recent call last):<br></span>  File "check-seclevel.py", line 13, in <module><br>    from mercurial.commands import table<br>  File "../mercurial/commands.py", line 13, in <module><br>    import hg, scmutil, util, revlog, copies, error, bookmarks<br>  File "../mercurial/hg.py", line 13, in <module><br>    import localrepo, bundlerepo, unionrepo, httppeer, sshpeer, statichttprepo<br>  File "../mercurial/localrepo.py", line 10, in <module><br>    import peer, changegroup, subrepo, pushkey, obsolete, repoview<br>  File "../mercurial/subrepo.py", line 13, in <module><br>    import config, util, node, error, cmdutil, scmutil, match as matchmod<br>  File "../mercurial/cmdutil.py", line 11, in <module><br>    import util, scmutil, templater, patch, error, templatekw, revlog, copies<br>  File "../mercurial/revlog.py", line 29, in <module><br>    from . import (<br>ImportError: cannot import name parsers<br><br></div><div>This is probably a result of the 'sys.path.insert(0, "..")' line in check-seclevel.py. That will almost certainly throw off relative imports.<br></div></div></div></div></blockquote><div><br></div><div>The rabbit hole says this is a problem with mercurial/pure being in sys.path. Before "import parsers" would pick up the C extension from mercurial/ (if available) and fall back to mercurial/pure/parsers.py if there was no C extension. With absolute imports, we need to explicitly qualify imports. <br></div></div><br></div><div class="gmail_extra">The obvious solution is to catch ImportError when native extensions can't be imported:<br><br></div><div class="gmail_extra">try:<br></div><div class="gmail_extra">    from . import parsers<br></div><div class="gmail_extra">except ImportError:<br></div><div class="gmail_extra">    from .pure import parsers<br></div></div>