Commit d2ee6d7e authored by Jason Madden's avatar Jason Madden

Allow building the socket module docs for both python 2 and 3. [skip ci]

parent 8d7fea5d
......@@ -31,7 +31,9 @@ variable. Specify ``ares``, ``thread``, or ``block`` to use the
:class:`gevent.resolver_ares.Resolver`,
:class:`gevent.resolver_thread.Resolver`, or
:class:`gevent.socket.BlockingResolver`, respectively, or set it to
the fully-qualified name of an implementation of the standard functions.
the fully-qualified name of an implementation of the standard
functions.
.. toctree::
gevent.resolver_thread
......
......@@ -25,7 +25,8 @@ directory = dirname(abspath(gevent.__file__))
print('Imported gevent from %s' % (directory, ))
modules = glob.glob(join(directory, '*.py')) + glob.glob(join(directory, '*.pyc'))
modules = set(basename(filename).split('.')[0] for filename in modules)
modules = set(name for name in modules if not name.startswith('_'))
modules = set(name for name in modules
if name.startswith('_socket2') or name.startswith('_socket3') or not name.startswith('_'))
import warnings
warnings.simplefilter('ignore', DeprecationWarning)
......
# Copyright (c) 2009-2014 Denis Bilenko and gevent contributors. See LICENSE for details.
"""
Python 2 socket module.
"""
import time
from gevent import _socketcommon
from gevent.hub import PYPY
for key in _socketcommon.__dict__:
if key.startswith('__'):
if key.startswith('__') or key in _socketcommon.__py3_imports__:
continue
globals()[key] = getattr(_socketcommon, key)
__socket__ = _socketcommon.__socket__
__implements__ = _socketcommon._implements
__extensions__ = _socketcommon.__extensions__
__imports__ = _socketcommon.__imports__
__imports__ = [i for i in _socketcommon.__imports__ if i not in _socketcommon.__py3_imports__]
__dns__ = _socketcommon.__dns__
_fileobject = __socket__._fileobject
try:
_fileobject = __socket__._fileobject
_socketmethods = __socket__._socketmethods
except AttributeError:
# Allow this module to be imported under Python 3
# for building the docs
_fileobject = object
_socketmethods = ('bind', 'connect', 'connect_ex',
'fileno', 'listen', 'getpeername',
'getsockname', 'getsockopt',
'setsockopt', 'sendall',
'setblocking', 'settimeout',
'gettimeout', 'shutdown')
if sys.version_info[:2] < (2, 7):
......@@ -363,7 +377,7 @@ class socket(object):
_s = ("def %s(self, *args): return self._sock.%s(*args)\n\n"
"%s.__doc__ = _realsocket.%s.__doc__\n")
for _m in set(__socket__._socketmethods) - set(locals()):
for _m in set(_socketmethods) - set(locals()):
exec(_s % (_m, _m, _m, _m))
del _m, _s
......
# Port of Python 3.3's socket module to gevent
"""
Python 3 socket module.
"""
import io
import sys
import time
......
......@@ -43,16 +43,20 @@ __imports__ = ['error',
'setdefaulttimeout',
# Windows:
'errorTab',
# Python 3
'AddressFamily',
'SocketKind',
'CMSG_LEN',
'CMSG_SPACE',
'dup',
'if_indextoname',
'if_nameindex',
'if_nametoindex',
'sethostname']
]
__py3_imports__ = [# Python 3
'AddressFamily',
'SocketKind',
'CMSG_LEN',
'CMSG_SPACE',
'dup',
'if_indextoname',
'if_nameindex',
'if_nametoindex',
'sethostname']
__imports__.extend(__py3_imports__)
import sys
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment