Commits

Geert Jansen committed 9def266

Moving to absolute imports.

This patch prepares for the addition of a "gevent.os" module.

Comments (0)

Files changed (15)

gevent/__init__.py

 See http://www.gevent.org/ for the documentation.
 """
 
+from __future__ import absolute_import
+
 version_info = (1, 0, 0, 'dev', None)
 __version__ = '1.0dev'
 
 
 import sys
 if sys.platform == 'win32':
-    __import__('socket')  # trigger WSAStartup call
+    import socket  # trigger WSAStartup call
 del sys
 
 
 from python cimport *
-import os
+# Work around lack of absolute_import in Cython.
+os = __import__('os', level=0)
 
 
 __all__ = ['set_exc_info']
 cimport libev
 from python cimport *
 import sys
-import os
+# Work around lack of absolute_import in Cython
+os = __import__('os', level=0)
 import traceback
 import signal as signalmodule
 

gevent/fileobject.py

+from __future__ import absolute_import
 import sys
 import os
 from gevent.hub import get_hub
 # Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.
 
+from __future__ import absolute_import
 import sys
 import os
 import traceback
         pass
 
 try:
-    greenlet = __import__('greenlet').greenlet
+    from greenlet import greenlet
 except ImportError:
     greenlet = __import_py_magic_greenlet()
     if greenlet is None:
     GreenletExit.__bases__ = (BaseException, )
 
 if sys.version_info[0] <= 2:
-    thread = __import__('thread')
+    import thread
 else:
-    thread = __import__('_thread')
+    import _thread as thread
 threadlocal = thread._local
 _threadlocal = threadlocal()
 _threadlocal.Hub = None
   - thread-local storage becomes greenlet-local storage
 """
 
+from __future__ import absolute_import
 import sys
 
 __all__ = ['patch_all',
     2
 """
 
+from __future__ import absolute_import
 import sys
 import heapq
 import collections
 
 if sys.version_info[0] == 2:
-    __queue__ = __import__('Queue')
+    import Queue as __queue__
 else:
-    __queue__ = __import__('queue')
+    import queue as __queue__
 Full = __queue__.Full
 Empty = __queue__.Empty
 

gevent/resolver_ares.py

 # Copyright (c) 2011 Denis Bilenko. See LICENSE for details.
+from __future__ import absolute_import
 import os
 import sys
 from _socket import getservbyname, getaddrinfo, gaierror, error
 # Copyright (c) 2009-2011 Denis Bilenko. See LICENSE for details.
+from __future__ import absolute_import
 import sys
 from gevent.timeout import Timeout
 from gevent.event import Event
 __implements__ = ['select']
 __all__ = ['error'] + __implements__
 
-__select__ = __import__('select')
+import select as __select__
 error = __select__.error
 
 
 as well as the constants from :mod:`socket` module are imported into this module.
 """
 
+from __future__ import absolute_import
+
 # standard functions and classes that this module re-implements in a gevent-aware way:
 __implements__ = ['create_connection',
                   'socket',
 
 import _socket
 _realsocket = _socket.socket
-__socket__ = __import__('socket')
+import socket as __socket__
 _fileobject = __socket__._fileobject
 
 for name in __imports__[:]:
 .. _`ssl package`: http://pypi.python.org/pypi/ssl
 """
 
-__ssl__ = __import__('ssl')
+from __future__ import absolute_import
+import ssl as __ssl__
 
 try:
     _ssl = __ssl__._ssl

gevent/subprocess.py

+from __future__ import absolute_import
 import sys
 import os
 import errno
 from gevent.fileobject import FileObject
 from gevent.greenlet import Greenlet, joinall
 spawn = Greenlet.spawn
-__subprocess__ = __import__('subprocess')
+import subprocess as __subprocess__
 
 
 # Standard functions and classes that this module re-implements in a gevent-aware way.
     used directly. For spawning greenlets in your applications, prefer
     :class:`Greenlet` class.
 """
+from __future__ import absolute_import
 import sys
 
 __implements__ = ['allocate_lock',
 
 __imports__ = ['error']
 if sys.version_info[0] <= 2:
-    __target__ = 'thread'
+    import thread as __thread__
 else:
-    __target__ = '_thread'
-__thread__ = __import__(__target__)
+    import _thread as __thread__
 error = __thread__.error
 from gevent.hub import getcurrent, GreenletExit
 from gevent.greenlet import Greenlet

gevent/threadpool.py

 # Copyright (c) 2012 Denis Bilenko. See LICENSE for details.
-from __future__ import with_statement
+from __future__ import with_statement, absolute_import
 import sys
 import os
 from gevent.hub import get_hub, getcurrent, sleep, integer_types

gevent/win32util.py

 The code is taken from twisted.python.win32 module.
 """
 
+from __future__ import absolute_import
 import os