On 9/21/16 12:09, timeless wrote:
# HG changeset patch
# User timeless <timel...@mozdev.org>
# Date 1474429683 0
#      Wed Sep 21 03:48:03 2016 +0000
# Node ID 0070696439eab002f6dd32bcb40eb671daff800a
# Parent  adb54fd7d90f0ca607432ed7ae884da55ec427de
# Available At https://bitbucket.org/timeless/mercurial-crew
#              hg pull https://bitbucket.org/timeless/mercurial-crew -r 
0070696439ea
demandimport: reject contextlib._GeneratorContextManager on Py < 3.2


As a general thing I don't think we should be spending time trying to fix this implementation of demandimport on Python 3 at all. I would much rather we use an implementation based on the new importlib stuff, like the one I sent to the list a while back. (Hopefully I can get it in during the sprint.)

- Siddharth


decorator expects:
  from contextlib import _GeneratorContextManager
to throw an exception on python < 3.2 (issue5373).

We tell demandimport to throw it.

diff -r adb54fd7d90f -r 0070696439ea mercurial/demandimport.py
--- a/mercurial/demandimport.py Wed Sep 21 18:58:54 2016 +0000
+++ b/mercurial/demandimport.py Wed Sep 21 03:48:03 2016 +0000
@@ -313,6 +313,12 @@
  if os.name != 'nt':
      reject('distutils', 'msvc9compiler', ImportError, 'No module named 
_winreg')
+# decorator imported by ipython from pygments does an import which isn't
+# friendly to demandimport.
+if sys.version_info[0] < 3 or sys.version_info[1] < 2:
+    reject('contextlib', '_GeneratorContextManager',
+           ImportError, 'cannot import name _GeneratorContextManager')
+
  def isenabled():
      return builtins.__import__ == _demandimport
diff -r adb54fd7d90f -r 0070696439ea tests/test-demandimport.py
--- a/tests/test-demandimport.py        Wed Sep 21 18:58:54 2016 +0000
+++ b/tests/test-demandimport.py        Wed Sep 21 03:48:03 2016 +0000
@@ -71,6 +71,15 @@
  except ImportError:
      pass
+if sys.version_info[0] < 3 or sys.version_info[1] < 2:
+    try:
+        from contextlib import _GeneratorContextManager
+        print('contextlib._GeneratorContextManager needs to be an '
+              'immediate importerror on python <3.2')
+        _GeneratorContextManager.__doc__
+    except ImportError:
+        pass
+
  demandimport.disable()
  os.environ['HGDEMANDIMPORT'] = 'disable'
  # this enable call should not actually enable demandimport!
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to