From 4212164e91ba2f49583cf44ad623a29b36db8f77 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Fri, 14 Sep 2018 19:32:27 -0700 Subject: Windows: Use 32-bit distribution of python --- python/gevent/builtins.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'python/gevent/builtins.py') diff --git a/python/gevent/builtins.py b/python/gevent/builtins.py index eab2099..389a652 100644 --- a/python/gevent/builtins.py +++ b/python/gevent/builtins.py @@ -2,10 +2,13 @@ """gevent friendly implementations of builtin functions.""" from __future__ import absolute_import -import imp # deprecated since 3.4; issues PendingDeprecationWarning in 3.5 import sys import weakref + from gevent.lock import RLock +from gevent._compat import imp_acquire_lock +from gevent._compat import imp_release_lock + # Normally we'd have the "expected" case inside the try # (Python 3, because Python 3 is the way forward). But @@ -14,15 +17,15 @@ from gevent.lock import RLock # So we test for the old, deprecated version first try: # Py2 - import __builtin__ as builtins + import __builtin__ as __gbuiltins__ _allowed_module_name_types = (basestring,) # pylint:disable=undefined-variable __target__ = '__builtin__' except ImportError: - import builtins # pylint: disable=import-error + import builtins as __gbuiltins__ # pylint: disable=import-error _allowed_module_name_types = (str,) __target__ = 'builtins' -_import = builtins.__import__ +_import = __gbuiltins__.__import__ # We need to protect imports both across threads and across greenlets. # And the order matters. Note that under 3.4, the global import lock @@ -86,7 +89,7 @@ def __import__(*args, **kwargs): return _import(*args, **kwargs) module_lock = __module_lock(args[0]) # Get a lock for the module name - imp.acquire_lock() + imp_acquire_lock() try: module_lock.acquire() try: @@ -94,7 +97,7 @@ def __import__(*args, **kwargs): finally: module_lock.release() finally: - imp.release_lock() + imp_release_lock() return result @@ -120,6 +123,13 @@ def _lock_imports(): if sys.version_info[:2] >= (3, 3): __implements__ = [] + __import__ = _import else: __implements__ = ['__import__'] __all__ = __implements__ + + +from gevent._util import copy_globals + +__imports__ = copy_globals(__gbuiltins__, globals(), + names_to_ignore=__implements__) -- cgit v1.2.3