Commit 07035b7e authored by Jason Madden's avatar Jason Madden

Down to one failing test.

parent bd96d8e1
...@@ -110,31 +110,21 @@ class socket(_socketcommon.SocketMixin): ...@@ -110,31 +110,21 @@ class socket(_socketcommon.SocketMixin):
# don't subclass it. This lets code that needs the raw _sock (not tied to the hub) # don't subclass it. This lets code that needs the raw _sock (not tied to the hub)
# get it. This shows up in tests like test__example_udp_server. # get it. This shows up in tests like test__example_udp_server.
if sys.version_info[:2] < (3, 7): # In 3.7, socket changed to auto-detecting family, type, and proto
def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None): # when given a fileno.
super().__init__() def __init__(self, family=-1, type=-1, proto=-1, fileno=None):
self._closed = False super().__init__()
self._sock = self._gevent_sock_class(family, type, proto, fileno) self._closed = False
self.timeout = None if fileno is None:
self.__init_common() if family == -1:
else: family = AddressFamily.AF_INET
# In 3.7, socket changed to auto-detecting family, type, and proto if type == -1:
# when given a fileno. type = SOCK_STREAM
def __init__(self, family=-1, type=-1, proto=-1, fileno=None): if proto == -1:
super().__init__() proto = 0
self._closed = False self._sock = self._gevent_sock_class(family, type, proto, fileno)
if fileno is None: self.timeout = None
if family == -1:
family = AF_INET
if type == -1:
type = SOCK_STREAM
if proto == -1:
proto = 0
self._sock = self._gevent_sock_class(family, type, proto, fileno)
self.timeout = None
self.__init_common()
def __init_common(self):
self._io_refs = 0 self._io_refs = 0
_socket.socket.setblocking(self._sock, False) _socket.socket.setblocking(self._sock, False)
fileno = _socket.socket.fileno(self._sock) fileno = _socket.socket.fileno(self._sock)
......
...@@ -51,9 +51,6 @@ __imports__ = [ ...@@ -51,9 +51,6 @@ __imports__ = [
'setdefaulttimeout', 'setdefaulttimeout',
# Windows: # Windows:
'errorTab', 'errorTab',
]
__py3_imports__ = [
# Python 3 # Python 3
'AddressFamily', 'AddressFamily',
'SocketKind', 'SocketKind',
...@@ -64,15 +61,15 @@ __py3_imports__ = [ ...@@ -64,15 +61,15 @@ __py3_imports__ = [
'if_nameindex', 'if_nameindex',
'if_nametoindex', 'if_nametoindex',
'sethostname', 'sethostname',
'create_server',
'has_dualstack_ipv6',
] ]
__imports__.extend(__py3_imports__)
import time import time
from gevent._hub_local import get_hub_noargs as get_hub from gevent._hub_local import get_hub_noargs as get_hub
from gevent._compat import string_types, integer_types, PY3 from gevent._compat import string_types, integer_types
from gevent._compat import PY38
from gevent._compat import PY39 from gevent._compat import PY39
from gevent._compat import WIN as is_windows from gevent._compat import WIN as is_windows
from gevent._compat import OSX as is_macos from gevent._compat import OSX as is_macos
...@@ -83,11 +80,6 @@ from gevent._hub_primitives import wait_on_socket as _wait_on_socket ...@@ -83,11 +80,6 @@ from gevent._hub_primitives import wait_on_socket as _wait_on_socket
from gevent.timeout import Timeout from gevent.timeout import Timeout
if PY38:
__imports__.extend([
'create_server',
'has_dualstack_ipv6',
])
if PY39: if PY39:
__imports__.extend([ __imports__.extend([
...@@ -210,8 +202,7 @@ def gethostbyname_ex(hostname): ...@@ -210,8 +202,7 @@ def gethostbyname_ex(hostname):
""" """
return get_hub().resolver.gethostbyname_ex(hostname) return get_hub().resolver.gethostbyname_ex(hostname)
def getaddrinfo(host, port, family=0, type=0, proto=0, flags=0):
def getaddrinfo(host, port, family=0, socktype=0, proto=0, flags=0):
""" """
Resolve host and port into list of address info entries. Resolve host and port into list of address info entries.
...@@ -228,40 +219,24 @@ def getaddrinfo(host, port, family=0, socktype=0, proto=0, flags=0): ...@@ -228,40 +219,24 @@ def getaddrinfo(host, port, family=0, socktype=0, proto=0, flags=0):
.. seealso:: :doc:`/dns` .. seealso:: :doc:`/dns`
""" """
return get_hub().resolver.getaddrinfo(host, port, family, socktype, proto, flags) # Also, on Python 3, we need to translate into the special enums.
# Our lower-level resolvers, including the thread and blocking, which use _socket,
if PY3: # function simply with integers.
# The name of the socktype param changed to type in Python 3. addrlist = get_hub().resolver.getaddrinfo(host, port, family, type, proto, flags)
# See https://github.com/gevent/gevent/issues/960 result = [
# Using inspect here to directly detect the condition is painful because we have to (_intenum_converter(af, AddressFamily),
# wrap it with a try/except TypeError because not all Python 2 _intenum_converter(socktype, SocketKind),
# versions can get the args of a builtin; we also have to use a with to suppress proto, canonname, sa)
# the deprecation warning. for af, socktype, proto, canonname, sa
d = getaddrinfo.__doc__ in addrlist
]
def getaddrinfo(host, port, family=0, type=0, proto=0, flags=0): return result
# pylint:disable=function-redefined, undefined-variable
# Also, on Python 3, we need to translate into the special enums. def _intenum_converter(value, enum_klass):
# Our lower-level resolvers, including the thread and blocking, which use _socket, try:
# function simply with integers. return enum_klass(value)
addrlist = get_hub().resolver.getaddrinfo(host, port, family, type, proto, flags) except ValueError: # pragma: no cover
result = [ return value
(_intenum_converter(af, AddressFamily),
_intenum_converter(socktype, SocketKind),
proto, canonname, sa)
for af, socktype, proto, canonname, sa
in addrlist
]
return result
getaddrinfo.__doc__ = d
del d
def _intenum_converter(value, enum_klass):
try:
return enum_klass(value)
except ValueError: # pragma: no cover
return value
def gethostbyaddr(ip_address): def gethostbyaddr(ip_address):
...@@ -546,8 +521,8 @@ class SocketMixin(object): ...@@ -546,8 +521,8 @@ class SocketMixin(object):
self.hub.cancel_wait(self._write_event, cancel_wait_ex) self.hub.cancel_wait(self._write_event, cancel_wait_ex)
self._sock.shutdown(how) self._sock.shutdown(how)
family = property(lambda self: self._sock.family) family = property(lambda self: _intenum_converter(self._sock.family, AddressFamily))
type = property(lambda self: self._sock.type) type = property(lambda self: _intenum_converter(self._sock.type, SocketKind))
proto = property(lambda self: self._sock.proto) proto = property(lambda self: self._sock.proto)
def fileno(self): def fileno(self):
......
...@@ -123,7 +123,7 @@ def notify_and_call_entry_points(event): ...@@ -123,7 +123,7 @@ def notify_and_call_entry_points(event):
# Prior to 3.9, there is no ``.module`` attribute, so if we # Prior to 3.9, there is no ``.module`` attribute, so if we
# needed that we'd have to look at the complete ``.value`` # needed that we'd have to look at the complete ``.value``
# attribute. # attribute.
ep_dict = entry_points() ep_dict = metadata.entry_points()
__traceback_info__ = ep_dict __traceback_info__ = ep_dict
# On Python 3.8, we can get duplicate EntryPoint objects; it is unclear # On Python 3.8, we can get duplicate EntryPoint objects; it is unclear
# why. Drop them into a set to make sure we only get one. # why. Drop them into a set to make sure we only get one.
......
...@@ -115,17 +115,9 @@ def get_switch_expected(fullname): ...@@ -115,17 +115,9 @@ def get_switch_expected(fullname):
disabled_tests = [ disabled_tests = [
# "test an implementation detail of thread objects" --- our implementation differs # Want's __module__ to be 'signal', which of course it isn't once
"test_threading.ThreadTests.test_tstate_lock", # monkey-patched.
# This likes to check the number of native thread IDs using the ``native_id`` attribute,
# and the ``get_native_id()`` function. Because we're monkey-patched,
# those don't change in other threads, so it won't work.
'test_threading.ThreadTests.test_various_ops',
# Added to address CPython issue 27718; it wants functions in the signal
# module to have __module__ equal to 'signal', but obviously when we
# monkey patch they don't.
'test_signal.GenericTests.test_functions_module_attr', 'test_signal.GenericTests.test_functions_module_attr',
# XXX: While we debug latest updates. This is leaking # XXX: While we debug latest updates. This is leaking
'test_threading.ThreadTests.test_no_refcycle_through_target', 'test_threading.ThreadTests.test_no_refcycle_through_target',
...@@ -268,13 +260,6 @@ disabled_tests = [ ...@@ -268,13 +260,6 @@ disabled_tests = [
] ]
if sys.version_info[:3] < (2, 7, 18):
# The final release was 2.7.18. It added some new tests for new
# fixes. At this writing, AppVeyor is still on 2.7.17.
disabled_tests += [
'test_urllib2.MiscTests.test_url_host_with_control_char_rejected',
]
if OSX: if OSX:
disabled_tests += [ disabled_tests += [
# These are timing dependent, and sometimes run into the OS X # These are timing dependent, and sometimes run into the OS X
...@@ -548,15 +533,6 @@ class _PatchedTest(object): ...@@ -548,15 +533,6 @@ class _PatchedTest(object):
return test return test
if sys.version_info[:3] <= (2, 7, 11):
disabled_tests += [
# These were added/fixed in 2.7.12+
'test_ssl.ThreadedTests.test__https_verify_certificates',
'test_ssl.ThreadedTests.test__https_verify_envvar',
]
if OSX: if OSX:
disabled_tests += [ disabled_tests += [
'test_subprocess.POSIXProcessTestCase.test_run_abort', 'test_subprocess.POSIXProcessTestCase.test_run_abort',
...@@ -644,101 +620,101 @@ if PYPY: ...@@ -644,101 +620,101 @@ if PYPY:
disabled_tests += [ disabled_tests += [
# Triggers the crash reporter # Triggers the crash reporter
'test_threading.SubinterpThreadingTests.test_daemon_threads_fatal_error', 'test_threading.SubinterpThreadingTests.test_daemon_threads_fatal_error',
# Relies on an implementation detail, Thread._tstate_lock
'test_threading.ThreadTests.test_tstate_lock',
# Relies on an implementation detail (reprs); we have our own version
'test_threading.ThreadTests.test_various_ops',
'test_threading.ThreadTests.test_various_ops_large_stack',
'test_threading.ThreadTests.test_various_ops_small_stack',
# Relies on Event having a _cond and an _reset_internal_locks()
# XXX: These are commented out in the source code of test_threading because
# this doesn't work.
# 'lock_tests.EventTests.test_reset_internal_locks',
# Python bug 13502. We may or may not suffer from this as its
# basically a timing race condition.
# XXX Same as above
# 'lock_tests.EventTests.test_set_and_clear',
# These tests want to assert on the type of the class that implements
# `Popen.stdin`; we use a FileObject, but they expect different subclasses
# from the `io` module
'test_subprocess.ProcessTestCase.test_io_buffered_by_default',
'test_subprocess.ProcessTestCase.test_io_unbuffered_works',
# 3.3 exposed the `endtime` argument to wait accidentally.
# It is documented as deprecated and not to be used since 3.4
# This test in 3.6.3 wants to use it though, and we don't have it.
'test_subprocess.ProcessTestCase.test_wait_endtime',
# These all want to inspect the string value of an exception raised
# by the exec() call in the child. The _posixsubprocess module arranges
# for better exception handling and printing than we do.
'test_subprocess.POSIXProcessTestCase.test_exception_bad_args_0',
'test_subprocess.POSIXProcessTestCase.test_exception_bad_executable',
'test_subprocess.POSIXProcessTestCase.test_exception_cwd',
# Relies on a 'fork_exec' attribute that we don't provide
'test_subprocess.POSIXProcessTestCase.test_exception_errpipe_bad_data',
'test_subprocess.POSIXProcessTestCase.test_exception_errpipe_normal',
# Python 3 fixed a bug if the stdio file descriptors were closed;
# we still have that bug
'test_subprocess.POSIXProcessTestCase.test_small_errpipe_write_fd',
# Relies on implementation details (some of these tests were added in 3.4,
# but PyPy3 is also shipping them.)
'test_socket.GeneralModuleTests.test_SocketType_is_socketobject',
'test_socket.GeneralModuleTests.test_dealloc_warn',
'test_socket.GeneralModuleTests.test_repr',
'test_socket.GeneralModuleTests.test_str_for_enums',
'test_socket.GeneralModuleTests.testGetaddrinfo',
] # Relies on an implementation detail, Thread._tstate_lock
if TRAVIS: 'test_threading.ThreadTests.test_tstate_lock',
disabled_tests += [ # Relies on an implementation detail (reprs); we have our own version
# test_cwd_with_relative_executable tends to fail 'test_threading.ThreadTests.test_various_ops',
# on Travis...it looks like the test processes are stepping 'test_threading.ThreadTests.test_various_ops_large_stack',
# on each other and messing up their temp directories. We tend to get things like 'test_threading.ThreadTests.test_various_ops_small_stack',
# saved_dir = os.getcwd()
# FileNotFoundError: [Errno 2] No such file or directory # Relies on Event having a _cond and an _reset_internal_locks()
'test_subprocess.ProcessTestCase.test_cwd_with_relative_arg', # XXX: These are commented out in the source code of test_threading because
'test_subprocess.ProcessTestCaseNoPoll.test_cwd_with_relative_arg', # this doesn't work.
'test_subprocess.ProcessTestCase.test_cwd_with_relative_executable', # 'lock_tests.EventTests.test_reset_internal_locks',
# In 3.7 and 3.8 on Travis CI, this appears to take the full 3 seconds. # Python bug 13502. We may or may not suffer from this as its
# Can't reproduce it locally. We have our own copy of this that takes # basically a timing race condition.
# timing on CI into account. # XXX Same as above
'test_subprocess.RunFuncTestCase.test_run_with_shell_timeout_and_capture_output', # 'lock_tests.EventTests.test_set_and_clear',
]
# These tests want to assert on the type of the class that implements
# `Popen.stdin`; we use a FileObject, but they expect different subclasses
# from the `io` module
'test_subprocess.ProcessTestCase.test_io_buffered_by_default',
'test_subprocess.ProcessTestCase.test_io_unbuffered_works',
# 3.3 exposed the `endtime` argument to wait accidentally.
# It is documented as deprecated and not to be used since 3.4
# This test in 3.6.3 wants to use it though, and we don't have it.
'test_subprocess.ProcessTestCase.test_wait_endtime',
# These all want to inspect the string value of an exception raised
# by the exec() call in the child. The _posixsubprocess module arranges
# for better exception handling and printing than we do.
'test_subprocess.POSIXProcessTestCase.test_exception_bad_args_0',
'test_subprocess.POSIXProcessTestCase.test_exception_bad_executable',
'test_subprocess.POSIXProcessTestCase.test_exception_cwd',
# Relies on a 'fork_exec' attribute that we don't provide
'test_subprocess.POSIXProcessTestCase.test_exception_errpipe_bad_data',
'test_subprocess.POSIXProcessTestCase.test_exception_errpipe_normal',
# Python 3 fixed a bug if the stdio file descriptors were closed;
# we still have that bug
'test_subprocess.POSIXProcessTestCase.test_small_errpipe_write_fd',
# Relies on implementation details (some of these tests were added in 3.4,
# but PyPy3 is also shipping them.)
'test_socket.GeneralModuleTests.test_SocketType_is_socketobject',
'test_socket.GeneralModuleTests.test_dealloc_warn',
'test_socket.GeneralModuleTests.test_repr',
'test_socket.GeneralModuleTests.test_str_for_enums',
'test_socket.GeneralModuleTests.testGetaddrinfo',
]
if TRAVIS:
disabled_tests += [ disabled_tests += [
# XXX: BUG: We simply don't handle this correctly. On CPython, # test_cwd_with_relative_executable tends to fail
# we wind up raising a BlockingIOError and then # on Travis...it looks like the test processes are stepping
# BrokenPipeError and then some random TypeErrors, all on the # on each other and messing up their temp directories. We tend to get things like
# server. CPython 3.5 goes directly to socket.send() (via # saved_dir = os.getcwd()
# socket.makefile), whereas CPython 3.6 uses socket.sendall(). # FileNotFoundError: [Errno 2] No such file or directory
# On PyPy, the behaviour is much worse: we hang indefinitely, perhaps exposing a problem 'test_subprocess.ProcessTestCase.test_cwd_with_relative_arg',
# with our signal handling. 'test_subprocess.ProcessTestCaseNoPoll.test_cwd_with_relative_arg',
'test_subprocess.ProcessTestCase.test_cwd_with_relative_executable',
# In actuality, though, this test doesn't fully test the EINTR it expects
# to under gevent (because if its EWOULDBLOCK retry behaviour.) # In 3.7 and 3.8 on Travis CI, this appears to take the full 3 seconds.
# Instead, the failures were all due to `pthread_kill` trying to send a signal # Can't reproduce it locally. We have our own copy of this that takes
# to a greenlet instead of a real thread. The solution is to deliver the signal # timing on CI into account.
# to the real thread by letting it get the correct ID, and we previously 'test_subprocess.RunFuncTestCase.test_run_with_shell_timeout_and_capture_output',
# used make_run_with_original to make it do that.
#
# But now that we have disabled our wrappers around Thread.join() in favor
# of the original implementation, that causes problems:
# background.join() thinks that it is the current thread, and won't let it
# be joined.
'test_wsgiref.IntegrationTests.test_interrupted_write',
] ]
disabled_tests += [
# XXX: BUG: We simply don't handle this correctly. On CPython,
# we wind up raising a BlockingIOError and then
# BrokenPipeError and then some random TypeErrors, all on the
# server. CPython 3.5 goes directly to socket.send() (via
# socket.makefile), whereas CPython 3.6 uses socket.sendall().
# On PyPy, the behaviour is much worse: we hang indefinitely, perhaps exposing a problem
# with our signal handling.
# In actuality, though, this test doesn't fully test the EINTR it expects
# to under gevent (because if its EWOULDBLOCK retry behaviour.)
# Instead, the failures were all due to `pthread_kill` trying to send a signal
# to a greenlet instead of a real thread. The solution is to deliver the signal
# to the real thread by letting it get the correct ID, and we previously
# used make_run_with_original to make it do that.
#
# But now that we have disabled our wrappers around Thread.join() in favor
# of the original implementation, that causes problems:
# background.join() thinks that it is the current thread, and won't let it
# be joined.
'test_wsgiref.IntegrationTests.test_interrupted_write',
]
# PyPy3 3.5.5 v5.8-beta # PyPy3 3.5.5 v5.8-beta
if PYPY3: if PYPY3:
......
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