diff options
author | James Taylor <user234683@users.noreply.github.com> | 2018-09-14 19:32:27 -0700 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2018-09-14 19:32:27 -0700 |
commit | 4212164e91ba2f49583cf44ad623a29b36db8f77 (patch) | |
tree | 47aefe3c0162f03e0c823b43873356f69c1cd636 /python/gevent/builtins.py | |
parent | 6ca20ff7010f2bafc7fefcb8cad982be27a8aeae (diff) | |
download | yt-local-4212164e91ba2f49583cf44ad623a29b36db8f77.tar.lz yt-local-4212164e91ba2f49583cf44ad623a29b36db8f77.tar.xz yt-local-4212164e91ba2f49583cf44ad623a29b36db8f77.zip |
Windows: Use 32-bit distribution of python
Diffstat (limited to 'python/gevent/builtins.py')
-rw-r--r-- | python/gevent/builtins.py | 22 |
1 files changed, 16 insertions, 6 deletions
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__) |