Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
625c88b0
Commit
625c88b0
authored
Nov 18, 2019
by
Jason Madden
Committed by
GitHub
Nov 18, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1483 from gevent/py38-take2
Update Python versions, including 3.8 final on Appveyor
parents
bb1d6c99
e00c797c
Changes
40
Hide whitespace changes
Inline
Side-by-side
Showing
40 changed files
with
1239 additions
and
685 deletions
+1239
-685
.pylintrc
.pylintrc
+6
-1
CHANGES.rst
CHANGES.rst
+3
-1
appveyor.yml
appveyor.yml
+13
-4
scripts/install.sh
scripts/install.sh
+7
-7
src/gevent/__init__.py
src/gevent/__init__.py
+16
-18
src/gevent/_compat.py
src/gevent/_compat.py
+32
-1
src/gevent/_imap.py
src/gevent/_imap.py
+1
-2
src/gevent/_socket2.py
src/gevent/_socket2.py
+1
-1
src/gevent/_socket3.py
src/gevent/_socket3.py
+1
-1
src/gevent/_ssl2.py
src/gevent/_ssl2.py
+1
-2
src/gevent/_ssl3.py
src/gevent/_ssl3.py
+58
-45
src/gevent/hub.py
src/gevent/hub.py
+22
-10
src/gevent/subprocess.py
src/gevent/subprocess.py
+37
-9
src/gevent/testing/monkey_test.py
src/gevent/testing/monkey_test.py
+10
-0
src/gevent/testing/openfiles.py
src/gevent/testing/openfiles.py
+25
-2
src/gevent/testing/sysinfo.py
src/gevent/testing/sysinfo.py
+13
-0
src/gevent/testing/util.py
src/gevent/testing/util.py
+34
-0
src/gevent/tests/test___monkey_patching.py
src/gevent/tests/test___monkey_patching.py
+3
-26
src/gevent/tests/test__makefile_ref.py
src/gevent/tests/test__makefile_ref.py
+234
-216
src/gevent/tests/test__monkey_sigchld.py
src/gevent/tests/test__monkey_sigchld.py
+21
-1
src/gevent/tests/test__monkey_sigchld_2.py
src/gevent/tests/test__monkey_sigchld_2.py
+5
-0
src/gevent/tests/test__monkey_sigchld_3.py
src/gevent/tests/test__monkey_sigchld_3.py
+6
-0
src/gevent/tests/test__pywsgi.py
src/gevent/tests/test__pywsgi.py
+2
-2
src/gevent/tests/test__ssl.py
src/gevent/tests/test__ssl.py
+7
-2
src/greentest/3.7/keycert.passwd.pem
src/greentest/3.7/keycert.passwd.pem
+43
-42
src/greentest/3.7/ssl_key.passwd.pem
src/greentest/3.7/ssl_key.passwd.pem
+42
-42
src/greentest/3.7/test_httplib.py
src/greentest/3.7/test_httplib.py
+29
-0
src/greentest/3.7/test_ssl.py
src/greentest/3.7/test_ssl.py
+148
-58
src/greentest/3.7/test_subprocess.py
src/greentest/3.7/test_subprocess.py
+46
-9
src/greentest/3.7/test_wsgiref.py
src/greentest/3.7/test_wsgiref.py
+54
-24
src/greentest/3.7/version
src/greentest/3.7/version
+1
-1
src/greentest/3.8/keycert.passwd.pem
src/greentest/3.8/keycert.passwd.pem
+43
-42
src/greentest/3.8/ssl_key.passwd.pem
src/greentest/3.8/ssl_key.passwd.pem
+42
-42
src/greentest/3.8/test_httplib.py
src/greentest/3.8/test_httplib.py
+29
-0
src/greentest/3.8/test_socket.py
src/greentest/3.8/test_socket.py
+3
-1
src/greentest/3.8/test_ssl.py
src/greentest/3.8/test_ssl.py
+151
-58
src/greentest/3.8/test_subprocess.py
src/greentest/3.8/test_subprocess.py
+46
-9
src/greentest/3.8/test_threading.py
src/greentest/3.8/test_threading.py
+0
-1
src/greentest/3.8/test_wsgiref.py
src/greentest/3.8/test_wsgiref.py
+3
-4
src/greentest/3.8/version
src/greentest/3.8/version
+1
-1
No files found.
.pylintrc
View file @
625c88b0
...
...
@@ -49,6 +49,9 @@ limit-inference-results=1
# @property
# def foo(self):
# return None # generates useless-return
# Pylint 2.4 adds import-outside-toplevel. But we do that a lot to defer imports because of patching.
# Pylint 2.4 adds self-assigning-variable. But we do *that* to avoid unused-import when we
# "export" the variable and don't have a __all__.
disable=wrong-import-position,
wrong-import-order,
missing-docstring,
...
...
@@ -69,7 +72,9 @@ disable=wrong-import-position,
undefined-all-variable,
inconsistent-return-statements,
useless-return,
useless-object-inheritance
useless-object-inheritance,
import-outside-toplevel,
self-assigning-variable
[FORMAT]
...
...
CHANGES.rst
View file @
625c88b0
...
...
@@ -7,7 +7,9 @@
1.5a3 (unreleased)
==================
- Nothing changed yet.
- Python version updates: gevent is now tested with CPython 2.7.17,
3.5.9, 3.6.9, 3.7.5 and 3.8.0 (final). It is also tested with PyPy2
7.2 and PyPy 3.6 7.2
1.5a2 (2019-10-21)
...
...
appveyor.yml
View file @
625c88b0
...
...
@@ -19,6 +19,10 @@ environment:
# a later point release.
# 64-bit
-
PYTHON
:
"
C:
\\
Python38-x64"
PYTHON_VERSION
:
"
3.8.x"
PYTHON_ARCH
:
"
64"
PYTHON_EXE
:
python
-
PYTHON
:
"
C:
\\
Python37-x64"
PYTHON_VERSION
:
"
3.7.x"
...
...
@@ -41,13 +45,18 @@ environment:
PYTHON_EXE
:
python
# 32-bit
-
PYTHON
:
"
C:
\\
pypy2.7-v7.
1
.0-win32"
-
PYTHON
:
"
C:
\\
pypy2.7-v7.
2
.0-win32"
PYTHON_ID
:
"
pypy"
PYTHON_EXE
:
pypy
PYTHON_VERSION
:
"
2.7.x"
PYTHON_ARCH
:
"
32"
# 32-bit, wheel only (no testing)
-
PYTHON
:
"
C:
\\
Python38"
PYTHON_VERSION
:
"
3.8.x"
PYTHON_ARCH
:
"
32"
PYTHON_EXE
:
python
GWHEEL_ONLY
:
true
-
PYTHON
:
"
C:
\\
Python37"
PYTHON_VERSION
:
"
3.7.x"
...
...
@@ -110,10 +119,10 @@ install:
New-Item -ItemType directory -Path "$env:PYTMP" | Out-Null;
}
if ("${env:PYTHON_ID}" -eq "pypy") {
if (!(Test-Path "${env:PYTMP}\pypy2-v7.
1
.0-win32.zip")) {
(New-Object Net.WebClient).DownloadFile('https://bitbucket.org/pypy/pypy/downloads/pypy2.7-v7.
1.0-win32.zip', "${env:PYTMP}\pypy2-v7.1
.0-win32.zip");
if (!(Test-Path "${env:PYTMP}\pypy2-v7.
2
.0-win32.zip")) {
(New-Object Net.WebClient).DownloadFile('https://bitbucket.org/pypy/pypy/downloads/pypy2.7-v7.
2.0-win32.zip', "${env:PYTMP}\pypy2-v7.2
.0-win32.zip");
}
7z x -y "${env:PYTMP}\pypy2-v7.
1
.0-win32.zip" -oC:\ | Out-Null;
7z x -y "${env:PYTMP}\pypy2-v7.
2
.0-win32.zip" -oC:\ | Out-Null;
& "${env:PYTHON}\pypy.exe" "-mensurepip";
}
...
...
scripts/install.sh
View file @
625c88b0
...
...
@@ -96,25 +96,25 @@ install () {
for
var
in
"
$@
"
;
do
case
"
${
var
}
"
in
2.7
)
install
2.7.1
6
python2.7 2.7.d
install
2.7.1
7
python2.7 2.7.d
;;
3.5
)
install
3.5.
6
python3.5 3.5.d
install
3.5.
9
python3.5 3.5.d
;;
3.6
)
install
3.6.
8
python3.6 3.6.d
install
3.6.
9
python3.6 3.6.d
;;
3.7
)
install
3.7.
4
python3.7 3.7.d
install
3.7.
5
python3.7 3.7.d
;;
3.8
)
install
3.8.0
b4
python3.8 3.8.d
install
3.8.0 python3.8 3.8.d
;;
pypy2.7
)
install
pypy2.7-7.
1
.0 pypy2.7 pypy2.7.d
install
pypy2.7-7.
2
.0 pypy2.7 pypy2.7.d
;;
pypy3.6
)
install
pypy3.6-7.
1
.0 pypy3.6 pypy3.6.d
install
pypy3.6-7.
2
.0 pypy3.6 pypy3.6.d
;;
esac
done
src/gevent/__init__.py
View file @
625c88b0
...
...
@@ -31,29 +31,29 @@ __version__ = '1.5a3.dev0'
__all__
=
[
'get_hub'
,
'Greenlet'
,
'GreenletExit'
,
'spawn'
,
'spawn_later'
,
'spawn_raw'
,
'iwait'
,
'wait'
,
'killall'
,
'Timeout'
,
'with_timeout'
,
'config'
,
# Added in 1.3a2
'fork'
,
'get_hub'
,
'getcurrent'
,
'
sleep
'
,
'
getswitchinterval
'
,
'idle'
,
'iwait'
,
'joinall'
,
'kill'
,
'signal'
,
# deprecated
'signal_handler'
,
'fork'
,
'killall'
,
'reinit'
,
'getswitchinterval'
,
'setswitchinterval'
,
# Added in 1.3a2
'config'
,
'signal'
,
# deprecated
'signal_handler'
,
'sleep'
,
'spawn'
,
'spawn_later'
,
'spawn_raw'
,
'wait'
,
'with_timeout'
,
]
...
...
@@ -89,11 +89,9 @@ from gevent._hub_primitives import iwait_on_objects as iwait
from
gevent._hub_primitives
import
wait_on_objects
as
wait
from
gevent.greenlet
import
Greenlet
,
joinall
,
killall
joinall
=
joinall
# export for pylint
spawn
=
Greenlet
.
spawn
spawn_later
=
Greenlet
.
spawn_later
#: The singleton configuration object for gevent.
config
=
config
from
gevent.timeout
import
Timeout
,
with_timeout
from
gevent.hub
import
getcurrent
,
GreenletExit
,
spawn_raw
,
sleep
,
idle
,
kill
,
reinit
...
...
@@ -163,7 +161,7 @@ del sys
# outdated on each major release.
def
__dependencies_for_freezing
():
# pragma: no cover
# pylint:disable=unused-import
# pylint:disable=unused-import
, import-outside-toplevel
from
gevent
import
core
from
gevent
import
resolver_thread
from
gevent
import
resolver_ares
...
...
src/gevent/_compat.py
View file @
625c88b0
...
...
@@ -47,6 +47,14 @@ def NativeStrIO():
import
io
return
io
.
BytesIO
()
if
str
is
bytes
else
io
.
StringIO
()
try
:
from
abc
import
ABC
except
ImportError
:
import
abc
ABC
=
abc
.
ABCMeta
(
'ABC'
,
(
object
,),
{
'__slots__'
:
()})
del
abc
## Exceptions
if
PY3
:
def
reraise
(
t
,
value
,
tb
=
None
):
# pylint:disable=unused-argument
...
...
@@ -87,6 +95,16 @@ else:
from
itertools
import
izip
# python 3: pylint:disable=no-member,no-name-in-module
izip
=
izip
## The __fspath__ protocol
try
:
from
os
import
PathLike
# pylint:disable=unused-import
except
ImportError
:
class
PathLike
(
ABC
):
@
classmethod
def
__subclasshook__
(
cls
,
subclass
):
return
hasattr
(
subclass
,
'__fspath__'
)
# fspath from 3.6 os.py, but modified to raise the same exceptions as the
# real native implementation.
# Define for testing
...
...
@@ -152,6 +170,19 @@ except ImportError:
# Not sure how to handle this.
raise
UnicodeEncodeError
(
"Can't encode path to filesystem encoding"
)
try
:
from
os
import
fsdecode
# pylint:disable=unused-import
except
ImportError
:
def
fsdecode
(
filename
):
"""Decode filename (an os.PathLike, bytes, or str) from the filesystem
encoding with 'surrogateescape' error handler, return str unchanged. On
Windows, use 'strict' error handler if the file system encoding is
'mbcs' (which is the default encoding).
"""
filename
=
fspath
(
filename
)
# Does type-checking of `filename`.
if
PY3
and
isinstance
(
filename
,
bytes
):
return
filename
.
decode
(
encoding
,
errors
)
return
filename
## Clocks
try
:
...
...
@@ -162,7 +193,7 @@ except ImportError:
import
time
if
sys
.
platform
==
"win32"
:
perf_counter
=
time
.
clock
perf_counter
=
time
.
clock
# pylint:disable=no-member
else
:
perf_counter
=
time
.
time
...
...
src/gevent/_imap.py
View file @
625c88b0
...
...
@@ -206,8 +206,7 @@ class IMap(IMapUnordered):
index
,
value
=
self
.
queue
.
get
()
if
index
==
self
.
index
:
break
else
:
self
.
_results
[
index
]
=
value
self
.
_results
[
index
]
=
value
self
.
index
+=
1
return
value
...
...
src/gevent/_socket2.py
View file @
625c88b0
...
...
@@ -261,7 +261,7 @@ class socket(object):
result
=
self
.
_sock
.
connect_ex
(
address
)
if
not
result
or
result
==
EISCONN
:
break
el
if
(
result
in
(
EWOULDBLOCK
,
EINPROGRESS
,
EALREADY
))
or
(
result
==
EINVAL
and
is_windows
):
if
(
result
in
(
EWOULDBLOCK
,
EINPROGRESS
,
EALREADY
))
or
(
result
==
EINVAL
and
is_windows
):
self
.
_wait
(
self
.
_write_event
)
else
:
raise
error
(
result
,
strerror
(
result
))
...
...
src/gevent/_socket3.py
View file @
625c88b0
...
...
@@ -398,7 +398,7 @@ class socket(object):
if
not
result
or
result
==
EISCONN
:
break
el
if
(
result
in
(
EWOULDBLOCK
,
EINPROGRESS
,
EALREADY
))
or
(
result
==
EINVAL
and
is_windows
):
if
(
result
in
(
EWOULDBLOCK
,
EINPROGRESS
,
EALREADY
))
or
(
result
==
EINVAL
and
is_windows
):
self
.
_wait
(
self
.
_write_event
)
else
:
if
(
isinstance
(
address
,
tuple
)
...
...
src/gevent/_ssl2.py
View file @
625c88b0
...
...
@@ -235,8 +235,7 @@ class SSLSocket(socket):
sys
.
exc_clear
()
self
.
_wait
(
self
.
_read_event
)
continue
else
:
raise
raise
else
:
return
socket
.
recv_into
(
self
,
buffer
,
nbytes
,
flags
)
...
...
src/gevent/_ssl3.py
View file @
625c88b0
...
...
@@ -44,6 +44,31 @@ if 'namedtuple' in __all__:
orig_SSLContext
=
__ssl__
.
SSLContext
# pylint:disable=no-member
# We have to pass the raw stdlib socket to SSLContext.wrap_socket.
# That method in turn can pass that object on to things like SNI callbacks.
# It wouldn't have access to any of the attributes on the SSLSocket, like
# context, that it's supposed to (see test_ssl.test_sni_callback). Previously
# we just delegated to the sslsocket with __getattr__, but 3.8
# added some new callbacks and a test that the object they get is an instance
# of the high-level SSLSocket class, so that doesn't work anymore. Instead,
# we wrap the callback and get the real socket to pass on.
class
_contextawaresock
(
socket
.
_gevent_sock_class
):
__slots__
=
(
'_sslsock'
,)
def
__init__
(
self
,
family
,
type
,
proto
,
fileno
,
sslsocket_wref
):
super
().
__init__
(
family
,
type
,
proto
,
fileno
)
self
.
_sslsock
=
sslsocket_wref
class
_Callback
(
object
):
__slots__
=
(
'user_function'
,)
def
__init__
(
self
,
user_function
):
self
.
user_function
=
user_function
def
__call__
(
self
,
conn
,
*
args
):
conn
=
conn
.
_sslsock
()
return
self
.
user_function
(
conn
,
*
args
)
class
SSLContext
(
orig_SSLContext
):
...
...
@@ -68,10 +93,6 @@ class SSLContext(orig_SSLContext):
_context
=
self
,
_session
=
session
)
if
not
hasattr
(
orig_SSLContext
,
'check_hostname'
):
# Python 3.3 lacks this
check_hostname
=
False
if
hasattr
(
orig_SSLContext
.
options
,
'setter'
):
# In 3.6, these became properties. They want to access the
# property __set__ method in the superclass, and they do so by using
...
...
@@ -108,52 +129,44 @@ class SSLContext(orig_SSLContext):
# SSLContext back. This function cannot switch, so it should be safe,
# unless somehow we have multiple threads in a monkey-patched ssl module
# at the same time, which doesn't make much sense.
@
orig_SSLContext
.
_msg_callback
.
setter
@
property
def
_msg_callback
(
self
):
result
=
super
().
_msg_callback
if
isinstance
(
result
,
_Callback
):
result
=
result
.
user_function
return
result
@
_msg_callback
.
setter
def
_msg_callback
(
self
,
value
):
if
value
and
callable
(
value
):
value
=
_Callback
(
value
)
__ssl__
.
SSLContext
=
orig_SSLContext
try
:
super
(
SSLContext
,
SSLContext
).
_msg_callback
.
__set__
(
self
,
value
)
finally
:
__ssl__
.
SSLContext
=
SSLContext
class
_contextawaresock
(
socket
.
_gevent_sock_class
):
# We have to pass the raw stdlib socket to SSLContext.wrap_socket.
# That method in turn can pass that object on to things like SNI callbacks.
# It wouldn't have access to any of the attributes on the SSLSocket, like
# context, that it's supposed to (see test_ssl.test_sni_callback). Our
# solution is to keep a weak reference to the SSLSocket on the raw
# socket and delegate.
# We keep it in a slot to avoid having the ability to set any attributes
# we're not prepared for (because we don't know what to delegate.)
__slots__
=
(
'_sslsock'
,)
@
property
def
context
(
self
):
return
self
.
_sslsock
().
context
@
context
.
setter
def
context
(
self
,
ctx
):
self
.
_sslsock
().
context
=
ctx
@
property
def
session
(
self
):
"""The SSLSession for client socket."""
return
self
.
_sslsock
().
session
if
hasattr
(
orig_SSLContext
,
'sni_callback'
):
# Added in 3.7.
@
property
def
sni_callback
(
self
):
result
=
super
().
sni_callback
if
isinstance
(
result
,
_Callback
):
result
=
result
.
user_function
return
result
@
sni_callback
.
setter
def
sni_callback
(
self
,
value
):
if
value
and
callable
(
value
):
value
=
_Callback
(
value
)
super
(
orig_SSLContext
,
orig_SSLContext
).
sni_callback
.
__set__
(
self
,
value
)
else
:
# In newer versions, this just sets sni_callback.
def
set_servername_callback
(
self
,
cb
):
# pylint:disable=arguments-differ
if
cb
and
callable
(
cb
):
cb
=
_Callback
(
cb
)
super
().
set_servername_callback
(
cb
)
@
session
.
setter
def
session
(
self
,
session
):
self
.
_sslsock
().
session
=
session
def
__getattr__
(
self
,
name
):
try
:
return
getattr
(
self
.
_sslsock
(),
name
)
except
RuntimeError
:
# XXX: If the attribute doesn't exist,
# we infinitely recurse
pass
raise
AttributeError
(
name
)
class
SSLSocket
(
socket
):
"""
...
...
@@ -164,8 +177,6 @@ class SSLSocket(socket):
# pylint:disable=too-many-instance-attributes,too-many-public-methods
_gevent_sock_class
=
_contextawaresock
def
__init__
(
self
,
sock
=
None
,
keyfile
=
None
,
certfile
=
None
,
server_side
=
False
,
cert_reqs
=
CERT_NONE
,
ssl_version
=
PROTOCOL_SSLv23
,
ca_certs
=
None
,
...
...
@@ -243,7 +254,6 @@ class SSLSocket(socket):
else
:
socket
.
__init__
(
self
,
family
=
family
,
type
=
type
,
proto
=
proto
)
self
.
_sock
.
_sslsock
=
_wref
(
self
)
self
.
_closed
=
False
self
.
_sslobj
=
None
# see if we're connected
...
...
@@ -274,6 +284,9 @@ class SSLSocket(socket):
self
.
close
()
raise
x
def
_gevent_sock_class
(
self
,
family
,
type
,
proto
,
fileno
):
return
_contextawaresock
(
family
,
type
,
proto
,
fileno
,
_wref
(
self
))
def
_extra_repr
(
self
):
return
' server=%s, cipher=%r'
%
(
self
.
server_side
,
...
...
src/gevent/hub.py
View file @
625c88b0
...
...
@@ -462,18 +462,29 @@ class Hub(WaitOperationsGreenlet):
def
handle_error
(
self
,
context
,
type
,
value
,
tb
):
"""
Called by the event loop when an error occurs. The arguments
type, value, and tb are the standard tuple returned by :func:`sys.exc_info`.
Called by the event loop when an error occurs. The default
action is to print the exception to the :attr:`exception
stream <exception_stream>`.
Applications can set a property on the hub with this same signature
to override the error handling provided by this class.
The arguments ``type``, ``value``, and ``tb`` are the standard
tuple as returned by :func:`sys.exc_info`. (Note that when
this is called, it may not be safe to call
:func:`sys.exc_info`.)
Errors that are :attr:`
system errors <SYSTEM_ERROR>` are passed
to :meth:`handle_system_error`
.
Errors that are :attr:`
not errors <NOT_ERROR>` are not
printed
.
:param context: If this is ``None``, indicates a system error that
should generally result in exiting the loop and being thrown to the
parent greenlet.
Errors that are :attr:`system errors <SYSTEM_ERROR>` are
passed to :meth:`handle_system_error` after being printed.
Applications can set a property on the hub instance with this
same signature to override the error handling provided by this
class. This is an advanced usage and requires great care. This
function *must not* raise any exceptions.
:param context: If this is ``None``, indicates a system error
that should generally result in exiting the loop and being
thrown to the parent greenlet.
"""
if
isinstance
(
value
,
str
):
# Cython can raise errors where the value is a plain string
...
...
@@ -513,7 +524,8 @@ class Hub(WaitOperationsGreenlet):
def
exception_stream
(
self
):
"""
The stream to which exceptions will be written.
Defaults to ``sys.stderr`` unless assigned to.
Defaults to ``sys.stderr`` unless assigned. Assigning a
false (None) value disables printing exceptions.
.. versionadded:: 1.2a1
"""
...
...
src/gevent/subprocess.py
View file @
625c88b0
...
...
@@ -49,8 +49,9 @@ from gevent._compat import PY36
from
gevent._compat
import
PY37
from
gevent._compat
import
PY38
from
gevent._compat
import
reraise
from
gevent._compat
import
fs
path
from
gevent._compat
import
fs
decode
from
gevent._compat
import
fsencode
from
gevent._compat
import
PathLike
from
gevent._util
import
_NONE
from
gevent._util
import
copy_globals
...
...
@@ -648,7 +649,7 @@ class Popen(object):
# Convert here for the sake of all platforms. os.chdir accepts
# path-like objects natively under 3.6, but CreateProcess
# doesn't.
cwd
=
fs
path
(
cwd
)
if
cwd
is
not
None
else
None
cwd
=
fs
decode
(
cwd
)
if
cwd
is
not
None
else
None
try
:
self
.
_execute_child
(
args
,
executable
,
preexec_fn
,
close_fds
,
pass_fds
,
cwd
,
env
,
universal_newlines
,
...
...
@@ -983,6 +984,22 @@ class Popen(object):
"""Execute program (MS Windows version)"""
# pylint:disable=undefined-variable
assert
not
pass_fds
,
"pass_fds not supported on Windows."
if
isinstance
(
args
,
str
):
pass
elif
isinstance
(
args
,
bytes
):
if
shell
and
PY3
:
raise
TypeError
(
'bytes args is not allowed on Windows'
)
args
=
list2cmdline
([
args
])
elif
isinstance
(
args
,
PathLike
):
if
shell
:
raise
TypeError
(
'path-like args is not allowed when '
'shell is true'
)
args
=
list2cmdline
([
args
])
else
:
args
=
list2cmdline
(
args
)
if
executable
is
not
None
:
executable
=
fsdecode
(
executable
)
if
not
isinstance
(
args
,
string_types
):
args
=
list2cmdline
(
args
)
...
...
@@ -990,10 +1007,15 @@ class Popen(object):
# Process startup details
if
startupinfo
is
None
:
startupinfo
=
STARTUPINFO
()
elif
hasattr
(
startupinfo
,
'
_
copy'
):
elif
hasattr
(
startupinfo
,
'copy'
):
# bpo-34044: Copy STARTUPINFO since it is modified below,
# so the caller can reuse it multiple times.
startupinfo
=
startupinfo
.
copy
()
elif
hasattr
(
startupinfo
,
'_copy'
):
# When the fix was backported to Python 3.7, copy() was
# made private as _copy.
startupinfo
=
startupinfo
.
_copy
()
use_std_handles
=
-
1
not
in
(
p2cread
,
c2pwrite
,
errwrite
)
if
use_std_handles
:
startupinfo
.
dwFlags
|=
STARTF_USESTDHANDLES
...
...
@@ -1060,7 +1082,7 @@ class Popen(object):
int
(
not
close_fds
),
creationflags
,
env
,
cwd
,
cwd
,
# fsdecode handled earlier
startupinfo
)
except
IOError
as
e
:
# From 2.6 on, pywintypes.error was defined as IOError
# Translate pywintypes.error to WindowsError, which is
...
...
@@ -1345,14 +1367,20 @@ class Popen(object):
args
=
[
args
]
elif
not
PY3
and
isinstance
(
args
,
string_types
):
args
=
[
args
]
elif
isinstance
(
args
,
PathLike
):
if
shell
:
raise
TypeError
(
'path-like args is not allowed when '
'shell is true'
)
args
=
[
fsencode
(
args
)]
# os.PathLike -> [str]
else
:
try
:
args
=
list
(
args
)
except
TypeError
:
# os.PathLike instead of a sequence?
args
=
[
fsencode
(
args
)]
# os.PathLike -> [str]
args
=
list
(
args
)
if
shell
:
args
=
[
"/bin/sh"
,
"-c"
]
+
args
# On Android the default shell is at '/system/bin/sh'.
unix_shell
=
(
'/system/bin/sh'
if
hasattr
(
sys
,
'getandroidapilevel'
)
else
'/bin/sh'
)
args
=
[
unix_shell
,
"-c"
]
+
args
if
executable
:
args
[
0
]
=
executable
...
...
src/gevent/testing/monkey_test.py
View file @
625c88b0
...
...
@@ -24,6 +24,7 @@ from .patched_tests_setup import disable_tests_in_source
from
.
import
support
from
.
import
resources
from
.
import
SkipTest
from
.
import
util
if
RUNNING_ON_APPVEYOR
and
PY37
:
# 3.7 added a stricter mode for thread cleanup.
...
...
@@ -42,6 +43,15 @@ if RUNNING_ON_APPVEYOR and PY37:
# Configure allowed resources
resources
.
setup_resources
()
if
not
os
.
path
.
exists
(
test_filename
)
and
os
.
sep
not
in
test_filename
:
# A simple filename, given without a path, that doesn't exist.
# So we change to the appropriate directory, if we can find it.
# This happens when copy-pasting the output of the testrunner
for
d
in
util
.
find_stdlib_tests
():
if
os
.
path
.
exists
(
os
.
path
.
join
(
d
,
test_filename
)):
os
.
chdir
(
d
)
break
__file__
=
os
.
path
.
join
(
os
.
getcwd
(),
test_filename
)
test_name
=
os
.
path
.
splitext
(
test_filename
)[
0
]
...
...
src/gevent/testing/openfiles.py
View file @
625c88b0
...
...
@@ -108,9 +108,32 @@ else:
(socket.listen(1)). Unlike the lsof implementation, this will only
return sockets in a state like that.
"""
# We've seen OSError: No such file or directory
# /proc/PID/fd/NUM. This occurs in the loop that checks open
# files. It first does listdir() and then tries readlink() on
# each file. But the file went away. This must be because of
# async GC in PyPy running destructors at arbitrary times.
# This became an issue in PyPy 7.2 but could theoretically be
# an issue with any objects caught in a cycle. Try to clean
# that up before we begin.
import
gc
gc
.
collect
()
gc
.
collect
()
results
=
dict
()
process
=
psutil
.
Process
()
results
[
'data'
]
=
process
.
open_files
()
+
process
.
connections
(
'all'
)
gc
.
disable
()
try
:
for
_
in
range
(
3
):
try
:
process
=
psutil
.
Process
()
results
[
'data'
]
=
process
.
open_files
()
+
process
.
connections
(
'all'
)
break
except
OSError
:
pass
else
:
# No break executed
raise
unittest
.
SkipTest
(
"Unable to read open files"
)
finally
:
gc
.
enable
()
for
x
in
results
[
'data'
]:
results
[
x
.
fd
]
=
x
results
[
'data'
]
+=
[
'From psutil'
,
process
]
...
...
src/gevent/testing/sysinfo.py
View file @
625c88b0
...
...
@@ -137,3 +137,16 @@ RESOLVER_ARES = os.getenv('GEVENT_RESOLVER') == 'ares'
RESOLVER_DNSPYTHON
=
os
.
getenv
(
'GEVENT_RESOLVER'
)
==
'dnspython'
RESOLVER_NOT_SYSTEM
=
RESOLVER_ARES
or
RESOLVER_DNSPYTHON
def
get_python_version
():
"""
Return a string of the simple python version,
such as '3.8.0b4'. Handles alpha and beta and final releases.
"""
version
=
'%s.%s.%s'
%
sys
.
version_info
[:
3
]
if
sys
.
version_info
[
3
]
==
'alpha'
:
version
+=
'a%s'
%
sys
.
version_info
[
4
]
elif
sys
.
version_info
[
3
]
==
'beta'
:
version
+=
'b%s'
%
sys
.
version_info
[
4
]
return
version
src/gevent/testing/util.py
View file @
625c88b0
...
...
@@ -418,6 +418,40 @@ def search_for_setup_py(a_file=None, a_module_name=None, a_class=None, climb_cwd
raise
NoSetupPyFound
(
"After checking %r"
%
(
locals
(),))
def
_version_dir_components
():
directory
=
'%s.%s'
%
sys
.
version_info
[:
2
]
full_directory
=
'%s.%s.%s'
%
sys
.
version_info
[:
3
]
if
hasattr
(
sys
,
'pypy_version_info'
):
directory
+=
'pypy'
full_directory
+=
'pypy'
return
directory
,
full_directory
def
find_stdlib_tests
():
"""
Return a sequence of directories that could contain
stdlib tests for the running version of Python.
The most specific tests are at the end of the sequence.
No checks are performed on existence of the directories.
"""
setup_py
=
search_for_setup_py
(
a_file
=
__file__
)
greentest
=
os
.
path
.
join
(
setup_py
,
'src'
,
'greentest'
)
directory
,
full_directory
=
_version_dir_components
()
directory
=
'%s.%s'
%
sys
.
version_info
[:
2
]
full_directory
=
'%s.%s.%s'
%
sys
.
version_info
[:
3
]
if
hasattr
(
sys
,
'pypy_version_info'
):
directory
+=
'pypy'
full_directory
+=
'pypy'
directory
=
os
.
path
.
join
(
greentest
,
directory
)
full_directory
=
os
.
path
.
join
(
greentest
,
full_directory
)
return
directory
,
full_directory
class
ExampleMixin
(
object
):
"Something that uses the examples/ directory"
...
...
src/gevent/tests/test___monkey_patching.py
View file @
625c88b0
...
...
@@ -6,35 +6,12 @@ import atexit
# subprocess: include in subprocess tests
from
gevent.testing
import
util
from
gevent.testing
import
sysinfo
TIMEOUT
=
120
# XXX: Generalize this so other packages can use it.
def
find_stdlib_tests
():
setup_py
=
util
.
search_for_setup_py
(
a_file
=
__file__
)
greentest
=
os
.
path
.
join
(
setup_py
,
'src'
,
'greentest'
)
directory
=
'%s.%s'
%
sys
.
version_info
[:
2
]
full_directory
=
'%s.%s.%s'
%
sys
.
version_info
[:
3
]
if
hasattr
(
sys
,
'pypy_version_info'
):
directory
+=
'pypy'
full_directory
+=
'pypy'
directory
=
os
.
path
.
join
(
greentest
,
directory
)
full_directory
=
os
.
path
.
join
(
greentest
,
full_directory
)
return
directory
,
full_directory
def
get_python_version
():
version
=
'%s.%s.%s'
%
sys
.
version_info
[:
3
]
if
sys
.
version_info
[
3
]
==
'alpha'
:
version
+=
'a%s'
%
sys
.
version_info
[
4
]
elif
sys
.
version_info
[
3
]
==
'beta'
:
version
+=
'b%s'
%
sys
.
version_info
[
4
]
return
version
def
get_absolute_pythonpath
():
paths
=
[
os
.
path
.
abspath
(
p
)
for
p
in
os
.
environ
.
get
(
'PYTHONPATH'
,
''
).
split
(
os
.
pathsep
)]
...
...
@@ -43,7 +20,7 @@ def get_absolute_pythonpath():
def
TESTRUNNER
(
tests
=
None
):
try
:
test_dir
,
version_test_dir
=
find_stdlib_tests
()
test_dir
,
version_test_dir
=
util
.
find_stdlib_tests
()
except
util
.
NoSetupPyFound
as
e
:
util
.
log
(
"WARNING: No setup.py and src/greentest found: %r"
,
e
,
color
=
"suboptimal-behaviour"
)
...
...
@@ -57,7 +34,7 @@ def TESTRUNNER(tests=None):
with
open
(
os
.
path
.
join
(
test_dir
,
'version'
))
as
f
:
preferred_version
=
f
.
read
().
strip
()
running_version
=
get_python_version
()
running_version
=
sysinfo
.
get_python_version
()
if
preferred_version
!=
running_version
:
util
.
log
(
'WARNING: The tests in %s/ are from version %s and your Python is %s'
,
test_dir
,
preferred_version
,
running_version
,
...
...
src/gevent/tests/test__makefile_ref.py
View file @
625c88b0
...
...
@@ -110,112 +110,97 @@ class Test(greentest.TestCase):
def
make_open_socket
(
self
):
s
=
socket
.
socket
()
s
.
bind
(
DEFAULT_BIND_ADDR_TUPLE
)
self
.
_close_on_teardown
(
s
)
if
WIN
or
greentest
.
LINUX
:
# Windows and linux (with psutil) doesn't show as open until
# we call listen (linux with lsof accepts either)
s
.
listen
(
1
)
self
.
assert_open
(
s
,
s
.
fileno
())
try
:
s
.
bind
(
DEFAULT_BIND_ADDR_TUPLE
)
if
WIN
or
greentest
.
LINUX
:
# Windows and linux (with psutil) doesn't show as open until
# we call listen (linux with lsof accepts either)
s
.
listen
(
1
)
self
.
assert_open
(
s
,
s
.
fileno
())
except
:
s
.
close
()
s
=
None
raise
return
s
if
CPYTHON
and
PY2
:
# Keeping raw sockets alive keeps SSL sockets
# from being closed too, at least on CPython2, so we
# need to use weakrefs.
# In contrast, on PyPy, *only* having a weakref lets the
# original socket die and leak
def
_close_on_teardown
(
self
,
resource
):
self
.
close_on_teardown
.
append
(
weakref
.
ref
(
resource
))
return
resource
def
_tearDownCloseOnTearDown
(
self
):
self
.
close_on_teardown
=
[
r
()
for
r
in
self
.
close_on_teardown
if
r
()
is
not
None
]
super
(
Test
,
self
).
_tearDownCloseOnTearDown
()
# Sometimes its this one, sometimes it's test_ssl. No clue why or how.
@
greentest
.
skipOnAppVeyor
(
"This sometimes times out for no apparent reason."
)
class
TestSocket
(
Test
):
def
test_simple_close
(
self
):
s
=
self
.
make_open_socket
()
fileno
=
s
.
fileno
()
s
.
close
()
with
Closing
()
as
closer
:
s
=
closer
(
self
.
make_open_socket
())
fileno
=
s
.
fileno
()
s
.
close
()
self
.
assert_closed
(
s
,
fileno
)
def
test_makefile1
(
self
):
s
=
self
.
make_open_socket
()
fileno
=
s
.
fileno
()
f
=
s
.
makefile
()
self
.
assert_open
(
s
,
fileno
)
s
.
close
()
# Under python 2, this closes socket wrapper object but not the file descriptor;
# under python 3, both stay open
if
PY3
:
with
Closing
()
as
closer
:
s
=
closer
(
self
.
make_open_socket
())
fileno
=
s
.
fileno
()
f
=
closer
(
s
.
makefile
())
self
.
assert_open
(
s
,
fileno
)
else
:
# Under python 2, this closes socket wrapper object but not the file descriptor;
# under python 3, both stay open
s
.
close
()
if
PY3
:
self
.
assert_open
(
s
,
fileno
)
else
:
self
.
assert_closed
(
s
)
self
.
assert_open
(
fileno
)
f
.
close
()
self
.
assert_closed
(
s
)
self
.
assert_open
(
fileno
)
f
.
close
()
self
.
assert_closed
(
s
)
self
.
assert_closed
(
fileno
)
self
.
assert_closed
(
fileno
)
def
test_makefile2
(
self
):
s
=
self
.
make_open_socket
()
fileno
=
s
.
fileno
()
self
.
assert_open
(
s
,
fileno
)
f
=
s
.
makefile
()
self
.
assert_open
(
s
)
self
.
assert_open
(
s
,
fileno
)
f
.
close
()
# closing fileobject does not close the socket
self
.
assert_open
(
s
,
fileno
)
s
.
close
()
self
.
assert_closed
(
s
,
fileno
)
with
Closing
()
as
closer
:
s
=
closer
(
self
.
make_open_socket
())
fileno
=
s
.
fileno
()
self
.
assert_open
(
s
,
fileno
)
f
=
closer
(
s
.
makefile
())
self
.
assert_open
(
s
)
self
.
assert_open
(
s
,
fileno
)
f
.
close
()
# closing fileobject does not close the socket
self
.
assert_open
(
s
,
fileno
)
s
.
close
()
self
.
assert_closed
(
s
,
fileno
)
def
test_server_simple
(
self
):
listener
=
tcp_listener
(
backlog
=
1
)
port
=
listener
.
getsockname
()[
1
]
with
Closing
()
as
closer
:
listener
=
closer
(
tcp_listener
(
backlog
=
1
))
port
=
listener
.
getsockname
()[
1
]
connector
=
socket
.
socket
()
self
.
_close_on_teardown
(
connector
)
connector
=
closer
(
socket
.
socket
())
def
connect
():
connector
.
connect
((
DEFAULT_CONNECT
,
port
))
def
connect
():
connector
.
connect
((
DEFAULT_CONNECT
,
port
))
t
=
threading
.
Thread
(
target
=
connect
)
t
.
start
()
closer
.
running_task
(
threading
.
Thread
(
target
=
connect
))
try
:
client_socket
,
_addr
=
listener
.
accept
()
client_socket
=
closer
.
accept
(
listener
)
fileno
=
client_socket
.
fileno
()
self
.
assert_open
(
client_socket
,
fileno
)
client_socket
.
close
()
self
.
assert_closed
(
client_socket
)
finally
:
t
.
join
()
listener
.
close
()
connector
.
close
()
def
test_server_makefile1
(
self
):
listener
=
tcp_listener
(
backlog
=
1
)
port
=
listener
.
getsockname
()[
1
]
with
Closing
()
as
closer
:
listener
=
closer
(
tcp_listener
(
backlog
=
1
))
port
=
listener
.
getsockname
()[
1
]
connector
=
socket
.
socket
()
self
.
_close_on_teardown
(
connector
)
connector
=
closer
(
socket
.
socket
())
def
connect
():
connector
.
connect
((
DEFAULT_CONNECT
,
port
))
def
connect
():
connector
.
connect
((
DEFAULT_CONNECT
,
port
))
t
=
threading
.
Thread
(
target
=
connect
)
t
.
start
()
closer
.
running_task
(
threading
.
Thread
(
target
=
connect
))
try
:
client_socket
,
_addr
=
listener
.
accept
(
)
client_socket
=
closer
.
accept
(
listener
)
fileno
=
client_socket
.
fileno
()
f
=
cl
ient_socket
.
makefile
(
)
f
=
cl
oser
(
client_socket
.
makefile
()
)
self
.
assert_open
(
client_socket
,
fileno
)
client_socket
.
close
()
# Under python 2, this closes socket wrapper object but not the file descriptor;
...
...
@@ -227,38 +212,28 @@ class TestSocket(Test):
self
.
assert_open
(
fileno
)
f
.
close
()
self
.
assert_closed
(
client_socket
,
fileno
)
finally
:
t
.
join
()
listener
.
close
()
connector
.
close
()
def
test_server_makefile2
(
self
):
listener
=
tcp_listener
(
backlog
=
1
)
port
=
listener
.
getsockname
()[
1
]
with
Closing
()
as
closer
:
listener
=
closer
(
tcp_listener
(
backlog
=
1
))
port
=
listener
.
getsockname
()[
1
]
connector
=
socket
.
socket
()
self
.
_close_on_teardown
(
connector
)
connector
=
closer
(
socket
.
socket
())
def
connect
():
connector
.
connect
((
DEFAULT_CONNECT
,
port
))
def
connect
():
connector
.
connect
((
DEFAULT_CONNECT
,
port
))
t
=
threading
.
Thread
(
target
=
connect
)
t
.
start
(
)
closer
.
running_task
(
threading
.
Thread
(
target
=
connect
)
)
client_socket
=
closer
.
accept
(
listener
)
try
:
client_socket
,
_addr
=
listener
.
accept
()
fileno
=
client_socket
.
fileno
()
f
=
cl
ient_socket
.
makefile
(
)
f
=
cl
oser
(
client_socket
.
makefile
()
)
self
.
assert_open
(
client_socket
,
fileno
)
# closing fileobject does not close the socket
f
.
close
()
self
.
assert_open
(
client_socket
,
fileno
)
client_socket
.
close
()
self
.
assert_closed
(
client_socket
,
fileno
)
finally
:
t
.
join
()
listener
.
close
()
connector
.
close
()
@
greentest
.
skipOnAppVeyor
(
"This sometimes times out for no apparent reason."
)
...
...
@@ -281,7 +256,6 @@ class TestSSL(Test):
# our socket first, so this fails.
pass
else
:
#self._close_on_teardown(x)
x
.
close
()
def
_make_ssl_connect_task
(
self
,
connector
,
port
):
...
...
@@ -292,116 +266,82 @@ class TestSSL(Test):
t
.
accepted_event
=
accepted_event
return
t
def
__cleanup
(
self
,
task
,
*
sockets
):
# workaround for test_server_makefile1, test_server_makefile2,
# test_server_simple, test_serverssl_makefile1.
# On PyPy on Linux, it is important to join the SSL Connect
# Task FIRST, before closing the sockets. If we do it after
# (which makes more sense) we hang. It's not clear why, except
# that it has something to do with context switches. Inserting a call to
# gevent.sleep(0.1) instead of joining the task has the same
# effect. If the previous tests hang, then later tests can fail with
# SSLError: unknown alert type.
# XXX: Why do those two things happen?
# On PyPy on macOS, we don't have that problem and can use the
# more logical order.
task
.
join
()
for
s
in
sockets
:
try
:
close
=
s
.
close
except
AttributeError
:
continue
else
:
close
()
del
sockets
del
task
def
test_simple_close
(
self
):
s
=
self
.
make_open_socket
()
fileno
=
s
.
fileno
(
)
s
=
ssl
.
wrap_socket
(
s
)
self
.
_close_on_teardown
(
s
)
fileno
=
s
.
fileno
()
self
.
assert_open
(
s
,
fileno
)
s
.
close
()
self
.
assert_closed
(
s
,
fileno
)
with
Closing
()
as
closer
:
s
=
closer
(
self
.
make_open_socket
()
)
fileno
=
s
.
fileno
(
)
s
=
closer
(
ssl
.
wrap_socket
(
s
)
)
fileno
=
s
.
fileno
()
self
.
assert_open
(
s
,
fileno
)
s
.
close
()
self
.
assert_closed
(
s
,
fileno
)
def
test_makefile1
(
self
):
raw_s
=
self
.
make_open_socket
()
s
=
ssl
.
wrap_socket
(
raw_s
)
self
.
_close_on_teardown
(
s
)
fileno
=
s
.
fileno
()
self
.
assert_open
(
s
,
fileno
)
f
=
s
.
makefile
()
self
.
assert_open
(
s
,
fileno
)
s
.
close
()
self
.
assert_open
(
s
,
fileno
)
f
.
close
()
raw_s
.
close
()
self
.
assert_closed
(
s
,
fileno
)
with
Closing
()
as
closer
:
raw_s
=
closer
(
self
.
make_open_socket
())
s
=
closer
(
ssl
.
wrap_socket
(
raw_s
))
fileno
=
s
.
fileno
()
self
.
assert_open
(
s
,
fileno
)
f
=
closer
(
s
.
makefile
())
self
.
assert_open
(
s
,
fileno
)
s
.
close
()
self
.
assert_open
(
s
,
fileno
)
f
.
close
()
raw_s
.
close
()
self
.
assert_closed
(
s
,
fileno
)
def
test_makefile2
(
self
):
s
=
self
.
make_open_socket
()
fileno
=
s
.
fileno
(
)
s
=
ssl
.
wrap_socket
(
s
)
self
.
_close_on_teardown
(
s
)
fileno
=
s
.
fileno
()
self
.
assert_open
(
s
,
fileno
)
f
=
s
.
makefile
(
)
self
.
assert_open
(
s
,
fileno
)
f
.
close
()
# closing fileobject does not close the socket
self
.
assert_open
(
s
,
fileno
)
s
.
close
()
self
.
assert_closed
(
s
,
fileno
)
with
Closing
()
as
closer
:
s
=
closer
(
self
.
make_open_socket
()
)
fileno
=
s
.
fileno
()
s
=
closer
(
ssl
.
wrap_socket
(
s
)
)
fileno
=
s
.
fileno
()
self
.
assert_open
(
s
,
fileno
)
f
=
closer
(
s
.
makefile
()
)
self
.
assert_open
(
s
,
fileno
)
f
.
close
()
# closing fileobject does not close the socket
self
.
assert_open
(
s
,
fileno
)
s
.
close
()
self
.
assert_closed
(
s
,
fileno
)
def
test_server_simple
(
self
):
listener
=
tcp_listener
(
backlog
=
1
)
port
=
listener
.
getsockname
()[
1
]
with
Closing
()
as
closer
:
listener
=
closer
(
tcp_listener
(
backlog
=
1
))
port
=
listener
.
getsockname
()[
1
]
connector
=
socket
.
socket
()
self
.
_close_on_teardown
(
connector
)
connector
=
closer
(
socket
.
socket
())
t
=
self
.
_make_ssl_connect_task
(
connector
,
port
)
t
.
start
(
)
t
=
self
.
_make_ssl_connect_task
(
connector
,
port
)
closer
.
running_task
(
t
)
try
:
client_socket
,
_addr
=
listener
.
accept
()
client_socket
=
closer
.
accept
(
listener
)
t
.
accepted_event
.
set
()
self
.
_close_on_teardown
(
client_socket
.
close
)
client_socket
=
ssl
.
wrap_socket
(
client_socket
,
keyfile
=
certfile
,
certfile
=
certfile
,
server_side
=
True
)
self
.
_close_on_teardown
(
client_socket
)
client_socket
=
closer
(
ssl
.
wrap_socket
(
client_socket
,
keyfile
=
certfile
,
certfile
=
certfile
,
server_side
=
True
)
)
fileno
=
client_socket
.
fileno
()
self
.
assert_open
(
client_socket
,
fileno
)
client_socket
.
close
()
self
.
assert_closed
(
client_socket
,
fileno
)
finally
:
self
.
__cleanup
(
t
,
listener
,
connector
)
def
test_server_makefile1
(
self
):
listener
=
self
.
_close_on_teardown
(
tcp_listener
(
backlog
=
1
))
port
=
listener
.
getsockname
()[
1
]
with
Closing
()
as
closer
:
listener
=
closer
(
tcp_listener
(
backlog
=
1
))
port
=
listener
.
getsockname
()[
1
]
connector
=
socket
.
socket
()
self
.
_close_on_teardown
(
connector
)
connector
=
closer
(
socket
.
socket
())
t
=
self
.
_make_ssl_connect_task
(
connector
,
port
)
t
.
start
(
)
t
=
self
.
_make_ssl_connect_task
(
connector
,
port
)
closer
.
running_task
(
t
)
try
:
client_socket
,
_addr
=
listener
.
accept
()
client_socket
=
closer
.
accept
(
listener
)
t
.
accepted_event
.
set
()
self
.
_close_on_teardown
(
client_socket
.
close
)
# hard ref
client_socket
=
ssl
.
wrap_socket
(
client_socket
,
keyfile
=
certfile
,
certfile
=
certfile
,
server_side
=
True
)
self
.
_close_on_teardown
(
client_socket
)
client_socket
=
closer
(
ssl
.
wrap_socket
(
client_socket
,
keyfile
=
certfile
,
certfile
=
certfile
,
server_side
=
True
)
)
fileno
=
client_socket
.
fileno
()
self
.
assert_open
(
client_socket
,
fileno
)
f
=
client_socket
.
makefile
()
...
...
@@ -410,26 +350,22 @@ class TestSSL(Test):
self
.
assert_open
(
client_socket
,
fileno
)
f
.
close
()
self
.
assert_closed
(
client_socket
,
fileno
)
finally
:
self
.
__cleanup
(
t
,
listener
,
connector
)
def
test_server_makefile2
(
self
):
listener
=
tcp_listener
(
backlog
=
1
)
port
=
listener
.
getsockname
()[
1
]
connector
=
socket
.
socket
()
self
.
_close_on_teardown
(
connector
)
with
Closing
()
as
closer
:
listener
=
closer
(
tcp_listener
(
backlog
=
1
))
port
=
listener
.
getsockname
()[
1
]
t
=
self
.
_make_ssl_connect_task
(
connector
,
port
)
t
.
start
()
connector
=
closer
(
socket
.
socket
())
t
=
self
.
_make_ssl_connect_task
(
connector
,
port
)
closer
.
running_task
(
t
)
try
:
client_socket
,
_addr
=
listener
.
accept
()
t
.
accepted_event
.
set
()
self
.
_close_on_teardown
(
client_socket
)
client_socket
=
ssl
.
wrap_socket
(
client_socket
,
keyfile
=
certfile
,
certfile
=
certfile
,
server_side
=
True
)
self
.
_close_on_teardown
(
client_socket
)
client_socket
=
closer
.
accept
(
listener
)
client_socket
=
closer
(
ssl
.
wrap_socket
(
client_socket
,
keyfile
=
certfile
,
certfile
=
certfile
,
server_side
=
True
))
fileno
=
client_socket
.
fileno
()
self
.
assert_open
(
client_socket
,
fileno
)
f
=
client_socket
.
makefile
()
...
...
@@ -439,23 +375,18 @@ class TestSSL(Test):
self
.
assert_open
(
client_socket
,
fileno
)
client_socket
.
close
()
self
.
assert_closed
(
client_socket
,
fileno
)
finally
:
self
.
__cleanup
(
t
,
connector
,
listener
,
client_socket
)
def
test_serverssl_makefile1
(
self
):
listener
=
self
.
_close_on_teardown
(
tcp_listener
(
backlog
=
1
)
)
fileno
=
listener
.
fileno
()
port
=
listener
.
getsockname
()[
1
]
listener
=
ssl
.
wrap_socket
(
listener
,
keyfile
=
certfile
,
certfile
=
certfile
)
raw_listener
=
tcp_listener
(
backlog
=
1
)
fileno
=
raw_
listener
.
fileno
()
port
=
raw_
listener
.
getsockname
()[
1
]
listener
=
ssl
.
wrap_socket
(
raw_
listener
,
keyfile
=
certfile
,
certfile
=
certfile
)
connector
=
socket
.
socket
()
self
.
_close_on_teardown
(
connector
)
t
=
self
.
_make_ssl_connect_task
(
connector
,
port
)
t
.
start
()
try
:
client_socket
,
_addr
=
listener
.
accept
()
with
CleaningUp
(
t
,
listener
,
raw_listener
,
connector
)
as
client_socket
:
t
.
accepted_event
.
set
()
fileno
=
client_socket
.
fileno
()
self
.
assert_open
(
client_socket
,
fileno
)
...
...
@@ -465,13 +396,11 @@ class TestSSL(Test):
self
.
assert_open
(
client_socket
,
fileno
)
f
.
close
()
self
.
assert_closed
(
client_socket
,
fileno
)
finally
:
self
.
__cleanup
(
t
,
listener
,
connector
)
def
test_serverssl_makefile2
(
self
):
listener
=
self
.
_close_on_teardown
(
tcp_listener
(
backlog
=
1
)
)
port
=
listener
.
getsockname
()[
1
]
listener
=
ssl
.
wrap_socket
(
listener
,
keyfile
=
certfile
,
certfile
=
certfile
)
raw_listener
=
tcp_listener
(
backlog
=
1
)
port
=
raw_
listener
.
getsockname
()[
1
]
listener
=
ssl
.
wrap_socket
(
raw_
listener
,
keyfile
=
certfile
,
certfile
=
certfile
)
accepted_event
=
threading
.
Event
()
def
connect
(
connector
=
socket
.
socket
()):
...
...
@@ -489,8 +418,7 @@ class TestSSL(Test):
t
.
daemon
=
True
t
.
start
()
client_socket
=
None
try
:
client_socket
,
_addr
=
listener
.
accept
()
with
CleaningUp
(
t
,
listener
,
raw_listener
)
as
client_socket
:
accepted_event
.
set
()
fileno
=
client_socket
.
fileno
()
self
.
assert_open
(
client_socket
,
fileno
)
...
...
@@ -505,8 +433,98 @@ class TestSSL(Test):
self
.
assert_open
(
client_socket
,
fileno
)
client_socket
.
close
()
self
.
assert_closed
(
client_socket
,
fileno
)
class
Closing
(
object
):
def
__init__
(
self
,
*
init
):
self
.
_objects
=
[]
for
i
in
init
:
self
.
closing
(
i
)
self
.
task
=
None
def
accept
(
self
,
listener
):
client_socket
,
_addr
=
listener
.
accept
()
return
self
.
closing
(
client_socket
)
def
__enter__
(
self
):
o
=
self
.
objects
()
if
len
(
o
)
==
1
:
return
o
[
0
]
return
self
if
PY2
and
CPYTHON
:
# This implementation depends or refcounting
# for things to close. Eww.
def
closing
(
self
,
o
):
self
.
_objects
.
append
(
weakref
.
ref
(
o
))
return
o
def
objects
(
self
):
return
[
r
()
for
r
in
self
.
_objects
if
r
()
is
not
None
]
else
:
def
objects
(
self
):
# PyPy returns an object without __len__...
return
list
(
reversed
(
self
.
_objects
))
def
closing
(
self
,
o
):
self
.
_objects
.
append
(
o
)
return
o
__call__
=
closing
def
running_task
(
self
,
thread
):
assert
self
.
task
is
None
self
.
task
=
thread
self
.
task
.
start
()
return
self
.
task
def
__exit__
(
self
,
t
,
v
,
tb
):
# workaround for test_server_makefile1, test_server_makefile2,
# test_server_simple, test_serverssl_makefile1.
# On PyPy on Linux, it is important to join the SSL Connect
# Task FIRST, before closing the sockets. If we do it after
# (which makes more sense) we hang. It's not clear why, except
# that it has something to do with context switches. Inserting a call to
# gevent.sleep(0.1) instead of joining the task has the same
# effect. If the previous tests hang, then later tests can fail with
# SSLError: unknown alert type.
# XXX: Why do those two things happen?
# On PyPy on macOS, we don't have that problem and can use the
# more logical order.
try
:
if
self
.
task
is
not
None
:
self
.
task
.
join
()
finally
:
self
.
__cleanup
(
t
,
listener
,
client_socket
)
self
.
task
=
None
for
o
in
self
.
objects
():
try
:
o
.
close
()
except
Exception
:
# pylint:disable=broad-except
pass
self
.
_objects
=
()
class
CleaningUp
(
Closing
):
def
__init__
(
self
,
task
,
listener
,
*
other_sockets
):
super
(
CleaningUp
,
self
).
__init__
(
listener
,
*
other_sockets
)
self
.
task
=
task
self
.
listener
=
listener
def
__enter__
(
self
):
return
self
.
accept
(
self
.
listener
)
def
__exit__
(
self
,
t
,
v
,
tb
):
try
:
Closing
.
__exit__
(
self
,
t
,
v
,
tb
)
finally
:
self
.
listener
=
None
if
__name__
==
'__main__'
:
...
...
src/gevent/tests/test__monkey_sigchld.py
View file @
625c88b0
import
errno
import
os
import
sys
#os.environ['GEVENT_NOWAITPID'] = 'True'
import
gevent
import
gevent.monkey
...
...
@@ -19,8 +18,27 @@ def handle_sigchld(*_args):
# Raise an ignored error
raise
TypeError
(
"This should be ignored but printed"
)
# Try to produce output compatible with unittest output so
# our status parsing functions work.
import
signal
if
hasattr
(
signal
,
'SIGCHLD'
):
# In Python 3.8.0 final, on both Travis CI/Linux and locally
# on macOS, the *child* process started crashing on exit with a memory
# error:
#
# Debug memory block at address p=0x7fcf5d6b5000: API ''
# 6508921152173528397 bytes originally requested
# The 7 pad bytes at p-7 are not all FORBIDDENBYTE (0xfd):
#
# When PYTHONDEVMODE is set. This happens even if we just simply fork
# the child process and don't have gevent even /imported/ in the most
# minimal test case. It's not clear what caused that.
if
sys
.
version_info
[:
2
]
>=
(
3
,
8
)
and
os
.
environ
.
get
(
"PYTHONDEVMODE"
):
print
(
"Ran 1 tests in 0.0s (skipped=1)"
)
sys
.
exit
(
0
)
assert
signal
.
getsignal
(
signal
.
SIGCHLD
)
==
signal
.
SIG_DFL
signal
.
signal
(
signal
.
SIGCHLD
,
handle_sigchld
)
handler
=
signal
.
getsignal
(
signal
.
SIGCHLD
)
...
...
@@ -64,6 +82,8 @@ if hasattr(signal, 'SIGCHLD'):
raise
AssertionError
(
"Failed to wait using"
,
func
)
finally
:
timeout
.
close
()
print
(
"Ran 1 tests in 0.0s"
)
sys
.
exit
(
0
)
else
:
print
(
"No SIGCHLD, not testing"
)
print
(
"Ran 1 tests in 0.0s (skipped=1)"
)
src/gevent/tests/test__monkey_sigchld_2.py
View file @
625c88b0
...
...
@@ -16,6 +16,11 @@ def handle(*_args):
os
.
waitpid
(
-
1
,
os
.
WNOHANG
)
# The signal watcher must be installed *before* monkey patching
if
hasattr
(
signal
,
'SIGCHLD'
):
if
sys
.
version_info
[:
2
]
>=
(
3
,
8
)
and
os
.
environ
.
get
(
"PYTHONDEVMODE"
):
# See test__monkey_sigchld.py
print
(
"Ran 1 tests in 0.0s (skipped=1)"
)
sys
.
exit
(
0
)
# On Python 2, the signal handler breaks the platform
# module, because it uses os.popen. pkg_resources uses the platform
# module.
...
...
src/gevent/tests/test__monkey_sigchld_3.py
View file @
625c88b0
...
...
@@ -25,6 +25,11 @@ def _waitpid(p):
assert
stat
==
0
,
stat
if
hasattr
(
signal
,
'SIGCHLD'
):
if
sys
.
version_info
[:
2
]
>=
(
3
,
8
)
and
os
.
environ
.
get
(
"PYTHONDEVMODE"
):
# See test__monkey_sigchld.py
print
(
"Ran 1 tests in 0.0s (skipped=1)"
)
sys
.
exit
(
0
)
# Do what subprocess does and make sure we have the watcher
# in the parent
get_hub
().
loop
.
install_sigchld
()
...
...
@@ -50,3 +55,4 @@ if hasattr(signal, 'SIGCHLD'):
sys
.
exit
(
0
)
else
:
print
(
"No SIGCHLD, not testing"
)
print
(
"Ran 1 tests in 0.0s (skipped=1)"
)
src/gevent/tests/test__pywsgi.py
View file @
625c88b0
...
...
@@ -636,11 +636,11 @@ class TestChunkedPost(TestCase):
return
[
data
]
if
env
[
'PATH_INFO'
]
==
'/b'
:
lines
=
[
x
for
x
in
iter
(
lambda
:
env
[
'wsgi.input'
].
read
(
6
),
b''
)]
lines
=
list
(
iter
(
lambda
:
env
[
'wsgi.input'
].
read
(
6
),
b''
))
return
lines
if
env
[
'PATH_INFO'
]
==
'/c'
:
return
[
x
for
x
in
iter
(
lambda
:
env
[
'wsgi.input'
].
read
(
1
),
b''
)]
return
list
(
iter
(
lambda
:
env
[
'wsgi.input'
].
read
(
1
),
b''
))
def
test_014_chunked_post
(
self
):
data
=
(
b'POST /a HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
'
...
...
src/gevent/tests/test__ssl.py
View file @
625c88b0
...
...
@@ -9,6 +9,8 @@ import gevent.testing as greentest
from
gevent.tests
import
test__socket
import
ssl
from
gevent.testing
import
PY2
def
ssl_listener
(
private_key
,
certificate
):
raw_listener
=
socket
.
socket
()
greentest
.
bind_and_listen
(
raw_listener
)
...
...
@@ -24,8 +26,11 @@ class TestSSL(test__socket.TestTCP):
# ssl.SSLError); That's gone in Py3 though. In Python 2, most timeouts are raised
# as SSLError, but Python 3 raises the normal socket.timeout instead. So this has
# the effect of making TIMEOUT_ERROR be SSLError on Py2 and socket.timeout on Py3
# See https://bugs.python.org/issue10272
TIMEOUT_ERROR
=
getattr
(
socket
,
'sslerror'
,
socket
.
timeout
)
# See https://bugs.python.org/issue10272.
# PyPy3 7.2 has a bug, though: it shares much of the SSL implementation with Python 2,
# and it unconditionally does `socket.sslerror = SSLError` when ssl is imported.
# So we can't rely on getattr/hasattr tests, we must be explicit.
TIMEOUT_ERROR
=
socket
.
sslerror
if
PY2
else
socket
.
timeout
# pylint:disable=no-member
def
_setup_listener
(
self
):
listener
,
raw_listener
=
ssl_listener
(
self
.
privfile
,
self
.
certfile
)
...
...
src/greentest/3.7/keycert.passwd.pem
View file @
625c88b0
-----BEGIN
RSA
PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,D134E931C96D9DEC
nuGFEej7vIjkYWSMz5OJeVTNntDRQi6ZM4DBm3g8T7i/0odr3WFqGMMKZcIhLYQf
rgRq7RSKtrJ1y5taVucMV+EuCjyfzDo0TsYt+ZrXv/D08eZhjRmkhoHnGVF0TqQm
nQEXM/ERT4J2RM78dnG+homMkI76qOqxgGbRqQqJo6AiVRcAZ45y8s96bru2TAB8
+pWjO/v0Je7AFVdwSU52N8OOY6uoSAygW+0UY1WVxbVGJF2XfRsNpPX+YQHYl6e+
3xM5XBVCgr6kmdAyub5qUJ38X3TpdVGoR0i+CVS9GTr2pSRib1zURAeeHnlqiUZM
4m0Gn9s72nJevU1wxED8pwOhR8fnHEmMKGD2HPhKoOCbzDhwwBZO27TNa1uWeM3f
M5oixKDi2PqMn3y2cDx1NjJtP661688EcJ5a2Ih9BgO9xpnhSyzBWEKcAn0tJB0H
/56M0FW6cdOOIzMveGGL7sHW5E+iOdI1n5e7C6KJUzew78Y9qJnhS53EdI6qTz9R
wsIsj1i070Fk6RbPo6zpLlF6w7Zj8GlZaZA7OZZv9wo5VEV/0ST8gmiiBOBc4C6Y
u9hyLIIu4dFEBKyQHRvBnQSLNpKx6or1OGFDVBay2In9Yh2BHh1+vOj/OIz/wq48
EHOIV27fRJxLu4jeK5LIGDhuPnMJ8AJYQ0bQOUP6fd7p+TxWkAQZPB/Dx/cs3hx
r
nFEdzx+eO+IAsObx/b1EGZyEJyETBslu4GwYX7/KK3HsJhDJ1bdZ//28jOCaoir6
ZOMT72GRwmVoQTJ0XpccfjHfKJDRLT7C1xvzo4Eibth0hpTZkA75IUYUp6qK/PuJ
kH/qdiC7QIkRKtsrawW4vEDna3YtxIYhQqz9+KwO6u/0gzooZtv1RU4U3ifMDB5u
5P5GAz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MCEGA1UECgwaUHl0aG9u
...
...
@@ -66,3 +66,4 @@ jMqTFlmO7kpf/jpCSmamp3/JSEE1BJKHwQ6Ql4nzRA2N1mnvWH7Zxcv043gkHeAu
9Wc2uXpw9xF8itV4Uvcdr3dwqByvIqn7iI/gB+4l41e0u8OmH2MKOx4Nxlly5TNW
HcVKQHyOeyvnINuBAQ==
-----END CERTIFICATE-----
src/greentest/3.7/ssl_key.passwd.pem
View file @
625c88b0
-----BEGIN
RSA
PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,8064BE1494B24B13
KJrffOMbo8M0I3PzcYxRZGMpKD1yB3Ii4+bT5XoanxjIJ+4fdx6LfZ0Rsx+riyzs
tymsQu/iYY9j+4rCvN9+eetsL1X6iZpiimKsLexcid9M3fb0vxED5Sgw0dvunCUA
xhqjLIKR92MKbODHf6KrDKCpsiPbjq4gZ7P+uCGXAMHL3MXIJSC0hW9rK7Ce6oyO
CjpIcgB8x+GUWZZZhAFdlzIHMZrteNP2P5HK6QcaT71P034Dz1hhqoj4Q0t+Fta2
4tfsM/bnTR/l6hwlhPa1e3Uj322tDTDWBScgWANn5+sEWldLmozMaWhZsn22pfk2
KjRMGXG024JVheV882nbdOBvG7oq+lxkZ/ZP+vvqJqnvYtf7WtM8UivzYpe5Hz5b
kVvWzPjBLUSZ9whM9rDLqSSqMPyPvDTuEmLkuq+xm7pYJmsLqIMP2klZLqRxLX6K
uqwplb8UG440qauxgnQ905PId1l2fJEnRtV+7vXprA0L0QotgXLVHBhLmTFM+3PH
9H3onf31dionUAPrn3nfVE36HhvVgRyvDBnBzJSIMighgq21Qx/d1dk0DRYi1hUI
nCHl0YJPXheVcXR7JiSF2XQCAaFuS1Mr7NCXfWZOZQC/0dkvmHnl9DUAhuqq9BNZ
1cKhZXcKHadg2/r0Zup/oDzmHPUEfTAXT0xbqoWlhkdwbF2veWQ96A/ncx3ISTb4
PkXBlX9rdia8nmtyQDQRn4NuvchbaGkj4WK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ED
PRIVATE KEY-----
src/greentest/3.7/test_httplib.py
View file @
625c88b0
...
...
@@ -1157,6 +1157,34 @@ class BasicTest(TestCase):
thread
.
join
()
self
.
assertEqual
(
result
,
b"proxied data
\
n
"
)
def
test_putrequest_override_validation
(
self
):
"""
It should be possible to override the default validation
behavior in putrequest (bpo-38216).
"""
class
UnsafeHTTPConnection
(
client
.
HTTPConnection
):
def
_validate_path
(
self
,
url
):
pass
conn
=
UnsafeHTTPConnection
(
'example.com'
)
conn
.
sock
=
FakeSocket
(
''
)
conn
.
putrequest
(
'GET'
,
'/
\
x00
'
)
def
test_putrequest_override_encoding
(
self
):
"""
It should be possible to override the default encoding
to transmit bytes in another encoding even if invalid
(bpo-36274).
"""
class
UnsafeHTTPConnection
(
client
.
HTTPConnection
):
def
_encode_request
(
self
,
str_url
):
return
str_url
.
encode
(
'utf-8'
)
conn
=
UnsafeHTTPConnection
(
'example.com'
)
conn
.
sock
=
FakeSocket
(
''
)
conn
.
putrequest
(
'GET'
,
'/☃'
)
class
ExtendedReadTest
(
TestCase
):
"""
Test peek(), read1(), readline()
...
...
@@ -1281,6 +1309,7 @@ class ExtendedReadTest(TestCase):
p
=
self
.
resp
.
peek
(
0
)
self
.
assertLessEqual
(
0
,
len
(
p
))
class
ExtendedReadTestChunked
(
ExtendedReadTest
):
"""
Test peek(), read1(), readline() in chunked mode
...
...
src/greentest/3.7/test_ssl.py
View file @
625c88b0
...
...
@@ -19,6 +19,7 @@ import weakref
import
platform
import
functools
import
sysconfig
import
functools
try
:
import
ctypes
except
ImportError
:
...
...
@@ -142,6 +143,87 @@ OP_CIPHER_SERVER_PREFERENCE = getattr(ssl, "OP_CIPHER_SERVER_PREFERENCE", 0)
OP_ENABLE_MIDDLEBOX_COMPAT
=
getattr
(
ssl
,
"OP_ENABLE_MIDDLEBOX_COMPAT"
,
0
)
def
has_tls_protocol
(
protocol
):
"""Check if a TLS protocol is available and enabled
:param protocol: enum ssl._SSLMethod member or name
:return: bool
"""
if
isinstance
(
protocol
,
str
):
assert
protocol
.
startswith
(
'PROTOCOL_'
)
protocol
=
getattr
(
ssl
,
protocol
,
None
)
if
protocol
is
None
:
return
False
if
protocol
in
{
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLS_SERVER
,
ssl
.
PROTOCOL_TLS_CLIENT
}:
# auto-negotiate protocols are always available
return
True
name
=
protocol
.
name
return
has_tls_version
(
name
[
len
(
'PROTOCOL_'
):])
@
functools
.
lru_cache
()
def
has_tls_version
(
version
):
"""Check if a TLS/SSL version is enabled
:param version: TLS version name or ssl.TLSVersion member
:return: bool
"""
if
version
==
"SSLv2"
:
# never supported and not even in TLSVersion enum
return
False
if
isinstance
(
version
,
str
):
version
=
ssl
.
TLSVersion
.
__members__
[
version
]
# check compile time flags like ssl.HAS_TLSv1_2
if
not
getattr
(
ssl
,
f'HAS_
{
version
.
name
}
'
):
return
False
# check runtime and dynamic crypto policy settings. A TLS version may
# be compiled in but disabled by a policy or config option.
ctx
=
ssl
.
SSLContext
()
if
(
hasattr
(
ctx
,
'minimum_version'
)
and
ctx
.
minimum_version
!=
ssl
.
TLSVersion
.
MINIMUM_SUPPORTED
and
version
<
ctx
.
minimum_version
):
return
False
if
(
hasattr
(
ctx
,
'maximum_version'
)
and
ctx
.
maximum_version
!=
ssl
.
TLSVersion
.
MAXIMUM_SUPPORTED
and
version
>
ctx
.
maximum_version
):
return
False
return
True
def
requires_tls_version
(
version
):
"""Decorator to skip tests when a required TLS version is not available
:param version: TLS version name or ssl.TLSVersion member
:return:
"""
def
decorator
(
func
):
@
functools
.
wraps
(
func
)
def
wrapper
(
*
args
,
**
kw
):
if
not
has_tls_version
(
version
):
raise
unittest
.
SkipTest
(
f"
{
version
}
is not available."
)
else
:
return
func
(
*
args
,
**
kw
)
return
wrapper
return
decorator
requires_minimum_version
=
unittest
.
skipUnless
(
hasattr
(
ssl
.
SSLContext
,
'minimum_version'
),
"required OpenSSL >= 1.1.0g"
)
def
handle_error
(
prefix
):
exc_format
=
' '
.
join
(
traceback
.
format_exception
(
*
sys
.
exc_info
()))
if
support
.
verbose
:
...
...
@@ -849,8 +931,8 @@ class BasicSocketTests(unittest.TestCase):
cert
,
enc
,
trust
=
element
self
.
assertIsInstance
(
cert
,
bytes
)
self
.
assertIn
(
enc
,
{
"x509_asn"
,
"pkcs_7_asn"
})
self
.
assertIsInstance
(
trust
,
(
set
,
bool
))
if
isinstance
(
trust
,
set
):
self
.
assertIsInstance
(
trust
,
(
frozenset
,
set
,
bool
))
if
isinstance
(
trust
,
(
frozenset
,
set
)
):
trust_oids
.
update
(
trust
)
serverAuth
=
"1.3.6.1.5.5.7.3.1"
...
...
@@ -1124,19 +1206,23 @@ class ContextTests(unittest.TestCase):
with
self
.
assertRaises
(
AttributeError
):
ctx
.
hostname_checks_common_name
=
True
@
unittest
.
skipUnless
(
hasattr
(
ssl
.
SSLContext
,
'minimum_version'
),
"required OpenSSL 1.1.0g
"
)
@
requires_minimum_version
@
unittest
.
skipIf
(
IS_LIBRESSL
,
"see bpo-34001
"
)
def
test_min_max_version
(
self
):
ctx
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_TLS_SERVER
)
# OpenSSL default is MINIMUM_SUPPORTED, however some vendors like
# Fedora override the setting to TLS 1.0.
minimum_range
=
{
# stock OpenSSL
ssl
.
TLSVersion
.
MINIMUM_SUPPORTED
,
# Fedora 29 uses TLS 1.0 by default
ssl
.
TLSVersion
.
TLSv1
,
# RHEL 8 uses TLS 1.2 by default
ssl
.
TLSVersion
.
TLSv1_2
}
self
.
assertIn
(
ctx
.
minimum_version
,
{
ssl
.
TLSVersion
.
MINIMUM_SUPPORTED
,
# Fedora 29 uses TLS 1.0 by default
ssl
.
TLSVersion
.
TLSv1
,
# RHEL 8 uses TLS 1.2 by default
ssl
.
TLSVersion
.
TLSv1_2
}
ctx
.
minimum_version
,
minimum_range
)
self
.
assertEqual
(
ctx
.
maximum_version
,
ssl
.
TLSVersion
.
MAXIMUM_SUPPORTED
...
...
@@ -1182,8 +1268,8 @@ class ContextTests(unittest.TestCase):
ctx
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_TLSv1_1
)
self
.
assert
Equal
(
ctx
.
minimum_version
,
ssl
.
TLSVersion
.
MINIMUM_SUPPORTED
self
.
assert
In
(
ctx
.
minimum_version
,
minimum_range
)
self
.
assertEqual
(
ctx
.
maximum_version
,
ssl
.
TLSVersion
.
MAXIMUM_SUPPORTED
...
...
@@ -2723,6 +2809,8 @@ class ThreadedTests(unittest.TestCase):
for
protocol
in
PROTOCOLS
:
if
protocol
in
{
ssl
.
PROTOCOL_TLS_CLIENT
,
ssl
.
PROTOCOL_TLS_SERVER
}:
continue
if
not
has_tls_protocol
(
protocol
):
continue
with
self
.
subTest
(
protocol
=
ssl
.
_PROTOCOL_NAMES
[
protocol
]):
context
=
ssl
.
SSLContext
(
protocol
)
context
.
load_cert_chain
(
CERTFILE
)
...
...
@@ -3014,7 +3102,7 @@ class ThreadedTests(unittest.TestCase):
else
:
self
.
fail
(
"Use of invalid cert should have failed!"
)
@
unittest
.
skipUnless
(
ssl
.
HAS_TLSv1_3
,
"Test needs TLS 1.3"
)
@
requires_tls_version
(
'TLSv1_3'
)
def
test_wrong_cert_tls13
(
self
):
client_context
,
server_context
,
hostname
=
testing_context
()
# load client cert that is not signed by trusted CA
...
...
@@ -3109,9 +3197,7 @@ class ThreadedTests(unittest.TestCase):
self
.
assertIn
(
msg
,
repr
(
e
))
self
.
assertIn
(
'certificate verify failed'
,
repr
(
e
))
@
skip_if_broken_ubuntu_ssl
@
unittest
.
skipUnless
(
hasattr
(
ssl
,
'PROTOCOL_SSLv2'
),
"OpenSSL is compiled without SSLv2 support"
)
@
requires_tls_version
(
'SSLv2'
)
def
test_protocol_sslv2
(
self
):
"""Connecting to an SSLv2 server with various client options"""
if
support
.
verbose
:
...
...
@@ -3120,7 +3206,7 @@ class ThreadedTests(unittest.TestCase):
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv2
,
ssl
.
PROTOCOL_SSLv2
,
True
,
ssl
.
CERT_OPTIONAL
)
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv2
,
ssl
.
PROTOCOL_SSLv2
,
True
,
ssl
.
CERT_REQUIRED
)
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv2
,
ssl
.
PROTOCOL_TLS
,
False
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv3'
):
if
has
_tls_version
(
'
SSLv3'
):
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv2
,
ssl
.
PROTOCOL_SSLv3
,
False
)
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv2
,
ssl
.
PROTOCOL_TLSv1
,
False
)
# SSLv23 client with specific SSL options
...
...
@@ -3138,7 +3224,7 @@ class ThreadedTests(unittest.TestCase):
"""Connecting to an SSLv23 server with various client options"""
if
support
.
verbose
:
sys
.
stdout
.
write
(
"
\
n
"
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv2'
):
if
has
_tls_version
(
'
SSLv2'
):
try
:
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_SSLv2
,
True
)
except
OSError
as
x
:
...
...
@@ -3147,35 +3233,36 @@ class ThreadedTests(unittest.TestCase):
sys
.
stdout
.
write
(
" SSL2 client to SSL23 server test unexpectedly failed:
\
n
%s
\
n
"
%
str
(
x
))
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv3'
):
if
has
_tls_version
(
'
SSLv3'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_SSLv3
,
False
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLS
,
True
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLSv1
,
'TLSv1'
)
if
has_tls_version
(
'TLSv1'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLSv1
,
'TLSv1'
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv3'
):
if
has
_tls_version
(
'
SSLv3'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_SSLv3
,
False
,
ssl
.
CERT_OPTIONAL
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLS
,
True
,
ssl
.
CERT_OPTIONAL
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLSv1
,
'TLSv1'
,
ssl
.
CERT_OPTIONAL
)
if
has_tls_version
(
'TLSv1'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLSv1
,
'TLSv1'
,
ssl
.
CERT_OPTIONAL
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv3'
):
if
has
_tls_version
(
'
SSLv3'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_SSLv3
,
False
,
ssl
.
CERT_REQUIRED
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLS
,
True
,
ssl
.
CERT_REQUIRED
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLSv1
,
'TLSv1'
,
ssl
.
CERT_REQUIRED
)
if
has_tls_version
(
'TLSv1'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLSv1
,
'TLSv1'
,
ssl
.
CERT_REQUIRED
)
# Server with specific SSL options
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv3'
):
if
has
_tls_version
(
'
SSLv3'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_SSLv3
,
False
,
server_options
=
ssl
.
OP_NO_SSLv3
)
# Will choose TLSv1
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLS
,
True
,
server_options
=
ssl
.
OP_NO_SSLv2
|
ssl
.
OP_NO_SSLv3
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLSv1
,
False
,
server_options
=
ssl
.
OP_NO_TLSv1
)
if
has_tls_version
(
'TLSv1'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLSv1
,
False
,
server_options
=
ssl
.
OP_NO_TLSv1
)
@
skip_if_broken_ubuntu_ssl
@
unittest
.
skipUnless
(
hasattr
(
ssl
,
'PROTOCOL_SSLv3'
),
"OpenSSL is compiled without SSLv3 support"
)
@
requires_tls_version
(
'SSLv3'
)
def
test_protocol_sslv3
(
self
):
"""Connecting to an SSLv3 server with various client options"""
if
support
.
verbose
:
...
...
@@ -3183,7 +3270,7 @@ class ThreadedTests(unittest.TestCase):
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv3
,
ssl
.
PROTOCOL_SSLv3
,
'SSLv3'
)
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv3
,
ssl
.
PROTOCOL_SSLv3
,
'SSLv3'
,
ssl
.
CERT_OPTIONAL
)
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv3
,
ssl
.
PROTOCOL_SSLv3
,
'SSLv3'
,
ssl
.
CERT_REQUIRED
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv2'
):
if
has
_tls_version
(
'
SSLv2'
):
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv3
,
ssl
.
PROTOCOL_SSLv2
,
False
)
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv3
,
ssl
.
PROTOCOL_TLS
,
False
,
client_options
=
ssl
.
OP_NO_SSLv3
)
...
...
@@ -3193,7 +3280,7 @@ class ThreadedTests(unittest.TestCase):
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv3
,
ssl
.
PROTOCOL_TLS
,
False
,
client_options
=
ssl
.
OP_NO_SSLv2
)
@
skip_if_broken_ubuntu_ssl
@
requires_tls_version
(
'TLSv1'
)
def
test_protocol_tlsv1
(
self
):
"""Connecting to a TLSv1 server with various client options"""
if
support
.
verbose
:
...
...
@@ -3201,36 +3288,32 @@ class ThreadedTests(unittest.TestCase):
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1
,
ssl
.
PROTOCOL_TLSv1
,
'TLSv1'
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1
,
ssl
.
PROTOCOL_TLSv1
,
'TLSv1'
,
ssl
.
CERT_OPTIONAL
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1
,
ssl
.
PROTOCOL_TLSv1
,
'TLSv1'
,
ssl
.
CERT_REQUIRED
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv2'
):
if
has
_tls_version
(
'
SSLv2'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1
,
ssl
.
PROTOCOL_SSLv2
,
False
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv3'
):
if
has
_tls_version
(
'
SSLv3'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1
,
ssl
.
PROTOCOL_SSLv3
,
False
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1
,
ssl
.
PROTOCOL_TLS
,
False
,
client_options
=
ssl
.
OP_NO_TLSv1
)
@
skip_if_broken_ubuntu_ssl
@
unittest
.
skipUnless
(
hasattr
(
ssl
,
"PROTOCOL_TLSv1_1"
),
"TLS version 1.1 not supported."
)
@
requires_tls_version
(
'TLSv1_1'
)
def
test_protocol_tlsv1_1
(
self
):
"""Connecting to a TLSv1.1 server with various client options.
Testing against older TLS versions."""
if
support
.
verbose
:
sys
.
stdout
.
write
(
"
\
n
"
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_1
,
ssl
.
PROTOCOL_TLSv1_1
,
'TLSv1.1'
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv2'
):
if
has
_tls_version
(
'
SSLv2'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_1
,
ssl
.
PROTOCOL_SSLv2
,
False
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv3'
):
if
has
_tls_version
(
'
SSLv3'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_1
,
ssl
.
PROTOCOL_SSLv3
,
False
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_1
,
ssl
.
PROTOCOL_TLS
,
False
,
client_options
=
ssl
.
OP_NO_TLSv1_1
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLSv1_1
,
'TLSv1.1'
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_1
,
ssl
.
PROTOCOL_TLSv1
,
False
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1
,
ssl
.
PROTOCOL_TLSv1_1
,
False
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_1
,
ssl
.
PROTOCOL_TLSv1
_2
,
False
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1
_2
,
ssl
.
PROTOCOL_TLSv1_1
,
False
)
@
skip_if_broken_ubuntu_ssl
@
unittest
.
skipUnless
(
hasattr
(
ssl
,
"PROTOCOL_TLSv1_2"
),
"TLS version 1.2 not supported."
)
@
requires_tls_version
(
'TLSv1_2'
)
def
test_protocol_tlsv1_2
(
self
):
"""Connecting to a TLSv1.2 server with various client options.
Testing against older TLS versions."""
...
...
@@ -3239,9 +3322,9 @@ class ThreadedTests(unittest.TestCase):
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_2
,
ssl
.
PROTOCOL_TLSv1_2
,
'TLSv1.2'
,
server_options
=
ssl
.
OP_NO_SSLv3
|
ssl
.
OP_NO_SSLv2
,
client_options
=
ssl
.
OP_NO_SSLv3
|
ssl
.
OP_NO_SSLv2
,)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv2'
):
if
has
_tls_version
(
'
SSLv2'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_2
,
ssl
.
PROTOCOL_SSLv2
,
False
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv3'
):
if
has
_tls_version
(
'
SSLv3'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_2
,
ssl
.
PROTOCOL_SSLv3
,
False
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_2
,
ssl
.
PROTOCOL_TLS
,
False
,
client_options
=
ssl
.
OP_NO_TLSv1_2
)
...
...
@@ -3684,7 +3767,7 @@ class ThreadedTests(unittest.TestCase):
self
.
assertIs
(
s
.
version
(),
None
)
self
.
assertIs
(
s
.
_sslobj
,
None
)
s
.
connect
((
HOST
,
server
.
port
))
if
IS_OPENSSL_1_1_1
and
ssl
.
HAS_TLSv1_3
:
if
IS_OPENSSL_1_1_1
and
has_tls_version
(
'TLSv1_3'
)
:
self
.
assertEqual
(
s
.
version
(),
'TLSv1.3'
)
elif
ssl
.
OPENSSL_VERSION_INFO
>=
(
1
,
0
,
2
):
self
.
assertEqual
(
s
.
version
(),
'TLSv1.2'
)
...
...
@@ -3693,8 +3776,7 @@ class ThreadedTests(unittest.TestCase):
self
.
assertIs
(
s
.
_sslobj
,
None
)
self
.
assertIs
(
s
.
version
(),
None
)
@
unittest
.
skipUnless
(
ssl
.
HAS_TLSv1_3
,
"test requires TLSv1.3 enabled OpenSSL"
)
@
requires_tls_version
(
'TLSv1_3'
)
def
test_tls1_3
(
self
):
context
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_TLS
)
context
.
load_cert_chain
(
CERTFILE
)
...
...
@@ -3711,9 +3793,9 @@ class ThreadedTests(unittest.TestCase):
})
self
.
assertEqual
(
s
.
version
(),
'TLSv1.3'
)
@
unittest
.
skipUnless
(
hasattr
(
ssl
.
SSLContext
,
'minimum_version'
),
"required OpenSSL 1.1.0g"
)
def
test_min_max_version
(
self
):
@
requires_minimum_version
@
requires_tls_version
(
'TLSv1_2'
)
def
test_min_max_version
_tlsv1_2
(
self
):
client_context
,
server_context
,
hostname
=
testing_context
()
# client TLSv1.0 to 1.2
client_context
.
minimum_version
=
ssl
.
TLSVersion
.
TLSv1
...
...
@@ -3728,7 +3810,13 @@ class ThreadedTests(unittest.TestCase):
s
.
connect
((
HOST
,
server
.
port
))
self
.
assertEqual
(
s
.
version
(),
'TLSv1.2'
)
@
requires_minimum_version
@
requires_tls_version
(
'TLSv1_1'
)
def
test_min_max_version_tlsv1_1
(
self
):
client_context
,
server_context
,
hostname
=
testing_context
()
# client 1.0 to 1.2, server 1.0 to 1.1
client_context
.
minimum_version
=
ssl
.
TLSVersion
.
TLSv1
client_context
.
maximum_version
=
ssl
.
TLSVersion
.
TLSv1_2
server_context
.
minimum_version
=
ssl
.
TLSVersion
.
TLSv1
server_context
.
maximum_version
=
ssl
.
TLSVersion
.
TLSv1_1
...
...
@@ -3738,6 +3826,10 @@ class ThreadedTests(unittest.TestCase):
s
.
connect
((
HOST
,
server
.
port
))
self
.
assertEqual
(
s
.
version
(),
'TLSv1.1'
)
@
requires_minimum_version
@
requires_tls_version
(
'TLSv1_2'
)
def
test_min_max_version_mismatch
(
self
):
client_context
,
server_context
,
hostname
=
testing_context
()
# client 1.0, server 1.2 (mismatch)
server_context
.
minimum_version
=
ssl
.
TLSVersion
.
TLSv1_2
server_context
.
maximum_version
=
ssl
.
TLSVersion
.
TLSv1_2
...
...
@@ -3750,10 +3842,8 @@ class ThreadedTests(unittest.TestCase):
s
.
connect
((
HOST
,
server
.
port
))
self
.
assertIn
(
"alert"
,
str
(
e
.
exception
))
@
unittest
.
skipUnless
(
hasattr
(
ssl
.
SSLContext
,
'minimum_version'
),
"required OpenSSL 1.1.0g"
)
@
unittest
.
skipUnless
(
ssl
.
HAS_SSLv3
,
"requires SSLv3 support"
)
@
requires_minimum_version
@
requires_tls_version
(
'SSLv3'
)
def
test_min_max_version_sslv3
(
self
):
client_context
,
server_context
,
hostname
=
testing_context
()
server_context
.
minimum_version
=
ssl
.
TLSVersion
.
SSLv3
...
...
@@ -4272,7 +4362,7 @@ class ThreadedTests(unittest.TestCase):
'Session refers to a different SSLContext.'
)
@
unittest
.
skipUnless
(
ssl
.
HAS_TLSv1_3
,
"Test needs TLS 1.3"
)
@
unittest
.
skipUnless
(
has_tls_version
(
'TLSv1_3'
)
,
"Test needs TLS 1.3"
)
class
TestPostHandshakeAuth
(
unittest
.
TestCase
):
def
test_pha_setter
(
self
):
protocols
=
[
...
...
src/greentest/3.7/test_subprocess.py
View file @
625c88b0
...
...
@@ -11,6 +11,7 @@ import os
import
errno
import
tempfile
import
time
import
traceback
import
selectors
import
sysconfig
import
select
...
...
@@ -59,10 +60,14 @@ class BaseTestCase(unittest.TestCase):
support
.
reap_children
()
def
tearDown
(
self
):
for
inst
in
subprocess
.
_active
:
inst
.
wait
()
subprocess
.
_cleanup
()
self
.
assertFalse
(
subprocess
.
_active
,
"subprocess._active not empty"
)
if
not
mswindows
:
# subprocess._active is not used on Windows and is set to None.
for
inst
in
subprocess
.
_active
:
inst
.
wait
()
subprocess
.
_cleanup
()
self
.
assertFalse
(
subprocess
.
_active
,
"subprocess._active not empty"
)
self
.
doCleanups
()
support
.
reap_children
()
...
...
@@ -1504,6 +1509,26 @@ class RunFuncTestCase(BaseTestCase):
self
.
assertIn
(
'stderr'
,
c
.
exception
.
args
[
0
])
self
.
assertIn
(
'capture_output'
,
c
.
exception
.
args
[
0
])
# This test _might_ wind up a bit fragile on loaded build+test machines
# as it depends on the timing with wide enough margins for normal situations
# but does assert that it happened "soon enough" to believe the right thing
# happened.
@
unittest
.
skipIf
(
mswindows
,
"requires posix like 'sleep' shell command"
)
def
test_run_with_shell_timeout_and_capture_output
(
self
):
"""Output capturing after a timeout mustn't hang forever on open filehandles."""
before_secs
=
time
.
monotonic
()
try
:
subprocess
.
run
(
'sleep 3'
,
shell
=
True
,
timeout
=
0.1
,
capture_output
=
True
)
# New session unspecified.
except
subprocess
.
TimeoutExpired
as
exc
:
after_secs
=
time
.
monotonic
()
stacks
=
traceback
.
format_exc
()
# assertRaises doesn't give this.
else
:
self
.
fail
(
"TimeoutExpired not raised."
)
self
.
assertLess
(
after_secs
-
before_secs
,
1.5
,
msg
=
"TimeoutExpired was delayed! Bad traceback:
\
n
```
\
n
"
f"
{
stacks
}
```"
)
@
unittest
.
skipIf
(
mswindows
,
"POSIX specific tests"
)
class
POSIXProcessTestCase
(
BaseTestCase
):
...
...
@@ -2622,8 +2647,12 @@ class POSIXProcessTestCase(BaseTestCase):
with
support
.
check_warnings
((
''
,
ResourceWarning
)):
p
=
None
# check that p is in the active processes list
self
.
assertIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
if
mswindows
:
# subprocess._active is not used on Windows and is set to None.
self
.
assertIsNone
(
subprocess
.
_active
)
else
:
# check that p is in the active processes list
self
.
assertIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
def
test_leak_fast_process_del_killed
(
self
):
# Issue #12650: on Unix, if Popen.__del__() was called before the
...
...
@@ -2644,8 +2673,12 @@ class POSIXProcessTestCase(BaseTestCase):
p
=
None
os
.
kill
(
pid
,
signal
.
SIGKILL
)
# check that p is in the active processes list
self
.
assertIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
if
mswindows
:
# subprocess._active is not used on Windows and is set to None.
self
.
assertIsNone
(
subprocess
.
_active
)
else
:
# check that p is in the active processes list
self
.
assertIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
# let some time for the process to exit, and create a new Popen: this
# should trigger the wait() of p
...
...
@@ -2657,7 +2690,11 @@ class POSIXProcessTestCase(BaseTestCase):
pass
# p should have been wait()ed on, and removed from the _active list
self
.
assertRaises
(
OSError
,
os
.
waitpid
,
pid
,
0
)
self
.
assertNotIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
if
mswindows
:
# subprocess._active is not used on Windows and is set to None.
self
.
assertIsNone
(
subprocess
.
_active
)
else
:
self
.
assertNotIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
def
test_close_fds_after_preexec
(
self
):
fd_status
=
support
.
findfile
(
"fd_status.py"
,
subdir
=
"subprocessdata"
)
...
...
src/greentest/3.7/test_wsgiref.py
View file @
625c88b0
...
...
@@ -540,32 +540,62 @@ class TestHandler(ErrorHandler):
class
HandlerTests
(
TestCase
):
def
checkEnvironAttrs
(
self
,
handler
):
env
=
handler
.
environ
for
attr
in
[
'version'
,
'multithread'
,
'multiprocess'
,
'run_once'
,
'file_wrapper'
]:
if
attr
==
'file_wrapper'
and
handler
.
wsgi_file_wrapper
is
None
:
continue
self
.
assertEqual
(
getattr
(
handler
,
'wsgi_'
+
attr
),
env
[
'wsgi.'
+
attr
])
def
checkOSEnviron
(
self
,
handler
):
empty
=
{};
setup_testing_defaults
(
empty
)
env
=
handler
.
environ
from
os
import
environ
for
k
,
v
in
environ
.
items
():
if
k
not
in
empty
:
self
.
assertEqual
(
env
[
k
],
v
)
for
k
,
v
in
empty
.
items
():
self
.
assertIn
(
k
,
env
)
# testEnviron() can produce long error message
maxDiff
=
80
*
50
def
testEnviron
(
self
):
h
=
TestHandler
(
X
=
"Y"
)
h
.
setup_environ
()
self
.
checkEnvironAttrs
(
h
)
self
.
checkOSEnviron
(
h
)
self
.
assertEqual
(
h
.
environ
[
"X"
],
"Y"
)
os_environ
=
{
# very basic environment
'HOME'
:
'/my/home'
,
'PATH'
:
'/my/path'
,
'LANG'
:
'fr_FR.UTF-8'
,
# set some WSGI variables
'SCRIPT_NAME'
:
'test_script_name'
,
'SERVER_NAME'
:
'test_server_name'
,
}
with
support
.
swap_attr
(
TestHandler
,
'os_environ'
,
os_environ
):
# override X and HOME variables
handler
=
TestHandler
(
X
=
"Y"
,
HOME
=
"/override/home"
)
handler
.
setup_environ
()
# Check that wsgi_xxx attributes are copied to wsgi.xxx variables
# of handler.environ
for
attr
in
(
'version'
,
'multithread'
,
'multiprocess'
,
'run_once'
,
'file_wrapper'
):
self
.
assertEqual
(
getattr
(
handler
,
'wsgi_'
+
attr
),
handler
.
environ
[
'wsgi.'
+
attr
])
# Test handler.environ as a dict
expected
=
{}
setup_testing_defaults
(
expected
)
# Handler inherits os_environ variables which are not overriden
# by SimpleHandler.add_cgi_vars() (SimpleHandler.base_env)
for
key
,
value
in
os_environ
.
items
():
if
key
not
in
expected
:
expected
[
key
]
=
value
expected
.
update
({
# X doesn't exist in os_environ
"X"
:
"Y"
,
# HOME is overriden by TestHandler
'HOME'
:
"/override/home"
,
# overriden by setup_testing_defaults()
"SCRIPT_NAME"
:
""
,
"SERVER_NAME"
:
"127.0.0.1"
,
# set by BaseHandler.setup_environ()
'wsgi.input'
:
handler
.
get_stdin
(),
'wsgi.errors'
:
handler
.
get_stderr
(),
'wsgi.version'
:
(
1
,
0
),
'wsgi.run_once'
:
False
,
'wsgi.url_scheme'
:
'http'
,
'wsgi.multithread'
:
True
,
'wsgi.multiprocess'
:
True
,
'wsgi.file_wrapper'
:
util
.
FileWrapper
,
})
self
.
assertDictEqual
(
handler
.
environ
,
expected
)
def
testCGIEnviron
(
self
):
h
=
BaseCGIHandler
(
None
,
None
,
None
,{})
...
...
src/greentest/3.7/version
View file @
625c88b0
3.7.
2
3.7.
5
src/greentest/3.8/keycert.passwd.pem
View file @
625c88b0
-----BEGIN
RSA
PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,D134E931C96D9DEC
nuGFEej7vIjkYWSMz5OJeVTNntDRQi6ZM4DBm3g8T7i/0odr3WFqGMMKZcIhLYQf
rgRq7RSKtrJ1y5taVucMV+EuCjyfzDo0TsYt+ZrXv/D08eZhjRmkhoHnGVF0TqQm
nQEXM/ERT4J2RM78dnG+homMkI76qOqxgGbRqQqJo6AiVRcAZ45y8s96bru2TAB8
+pWjO/v0Je7AFVdwSU52N8OOY6uoSAygW+0UY1WVxbVGJF2XfRsNpPX+YQHYl6e+
3xM5XBVCgr6kmdAyub5qUJ38X3TpdVGoR0i+CVS9GTr2pSRib1zURAeeHnlqiUZM
4m0Gn9s72nJevU1wxED8pwOhR8fnHEmMKGD2HPhKoOCbzDhwwBZO27TNa1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utmJiQAz5lm9Z9PXaR0C8
hXB6owRY67C0YKQwXhoNf6xQun2xGBGYy5rPEEezX1S1tUH5GR/KW1Lh+FzFqHXI
ZEb5avfDqHKehGAjPON+Br7akuQ125M9LLjKuSyPaQzeeCAy356Xd7XzVwbPddbm
9S9WSPqzaPgh10chIHoNoC8HMd33dB5j9/Q6jrbU/oPlptu/GlorWblvJdcTuBGI
IVn45RFnkG8hCz0GJSNzW7+70YdESQbfJW79vssWMaiSjFE0pMyFXrFR5lBywBTx
PiGEUWtvrKG94X1TMlGUzDzDJOQNZ9dT94bonNe9pVmP5BP4/DzwwiWh6qrzWk6p
j8OE4cfCSh2WvHnhJbH7/N0v+JKjtxeIeJ16jx/K2oK5
-----END
ENCRYPTED
PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIIEWTCCAsGgAwIBAgIJAJinz4jHSjLtMA0GCSqGSIb3DQEBCwUAMF8xCzAJBgNV
BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u
...
...
@@ -66,3 +66,4 @@ jMqTFlmO7kpf/jpCSmamp3/JSEE1BJKHwQ6Ql4nzRA2N1mnvWH7Zxcv043gkHeAu
9Wc2uXpw9xF8itV4Uvcdr3dwqByvIqn7iI/gB+4l41e0u8OmH2MKOx4Nxlly5TNW
HcVKQHyOeyvnINuBAQ==
-----END CERTIFICATE-----
src/greentest/3.8/ssl_key.passwd.pem
View file @
625c88b0
-----BEGIN
RSA
PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,8064BE1494B24B13
KJrffOMbo8M0I3PzcYxRZGMpKD1yB3Ii4+bT5XoanxjIJ+4fdx6LfZ0Rsx+riyzs
tymsQu/iYY9j+4rCvN9+eetsL1X6iZpiimKsLexcid9M3fb0vxED5Sgw0dvunCUA
xhqjLIKR92MKbODHf6KrDKCpsiPbjq4gZ7P+uCGXAMHL3MXIJSC0hW9rK7Ce6oyO
CjpIcg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yHWDUhRH4cFCLiGPl4XIcnXOuTze3H
3j+EYSiS3v3DhHjp33YU2pXlJDjiYsKzAXejEh66++Y8qaQdCAad3ruWRCzW3kgk
Md0A1VGzntTnQsewvExQEMZH2LtYIsPv3KCYGeSAuLabX4tbGk79PswjnjLLEOr0
Ghf6RF6qf5/iFyJoG4vrbKT8kx6ywh0InILCdjUunuDskIBxX6tEcr9XwajoIvb2
kcmGdjam5kKLS7QOWQTl8/r/cuFes0dj34cX5Qpq+Gd7tRq/D+b0207926Cxvftv
qQ1cVn8HiLxKkZzd3tpf2xnoV1zkTL0oHrNg+qzxoxXUTUcwtIf1d/HRbYEAhi/d
bBBoFeftEHWNq+sJgS9bH+XNzo/yK4u04B5miOq8v4CSkJdzu+ZdF22d4cjiGmtQ
8BTmcn0Unzm+u5H0+QSZe54QBHJGNXXOIKMTkgnOdW27g4DbI1y7fCqJiSMbRW6L
oHmMfbdB3GWqGbsUkhY8i6h9op0MU6WOX7ea2Rxyt4t6
-----END
ENCRYPTED
PRIVATE KEY-----
src/greentest/3.8/test_httplib.py
View file @
625c88b0
...
...
@@ -1155,6 +1155,34 @@ class BasicTest(TestCase):
thread
.
join
()
self
.
assertEqual
(
result
,
b"proxied data
\
n
"
)
def
test_putrequest_override_validation
(
self
):
"""
It should be possible to override the default validation
behavior in putrequest (bpo-38216).
"""
class
UnsafeHTTPConnection
(
client
.
HTTPConnection
):
def
_validate_path
(
self
,
url
):
pass
conn
=
UnsafeHTTPConnection
(
'example.com'
)
conn
.
sock
=
FakeSocket
(
''
)
conn
.
putrequest
(
'GET'
,
'/
\
x00
'
)
def
test_putrequest_override_encoding
(
self
):
"""
It should be possible to override the default encoding
to transmit bytes in another encoding even if invalid
(bpo-36274).
"""
class
UnsafeHTTPConnection
(
client
.
HTTPConnection
):
def
_encode_request
(
self
,
str_url
):
return
str_url
.
encode
(
'utf-8'
)
conn
=
UnsafeHTTPConnection
(
'example.com'
)
conn
.
sock
=
FakeSocket
(
''
)
conn
.
putrequest
(
'GET'
,
'/☃'
)
class
ExtendedReadTest
(
TestCase
):
"""
Test peek(), read1(), readline()
...
...
@@ -1279,6 +1307,7 @@ class ExtendedReadTest(TestCase):
p
=
self
.
resp
.
peek
(
0
)
self
.
assertLessEqual
(
0
,
len
(
p
))
class
ExtendedReadTestChunked
(
ExtendedReadTest
):
"""
Test peek(), read1(), readline() in chunked mode
...
...
src/greentest/3.8/test_socket.py
View file @
625c88b0
...
...
@@ -1897,7 +1897,9 @@ class BasicCANTest(unittest.TestCase):
def
testBindAny
(
self
):
with
socket
.
socket
(
socket
.
PF_CAN
,
socket
.
SOCK_RAW
,
socket
.
CAN_RAW
)
as
s
:
s
.
bind
((
''
,
))
address
=
(
''
,
)
s
.
bind
(
address
)
self
.
assertEqual
(
s
.
getsockname
(),
address
)
def
testTooLongInterfaceName
(
self
):
# most systems limit IFNAMSIZ to 16, take 1024 to be sure
...
...
src/greentest/3.8/test_ssl.py
View file @
625c88b0
...
...
@@ -19,6 +19,7 @@ import asyncore
import
weakref
import
platform
import
sysconfig
import
functools
try
:
import
ctypes
except
ImportError
:
...
...
@@ -143,6 +144,87 @@ OP_CIPHER_SERVER_PREFERENCE = getattr(ssl, "OP_CIPHER_SERVER_PREFERENCE", 0)
OP_ENABLE_MIDDLEBOX_COMPAT
=
getattr
(
ssl
,
"OP_ENABLE_MIDDLEBOX_COMPAT"
,
0
)
def
has_tls_protocol
(
protocol
):
"""Check if a TLS protocol is available and enabled
:param protocol: enum ssl._SSLMethod member or name
:return: bool
"""
if
isinstance
(
protocol
,
str
):
assert
protocol
.
startswith
(
'PROTOCOL_'
)
protocol
=
getattr
(
ssl
,
protocol
,
None
)
if
protocol
is
None
:
return
False
if
protocol
in
{
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLS_SERVER
,
ssl
.
PROTOCOL_TLS_CLIENT
}:
# auto-negotiate protocols are always available
return
True
name
=
protocol
.
name
return
has_tls_version
(
name
[
len
(
'PROTOCOL_'
):])
@
functools
.
lru_cache
def
has_tls_version
(
version
):
"""Check if a TLS/SSL version is enabled
:param version: TLS version name or ssl.TLSVersion member
:return: bool
"""
if
version
==
"SSLv2"
:
# never supported and not even in TLSVersion enum
return
False
if
isinstance
(
version
,
str
):
version
=
ssl
.
TLSVersion
.
__members__
[
version
]
# check compile time flags like ssl.HAS_TLSv1_2
if
not
getattr
(
ssl
,
f'HAS_
{
version
.
name
}
'
):
return
False
# check runtime and dynamic crypto policy settings. A TLS version may
# be compiled in but disabled by a policy or config option.
ctx
=
ssl
.
SSLContext
()
if
(
hasattr
(
ctx
,
'minimum_version'
)
and
ctx
.
minimum_version
!=
ssl
.
TLSVersion
.
MINIMUM_SUPPORTED
and
version
<
ctx
.
minimum_version
):
return
False
if
(
hasattr
(
ctx
,
'maximum_version'
)
and
ctx
.
maximum_version
!=
ssl
.
TLSVersion
.
MAXIMUM_SUPPORTED
and
version
>
ctx
.
maximum_version
):
return
False
return
True
def
requires_tls_version
(
version
):
"""Decorator to skip tests when a required TLS version is not available
:param version: TLS version name or ssl.TLSVersion member
:return:
"""
def
decorator
(
func
):
@
functools
.
wraps
(
func
)
def
wrapper
(
*
args
,
**
kw
):
if
not
has_tls_version
(
version
):
raise
unittest
.
SkipTest
(
f"
{
version
}
is not available."
)
else
:
return
func
(
*
args
,
**
kw
)
return
wrapper
return
decorator
requires_minimum_version
=
unittest
.
skipUnless
(
hasattr
(
ssl
.
SSLContext
,
'minimum_version'
),
"required OpenSSL >= 1.1.0g"
)
def
handle_error
(
prefix
):
exc_format
=
' '
.
join
(
traceback
.
format_exception
(
*
sys
.
exc_info
()))
if
support
.
verbose
:
...
...
@@ -832,8 +914,8 @@ class BasicSocketTests(unittest.TestCase):
cert
,
enc
,
trust
=
element
self
.
assertIsInstance
(
cert
,
bytes
)
self
.
assertIn
(
enc
,
{
"x509_asn"
,
"pkcs_7_asn"
})
self
.
assertIsInstance
(
trust
,
(
set
,
bool
))
if
isinstance
(
trust
,
set
):
self
.
assertIsInstance
(
trust
,
(
frozenset
,
set
,
bool
))
if
isinstance
(
trust
,
(
frozenset
,
set
)
):
trust_oids
.
update
(
trust
)
serverAuth
=
"1.3.6.1.5.5.7.3.1"
...
...
@@ -1104,19 +1186,23 @@ class ContextTests(unittest.TestCase):
with
self
.
assertRaises
(
AttributeError
):
ctx
.
hostname_checks_common_name
=
True
@
unittest
.
skipUnless
(
hasattr
(
ssl
.
SSLContext
,
'minimum_version'
),
"required OpenSSL 1.1.0g
"
)
@
requires_minimum_version
@
unittest
.
skipIf
(
IS_LIBRESSL
,
"see bpo-34001
"
)
def
test_min_max_version
(
self
):
ctx
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_TLS_SERVER
)
# OpenSSL default is MINIMUM_SUPPORTED, however some vendors like
# Fedora override the setting to TLS 1.0.
minimum_range
=
{
# stock OpenSSL
ssl
.
TLSVersion
.
MINIMUM_SUPPORTED
,
# Fedora 29 uses TLS 1.0 by default
ssl
.
TLSVersion
.
TLSv1
,
# RHEL 8 uses TLS 1.2 by default
ssl
.
TLSVersion
.
TLSv1_2
}
self
.
assertIn
(
ctx
.
minimum_version
,
{
ssl
.
TLSVersion
.
MINIMUM_SUPPORTED
,
# Fedora 29 uses TLS 1.0 by default
ssl
.
TLSVersion
.
TLSv1
,
# RHEL 8 uses TLS 1.2 by default
ssl
.
TLSVersion
.
TLSv1_2
}
ctx
.
minimum_version
,
minimum_range
)
self
.
assertEqual
(
ctx
.
maximum_version
,
ssl
.
TLSVersion
.
MAXIMUM_SUPPORTED
...
...
@@ -1162,8 +1248,8 @@ class ContextTests(unittest.TestCase):
ctx
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_TLSv1_1
)
self
.
assert
Equal
(
ctx
.
minimum_version
,
ssl
.
TLSVersion
.
MINIMUM_SUPPORTED
self
.
assert
In
(
ctx
.
minimum_version
,
minimum_range
)
self
.
assertEqual
(
ctx
.
maximum_version
,
ssl
.
TLSVersion
.
MAXIMUM_SUPPORTED
...
...
@@ -2716,6 +2802,8 @@ class ThreadedTests(unittest.TestCase):
for
protocol
in
PROTOCOLS
:
if
protocol
in
{
ssl
.
PROTOCOL_TLS_CLIENT
,
ssl
.
PROTOCOL_TLS_SERVER
}:
continue
if
not
has_tls_protocol
(
protocol
):
continue
with
self
.
subTest
(
protocol
=
ssl
.
_PROTOCOL_NAMES
[
protocol
]):
context
=
ssl
.
SSLContext
(
protocol
)
context
.
load_cert_chain
(
CERTFILE
)
...
...
@@ -3007,7 +3095,7 @@ class ThreadedTests(unittest.TestCase):
else
:
self
.
fail
(
"Use of invalid cert should have failed!"
)
@
unittest
.
skipUnless
(
ssl
.
HAS_TLSv1_3
,
"Test needs TLS 1.3"
)
@
requires_tls_version
(
'TLSv1_3'
)
def
test_wrong_cert_tls13
(
self
):
client_context
,
server_context
,
hostname
=
testing_context
()
# load client cert that is not signed by trusted CA
...
...
@@ -3102,8 +3190,7 @@ class ThreadedTests(unittest.TestCase):
self
.
assertIn
(
msg
,
repr
(
e
))
self
.
assertIn
(
'certificate verify failed'
,
repr
(
e
))
@
unittest
.
skipUnless
(
hasattr
(
ssl
,
'PROTOCOL_SSLv2'
),
"OpenSSL is compiled without SSLv2 support"
)
@
requires_tls_version
(
'SSLv2'
)
def
test_protocol_sslv2
(
self
):
"""Connecting to an SSLv2 server with various client options"""
if
support
.
verbose
:
...
...
@@ -3112,7 +3199,7 @@ class ThreadedTests(unittest.TestCase):
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv2
,
ssl
.
PROTOCOL_SSLv2
,
True
,
ssl
.
CERT_OPTIONAL
)
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv2
,
ssl
.
PROTOCOL_SSLv2
,
True
,
ssl
.
CERT_REQUIRED
)
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv2
,
ssl
.
PROTOCOL_TLS
,
False
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv3'
):
if
has
_tls_version
(
'
SSLv3'
):
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv2
,
ssl
.
PROTOCOL_SSLv3
,
False
)
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv2
,
ssl
.
PROTOCOL_TLSv1
,
False
)
# SSLv23 client with specific SSL options
...
...
@@ -3129,7 +3216,7 @@ class ThreadedTests(unittest.TestCase):
"""Connecting to an SSLv23 server with various client options"""
if
support
.
verbose
:
sys
.
stdout
.
write
(
"
\
n
"
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv2'
):
if
has
_tls_version
(
'
SSLv2'
):
try
:
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_SSLv2
,
True
)
except
OSError
as
x
:
...
...
@@ -3138,34 +3225,36 @@ class ThreadedTests(unittest.TestCase):
sys
.
stdout
.
write
(
" SSL2 client to SSL23 server test unexpectedly failed:
\
n
%s
\
n
"
%
str
(
x
))
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv3'
):
if
has
_tls_version
(
'
SSLv3'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_SSLv3
,
False
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLS
,
True
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLSv1
,
'TLSv1'
)
if
has_tls_version
(
'TLSv1'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLSv1
,
'TLSv1'
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv3'
):
if
has
_tls_version
(
'
SSLv3'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_SSLv3
,
False
,
ssl
.
CERT_OPTIONAL
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLS
,
True
,
ssl
.
CERT_OPTIONAL
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLSv1
,
'TLSv1'
,
ssl
.
CERT_OPTIONAL
)
if
has_tls_version
(
'TLSv1'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLSv1
,
'TLSv1'
,
ssl
.
CERT_OPTIONAL
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv3'
):
if
has
_tls_version
(
'
SSLv3'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_SSLv3
,
False
,
ssl
.
CERT_REQUIRED
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLS
,
True
,
ssl
.
CERT_REQUIRED
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLSv1
,
'TLSv1'
,
ssl
.
CERT_REQUIRED
)
if
has_tls_version
(
'TLSv1'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLSv1
,
'TLSv1'
,
ssl
.
CERT_REQUIRED
)
# Server with specific SSL options
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv3'
):
if
has
_tls_version
(
'
SSLv3'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_SSLv3
,
False
,
server_options
=
ssl
.
OP_NO_SSLv3
)
# Will choose TLSv1
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLS
,
True
,
server_options
=
ssl
.
OP_NO_SSLv2
|
ssl
.
OP_NO_SSLv3
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLSv1
,
False
,
server_options
=
ssl
.
OP_NO_TLSv1
)
if
has_tls_version
(
'TLSv1'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLSv1
,
False
,
server_options
=
ssl
.
OP_NO_TLSv1
)
@
unittest
.
skipUnless
(
hasattr
(
ssl
,
'PROTOCOL_SSLv3'
),
"OpenSSL is compiled without SSLv3 support"
)
@
requires_tls_version
(
'SSLv3'
)
def
test_protocol_sslv3
(
self
):
"""Connecting to an SSLv3 server with various client options"""
if
support
.
verbose
:
...
...
@@ -3173,7 +3262,7 @@ class ThreadedTests(unittest.TestCase):
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv3
,
ssl
.
PROTOCOL_SSLv3
,
'SSLv3'
)
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv3
,
ssl
.
PROTOCOL_SSLv3
,
'SSLv3'
,
ssl
.
CERT_OPTIONAL
)
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv3
,
ssl
.
PROTOCOL_SSLv3
,
'SSLv3'
,
ssl
.
CERT_REQUIRED
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv2'
):
if
has
_tls_version
(
'
SSLv2'
):
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv3
,
ssl
.
PROTOCOL_SSLv2
,
False
)
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv3
,
ssl
.
PROTOCOL_TLS
,
False
,
client_options
=
ssl
.
OP_NO_SSLv3
)
...
...
@@ -3183,6 +3272,7 @@ class ThreadedTests(unittest.TestCase):
try_protocol_combo
(
ssl
.
PROTOCOL_SSLv3
,
ssl
.
PROTOCOL_TLS
,
False
,
client_options
=
ssl
.
OP_NO_SSLv2
)
@
requires_tls_version
(
'TLSv1'
)
def
test_protocol_tlsv1
(
self
):
"""Connecting to a TLSv1 server with various client options"""
if
support
.
verbose
:
...
...
@@ -3190,34 +3280,32 @@ class ThreadedTests(unittest.TestCase):
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1
,
ssl
.
PROTOCOL_TLSv1
,
'TLSv1'
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1
,
ssl
.
PROTOCOL_TLSv1
,
'TLSv1'
,
ssl
.
CERT_OPTIONAL
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1
,
ssl
.
PROTOCOL_TLSv1
,
'TLSv1'
,
ssl
.
CERT_REQUIRED
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv2'
):
if
has
_tls_version
(
'
SSLv2'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1
,
ssl
.
PROTOCOL_SSLv2
,
False
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv3'
):
if
has
_tls_version
(
'
SSLv3'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1
,
ssl
.
PROTOCOL_SSLv3
,
False
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1
,
ssl
.
PROTOCOL_TLS
,
False
,
client_options
=
ssl
.
OP_NO_TLSv1
)
@
unittest
.
skipUnless
(
hasattr
(
ssl
,
"PROTOCOL_TLSv1_1"
),
"TLS version 1.1 not supported."
)
@
requires_tls_version
(
'TLSv1_1'
)
def
test_protocol_tlsv1_1
(
self
):
"""Connecting to a TLSv1.1 server with various client options.
Testing against older TLS versions."""
if
support
.
verbose
:
sys
.
stdout
.
write
(
"
\
n
"
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_1
,
ssl
.
PROTOCOL_TLSv1_1
,
'TLSv1.1'
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv2'
):
if
has
_tls_version
(
'
SSLv2'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_1
,
ssl
.
PROTOCOL_SSLv2
,
False
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv3'
):
if
has
_tls_version
(
'
SSLv3'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_1
,
ssl
.
PROTOCOL_SSLv3
,
False
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_1
,
ssl
.
PROTOCOL_TLS
,
False
,
client_options
=
ssl
.
OP_NO_TLSv1_1
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLS
,
ssl
.
PROTOCOL_TLSv1_1
,
'TLSv1.1'
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_1
,
ssl
.
PROTOCOL_TLSv1
,
False
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1
,
ssl
.
PROTOCOL_TLSv1_1
,
False
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_1
,
ssl
.
PROTOCOL_TLSv1
_2
,
False
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1
_2
,
ssl
.
PROTOCOL_TLSv1_1
,
False
)
@
unittest
.
skipUnless
(
hasattr
(
ssl
,
"PROTOCOL_TLSv1_2"
),
"TLS version 1.2 not supported."
)
@
requires_tls_version
(
'TLSv1_2'
)
def
test_protocol_tlsv1_2
(
self
):
"""Connecting to a TLSv1.2 server with various client options.
Testing against older TLS versions."""
...
...
@@ -3226,9 +3314,9 @@ class ThreadedTests(unittest.TestCase):
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_2
,
ssl
.
PROTOCOL_TLSv1_2
,
'TLSv1.2'
,
server_options
=
ssl
.
OP_NO_SSLv3
|
ssl
.
OP_NO_SSLv2
,
client_options
=
ssl
.
OP_NO_SSLv3
|
ssl
.
OP_NO_SSLv2
,)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv2'
):
if
has
_tls_version
(
'
SSLv2'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_2
,
ssl
.
PROTOCOL_SSLv2
,
False
)
if
has
attr
(
ssl
,
'PROTOCOL_
SSLv3'
):
if
has
_tls_version
(
'
SSLv3'
):
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_2
,
ssl
.
PROTOCOL_SSLv3
,
False
)
try_protocol_combo
(
ssl
.
PROTOCOL_TLSv1_2
,
ssl
.
PROTOCOL_TLS
,
False
,
client_options
=
ssl
.
OP_NO_TLSv1_2
)
...
...
@@ -3671,7 +3759,7 @@ class ThreadedTests(unittest.TestCase):
self
.
assertIs
(
s
.
version
(),
None
)
self
.
assertIs
(
s
.
_sslobj
,
None
)
s
.
connect
((
HOST
,
server
.
port
))
if
IS_OPENSSL_1_1_1
and
ssl
.
HAS_TLSv1_3
:
if
IS_OPENSSL_1_1_1
and
has_tls_version
(
'TLSv1_3'
)
:
self
.
assertEqual
(
s
.
version
(),
'TLSv1.3'
)
elif
ssl
.
OPENSSL_VERSION_INFO
>=
(
1
,
0
,
2
):
self
.
assertEqual
(
s
.
version
(),
'TLSv1.2'
)
...
...
@@ -3680,8 +3768,7 @@ class ThreadedTests(unittest.TestCase):
self
.
assertIs
(
s
.
_sslobj
,
None
)
self
.
assertIs
(
s
.
version
(),
None
)
@
unittest
.
skipUnless
(
ssl
.
HAS_TLSv1_3
,
"test requires TLSv1.3 enabled OpenSSL"
)
@
requires_tls_version
(
'TLSv1_3'
)
def
test_tls1_3
(
self
):
context
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_TLS
)
context
.
load_cert_chain
(
CERTFILE
)
...
...
@@ -3698,9 +3785,9 @@ class ThreadedTests(unittest.TestCase):
})
self
.
assertEqual
(
s
.
version
(),
'TLSv1.3'
)
@
unittest
.
skipUnless
(
hasattr
(
ssl
.
SSLContext
,
'minimum_version'
),
"required OpenSSL 1.1.0g"
)
def
test_min_max_version
(
self
):
@
requires_minimum_version
@
requires_tls_version
(
'TLSv1_2'
)
def
test_min_max_version
_tlsv1_2
(
self
):
client_context
,
server_context
,
hostname
=
testing_context
()
# client TLSv1.0 to 1.2
client_context
.
minimum_version
=
ssl
.
TLSVersion
.
TLSv1
...
...
@@ -3715,7 +3802,13 @@ class ThreadedTests(unittest.TestCase):
s
.
connect
((
HOST
,
server
.
port
))
self
.
assertEqual
(
s
.
version
(),
'TLSv1.2'
)
@
requires_minimum_version
@
requires_tls_version
(
'TLSv1_1'
)
def
test_min_max_version_tlsv1_1
(
self
):
client_context
,
server_context
,
hostname
=
testing_context
()
# client 1.0 to 1.2, server 1.0 to 1.1
client_context
.
minimum_version
=
ssl
.
TLSVersion
.
TLSv1
client_context
.
maximum_version
=
ssl
.
TLSVersion
.
TLSv1_2
server_context
.
minimum_version
=
ssl
.
TLSVersion
.
TLSv1
server_context
.
maximum_version
=
ssl
.
TLSVersion
.
TLSv1_1
...
...
@@ -3725,11 +3818,15 @@ class ThreadedTests(unittest.TestCase):
s
.
connect
((
HOST
,
server
.
port
))
self
.
assertEqual
(
s
.
version
(),
'TLSv1.1'
)
@
requires_minimum_version
@
requires_tls_version
(
'TLSv1_2'
)
def
test_min_max_version_mismatch
(
self
):
client_context
,
server_context
,
hostname
=
testing_context
()
# client 1.0, server 1.2 (mismatch)
server_context
.
minimum_version
=
ssl
.
TLSVersion
.
TLSv1_2
server_context
.
maximum_version
=
ssl
.
TLSVersion
.
TLSv1_2
server_context
.
minimum_version
=
ssl
.
TLSVersion
.
TLSv1_2
client_context
.
maximum_version
=
ssl
.
TLSVersion
.
TLSv1
client_context
.
m
ax
imum_version
=
ssl
.
TLSVersion
.
TLSv1
client_context
.
m
in
imum_version
=
ssl
.
TLSVersion
.
TLSv1
with
ThreadedEchoServer
(
context
=
server_context
)
as
server
:
with
client_context
.
wrap_socket
(
socket
.
socket
(),
server_hostname
=
hostname
)
as
s
:
...
...
@@ -3737,10 +3834,8 @@ class ThreadedTests(unittest.TestCase):
s
.
connect
((
HOST
,
server
.
port
))
self
.
assertIn
(
"alert"
,
str
(
e
.
exception
))
@
unittest
.
skipUnless
(
hasattr
(
ssl
.
SSLContext
,
'minimum_version'
),
"required OpenSSL 1.1.0g"
)
@
unittest
.
skipUnless
(
ssl
.
HAS_SSLv3
,
"requires SSLv3 support"
)
@
requires_minimum_version
@
requires_tls_version
(
'SSLv3'
)
def
test_min_max_version_sslv3
(
self
):
client_context
,
server_context
,
hostname
=
testing_context
()
server_context
.
minimum_version
=
ssl
.
TLSVersion
.
SSLv3
...
...
@@ -4263,7 +4358,7 @@ class ThreadedTests(unittest.TestCase):
'Session refers to a different SSLContext.'
)
@
unittest
.
skipUnless
(
ssl
.
HAS_TLSv1_3
,
"Test needs TLS 1.3"
)
@
unittest
.
skipUnless
(
has_tls_version
(
'TLSv1_3'
)
,
"Test needs TLS 1.3"
)
class
TestPostHandshakeAuth
(
unittest
.
TestCase
):
def
test_pha_setter
(
self
):
protocols
=
[
...
...
@@ -4575,9 +4670,7 @@ class TestSSLDebug(unittest.TestCase):
msg
=
[]
def
msg_cb
(
conn
,
direction
,
version
,
content_type
,
msg_type
,
data
):
# gevent: disabled . We want this test to run, but the socket is passed from
# the low-level C code, and it's not the gevent wrapper.
# self.assertIsInstance(conn, ssl.SSLSocket)
self
.
assertIsInstance
(
conn
,
ssl
.
SSLSocket
)
self
.
assertIsInstance
(
data
,
bytes
)
self
.
assertIn
(
direction
,
{
'read'
,
'write'
})
msg
.
append
((
direction
,
version
,
content_type
,
msg_type
))
...
...
src/greentest/3.8/test_subprocess.py
View file @
625c88b0
...
...
@@ -10,6 +10,7 @@ import os
import
errno
import
tempfile
import
time
import
traceback
import
selectors
import
sysconfig
import
select
...
...
@@ -52,10 +53,14 @@ class BaseTestCase(unittest.TestCase):
support
.
reap_children
()
def
tearDown
(
self
):
for
inst
in
subprocess
.
_active
:
inst
.
wait
()
subprocess
.
_cleanup
()
self
.
assertFalse
(
subprocess
.
_active
,
"subprocess._active not empty"
)
if
not
mswindows
:
# subprocess._active is not used on Windows and is set to None.
for
inst
in
subprocess
.
_active
:
inst
.
wait
()
subprocess
.
_cleanup
()
self
.
assertFalse
(
subprocess
.
_active
,
"subprocess._active not empty"
)
self
.
doCleanups
()
support
.
reap_children
()
...
...
@@ -1553,6 +1558,26 @@ class RunFuncTestCase(BaseTestCase):
self
.
assertIn
(
'stderr'
,
c
.
exception
.
args
[
0
])
self
.
assertIn
(
'capture_output'
,
c
.
exception
.
args
[
0
])
# This test _might_ wind up a bit fragile on loaded build+test machines
# as it depends on the timing with wide enough margins for normal situations
# but does assert that it happened "soon enough" to believe the right thing
# happened.
@
unittest
.
skipIf
(
mswindows
,
"requires posix like 'sleep' shell command"
)
def
test_run_with_shell_timeout_and_capture_output
(
self
):
"""Output capturing after a timeout mustn't hang forever on open filehandles."""
before_secs
=
time
.
monotonic
()
try
:
subprocess
.
run
(
'sleep 3'
,
shell
=
True
,
timeout
=
0.1
,
capture_output
=
True
)
# New session unspecified.
except
subprocess
.
TimeoutExpired
as
exc
:
after_secs
=
time
.
monotonic
()
stacks
=
traceback
.
format_exc
()
# assertRaises doesn't give this.
else
:
self
.
fail
(
"TimeoutExpired not raised."
)
self
.
assertLess
(
after_secs
-
before_secs
,
1.5
,
msg
=
"TimeoutExpired was delayed! Bad traceback:
\
n
```
\
n
"
f"
{
stacks
}
```"
)
@
unittest
.
skipIf
(
mswindows
,
"POSIX specific tests"
)
class
POSIXProcessTestCase
(
BaseTestCase
):
...
...
@@ -2672,8 +2697,12 @@ class POSIXProcessTestCase(BaseTestCase):
with
support
.
check_warnings
((
''
,
ResourceWarning
)):
p
=
None
# check that p is in the active processes list
self
.
assertIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
if
mswindows
:
# subprocess._active is not used on Windows and is set to None.
self
.
assertIsNone
(
subprocess
.
_active
)
else
:
# check that p is in the active processes list
self
.
assertIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
def
test_leak_fast_process_del_killed
(
self
):
# Issue #12650: on Unix, if Popen.__del__() was called before the
...
...
@@ -2694,8 +2723,12 @@ class POSIXProcessTestCase(BaseTestCase):
p
=
None
os
.
kill
(
pid
,
signal
.
SIGKILL
)
# check that p is in the active processes list
self
.
assertIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
if
mswindows
:
# subprocess._active is not used on Windows and is set to None.
self
.
assertIsNone
(
subprocess
.
_active
)
else
:
# check that p is in the active processes list
self
.
assertIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
# let some time for the process to exit, and create a new Popen: this
# should trigger the wait() of p
...
...
@@ -2707,7 +2740,11 @@ class POSIXProcessTestCase(BaseTestCase):
pass
# p should have been wait()ed on, and removed from the _active list
self
.
assertRaises
(
OSError
,
os
.
waitpid
,
pid
,
0
)
self
.
assertNotIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
if
mswindows
:
# subprocess._active is not used on Windows and is set to None.
self
.
assertIsNone
(
subprocess
.
_active
)
else
:
self
.
assertNotIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
def
test_close_fds_after_preexec
(
self
):
fd_status
=
support
.
findfile
(
"fd_status.py"
,
subdir
=
"subprocessdata"
)
...
...
src/greentest/3.8/test_threading.py
View file @
625c88b0
...
...
@@ -18,7 +18,6 @@ import os
import
subprocess
import
signal
# from test import lock_tests
from
gevent.tests
import
lock_tests
# gevent: use our local copy
from
test
import
support
...
...
src/greentest/3.8/test_wsgiref.py
View file @
625c88b0
...
...
@@ -293,10 +293,9 @@ class IntegrationTests(TestCase):
received
=
len
(
response
.
read
())
http
.
close
()
background
=
threading
.
Thread
(
target
=
run_client
,
name
=
'gevent'
)
background
=
threading
.
Thread
(
target
=
run_client
)
background
.
start
()
server
.
handle_request
()
print
(
dir
(
background
))
background
.
join
()
self
.
assertEqual
(
received
,
support
.
SOCK_MAX_SIZE
-
100
)
...
...
@@ -587,10 +586,10 @@ class HandlerTests(TestCase):
expected
.
update
({
# X doesn't exist in os_environ
"X"
:
"Y"
,
# HOME is overriden by TestHandler
# HOME is overrid
d
en by TestHandler
'HOME'
:
"/override/home"
,
# overriden by setup_testing_defaults()
# overrid
d
en by setup_testing_defaults()
"SCRIPT_NAME"
:
""
,
"SERVER_NAME"
:
"127.0.0.1"
,
...
...
src/greentest/3.8/version
View file @
625c88b0
3.8.0
b4
3.8.0
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment