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

issue5373

diff -r 894cc47eb82a -r e07c3d398573 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
@@ -306,6 +306,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 894cc47eb82a -r e07c3d398573 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