diff --git a/.ci/azure-pipelines.yml b/.ci/azure-pipelines.yml index 397c52f3..5f687be4 100644 --- a/.ci/azure-pipelines.yml +++ b/.ci/azure-pipelines.yml @@ -66,6 +66,12 @@ jobs: DISTRO: debian VER: 2.10.0 + Mito39Debian_27: + python.version: '3.9' + MODE: mitogen + DISTRO: debian + VER: 2.10.0 + #Py26CentOS7: #python.version: '2.7' #MODE: mitogen @@ -117,3 +123,8 @@ jobs: python.version: '3.5' MODE: ansible VER: 2.10.0 + + Ansible_210_39: + python.version: '3.9' + MODE: ansible + VER: 2.10.0 diff --git a/.travis.yml b/.travis.yml index aafb4413..7ee98677 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ sudo: required -dist: trusty +dist: xenial # Ubuntu 16.04 LTS notifications: email: false @@ -17,7 +17,6 @@ cache: - /home/travis/virtualenv install: -- grep -Erl git-lfs\|couchdb /etc/apt | sudo xargs rm -v - pip install -U pip==20.2.1 - .ci/${MODE}_install.py @@ -53,6 +52,9 @@ matrix: - python: "3.6" env: MODE=ansible VER=2.10.0 # 2.10 -> {debian, centos6, centos7} + - python: "3.9" + env: MODE=ansible VER=2.10.0 + # 2.10 -> {debian, centos6, centos7} - python: "2.7" env: MODE=ansible VER=2.10.0 # 2.10 -> {debian, centos6, centos7} @@ -73,6 +75,8 @@ matrix: #env: MODE=mitogen DISTRO=centos6 - python: "3.6" env: MODE=mitogen DISTROS=centos7 VER=2.10.0 + - python: "3.9" + env: MODE=mitogen DISTROS=centos7 VER=2.10.0 # 2.6 -> 2.7 # - python: "2.6" # env: MODE=mitogen DISTROS=centos7 VER=2.10.0 diff --git a/docs/changelog.rst b/docs/changelog.rst index 4cb8d6fe..99c30798 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -40,6 +40,8 @@ v0.2.10 (unreleased) timeout, when using recent OpenSSH client versions. * :gh:issue:`758` fix initilialisation of callback plugins in test suite, to address a `KeyError` in :method:`ansible.plugins.callback.CallbackBase.v2_runner_on_start` +* :gh:issue:`775` Test with Python 3.9 +* :gh:issue:`775` Add msvcrt to the default module deny list v0.2.9 (2019-11-02) diff --git a/mitogen/core.py b/mitogen/core.py index 4dd44925..9a00ce65 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -1269,6 +1269,13 @@ class Importer(object): # a negative round-trip. 'builtins', '__builtin__', + + # On some Python releases (e.g. 3.8, 3.9) the subprocess module tries + # to import of this Windows-only builtin module. + 'msvcrt', + + # Python 2.x module that was renamed to _thread in 3.x. + # This entry avoids a roundtrip on 2.x -> 3.x. 'thread', # org.python.core imported by copy, pickle, xml.sax; breaks Jython, but diff --git a/tests/ansible/requirements.txt b/tests/ansible/requirements.txt index c0386cd8..2c3c87c8 100644 --- a/tests/ansible/requirements.txt +++ b/tests/ansible/requirements.txt @@ -1,4 +1,4 @@ paramiko==2.3.2 # Last 2.6-compat version. hdrhistogram==0.6.1 PyYAML==3.11; python_version < '2.7' -PyYAML==3.13; python_version >= '2.7' +PyYAML==5.3.1; python_version >= '2.7' # Latest release (Jan 2021) diff --git a/tests/testlib.py b/tests/testlib.py index ace8f0a2..ee76a26d 100644 --- a/tests/testlib.py +++ b/tests/testlib.py @@ -103,6 +103,18 @@ if hasattr(subprocess.Popen, 'terminate'): Popen__terminate = subprocess.Popen.terminate +def threading__thread_is_alive(thread): + """Return whether the thread is alive (Python version compatibility shim). + + On Python >= 3.8 thread.isAlive() is deprecated (removed in Python 3.9). + On Python <= 2.5 thread.is_alive() isn't present (added in Python 2.6). + """ + try: + return thread.is_alive() + except AttributeError: + return thread.isAlive() + + def wait_for_port( host, port, @@ -334,7 +346,9 @@ class TestCase(unittest2.TestCase): for thread in threading.enumerate(): name = thread.getName() # Python 2.4: enumerate() may return stopped threads. - assert (not thread.isAlive()) or name in self.ALLOWED_THREADS, \ + assert \ + not threading__thread_is_alive(thread) \ + or name in self.ALLOWED_THREADS, \ 'Found thread %r still running after tests.' % (name,) counts[name] = counts.get(name, 0) + 1 diff --git a/tests/utils_test.py b/tests/utils_test.py index a70b23dc..b5204a3c 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -31,14 +31,14 @@ class RunWithRouterTest(testlib.TestCase): def test_run_with_broker(self): router = mitogen.utils.run_with_router(func0) self.assertIsInstance(router, mitogen.master.Router) - self.assertFalse(router.broker._thread.isAlive()) + self.assertFalse(testlib.threading__thread_is_alive(router.broker._thread)) class WithRouterTest(testlib.TestCase): def test_with_broker(self): router = func() self.assertIsInstance(router, mitogen.master.Router) - self.assertFalse(router.broker._thread.isAlive()) + self.assertFalse(testlib.threading__thread_is_alive(router.broker._thread)) class Dict(dict): pass