# HG changeset patch
# User timeless <timel...@mozdev.org>
# Date 1474429683 0
#      Wed Sep 21 03:48:03 2016 +0000
# Node ID b2d5ad899bbb3c6eace4547b975c84f155066f0b
# Parent  20111b4d031e63596b93e162af9b8ca3ff1c98af
# Available At https://bitbucket.org/timeless/mercurial-crew
#              hg pull https://bitbucket.org/timeless/mercurial-crew -r 
b2d5ad899bbb
demandimport: reject contextlib._GeneratorContextManager on Py < 3.2

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

We tell demandimport to throw it.

diff -r 20111b4d031e -r b2d5ad899bbb mercurial/demandimport.py
--- a/mercurial/demandimport.py Wed Sep 21 03:47:35 2016 +0000
+++ b/mercurial/demandimport.py Wed Sep 21 03:48:03 2016 +0000
@@ -309,6 +309,13 @@
     if not mod in rejects:
         rejects[mod] = {}
     rejects[mod][prop] = [cls, msg]
+
+# 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 20111b4d031e -r b2d5ad899bbb tests/test-demandimport.py
--- a/tests/test-demandimport.py        Wed Sep 21 03:47:35 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

Reply via email to