D7941: py3: wallpaper over demand importer differences on Python 3.5

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Sat Jan 18 07:43:00 UTC 2020


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  For some reason, Python 3.5 and only Python 3.5's demand importer
  is importing extra parent modules. This is causing test output
  on 3.5 to diverge.
  
  While I'm not thrilled about the divergence in behavior, I don't
  think it is critical enough to warrant fixing in code. So this
  commit teaches our test to recognize the divergent behavior on
  Python 3.5.
  
  Because the test format doesn't support conditional exit codes and
  we were already inside an #if (it also doesn't allow nested #ifs),
  I added a `|| false` to normalize the exit code. The actual exit
  code shouldn't matter here, as we have tests for that elsewhere.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D7941

AFFECTED FILES
  tests/test-extension.t

CHANGE DETAILS

diff --git a/tests/test-extension.t b/tests/test-extension.t
--- a/tests/test-extension.t
+++ b/tests/test-extension.t
@@ -574,25 +574,35 @@
   > NO_CHECK_EOF
 
 Examine module importing.
-
-  $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showabsolute)
-  LIB: this is extlibroot.lsub1.lsub2.used
-  LIB: this is extlibroot.lsub1.lsub2.called.func()
-  LIB: this is extlibroot.recursedown.abs.used
-  LIB: this is extlibroot.recursedown.legacy.used
-  LIB: this is extlibroot.shadowing.used
-  ABS: this is absextroot.xsub1.xsub2.used
-  ABS: this is absextroot.xsub1.xsub2.called.func()
+Python 3.5's lazy module importer varies in behavior from ours and the
+one in the standard library at 3.6+. This is not desirable. But it is
+a corner case in behavior and we don't expect many people to be running
+into it.
 
-  $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showrelative)
-  LIB: this is extlibroot.lsub1.lsub2.used
-  LIB: this is extlibroot.lsub1.lsub2.called.func()
-  LIB: this is extlibroot.recursedown.abs.used
-  LIB: this is extlibroot.recursedown.legacy.used
-  LIB: this is extlibroot.shadowing.used
-  REL: this is absextroot.xsub1.xsub2.used
-  REL: this is absextroot.xsub1.xsub2.called.func()
-  REL: this relimporter imports 'this is absextroot.relimportee'
+  $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showabsolute) || true
+  LIB: this is extlibroot.lsub1.lsub2.used (no-pyexact35 !)
+  LIB: this is extlibroot.lsub1.lsub2.called.func() (no-pyexact35 !)
+  LIB: this is extlibroot.recursedown.abs.used (no-pyexact35 !)
+  LIB: this is extlibroot.recursedown.legacy.used (no-pyexact35 !)
+  LIB: this is extlibroot.shadowing.used (no-pyexact35 !)
+  ABS: this is absextroot.xsub1.xsub2.used (no-pyexact35 !)
+  ABS: this is absextroot.xsub1.xsub2.called.func() (no-pyexact35 !)
+  *** failed to import extension absextroot from $TESTTMP/absextroot: extlibroot.lsub1.lsub2.unused is loaded unintentionally (pyexact35 !)
+  hg: unknown command 'showabsolute' (pyexact35 !)
+  (use 'hg help' for a list of commands) (pyexact35 !)
+
+  $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showrelative) || true
+  LIB: this is extlibroot.lsub1.lsub2.used (no-pyexact35 !)
+  LIB: this is extlibroot.lsub1.lsub2.called.func() (no-pyexact35 !)
+  LIB: this is extlibroot.recursedown.abs.used (no-pyexact35 !)
+  LIB: this is extlibroot.recursedown.legacy.used (no-pyexact35 !)
+  LIB: this is extlibroot.shadowing.used (no-pyexact35 !)
+  REL: this is absextroot.xsub1.xsub2.used (no-pyexact35 !)
+  REL: this is absextroot.xsub1.xsub2.called.func() (no-pyexact35 !)
+  REL: this relimporter imports 'this is absextroot.relimportee' (no-pyexact35 !)
+  *** failed to import extension absextroot from $TESTTMP/absextroot: extlibroot.lsub1.lsub2.unused is loaded unintentionally (pyexact35 !)
+  hg: unknown command 'showrelative' (pyexact35 !)
+  (did you mean shelve?) (pyexact35 !)
 
 Examine whether sub-module is imported relatively as expected.
 



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list