diff --git a/cpython/remove_modules.txt b/cpython/remove_modules.txt index 284497657..003b97d09 100644 --- a/cpython/remove_modules.txt +++ b/cpython/remove_modules.txt @@ -5,7 +5,6 @@ dbm ensurepip idlelib lib2to3 -multiprocessing tkinter turtle.py turtledemo diff --git a/packages/attrs/meta.yaml b/packages/attrs/meta.yaml index 9ade005bc..2a8905da3 100644 --- a/packages/attrs/meta.yaml +++ b/packages/attrs/meta.yaml @@ -2,8 +2,6 @@ package: name: attrs version: 20.1.0 source: - patches: - - patches/use-dummy-threading.patch sha256: 0ef97238856430dcf9228e07f316aefc17e8939fc8507e18c6501b761ef1a42a url: https://files.pythonhosted.org/packages/c4/d4/c2b5232ecfc0783c697a81c13efc53a4fe285d4e2c00e0d8aed90495fade/attrs-20.1.0.tar.gz test: diff --git a/packages/attrs/patches/use-dummy-threading.patch b/packages/attrs/patches/use-dummy-threading.patch deleted file mode 100644 index 0a692d9b7..000000000 --- a/packages/attrs/patches/use-dummy-threading.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/src/attr/_make.py b/src/attr/_make.py -index fc44611..f60016e 100644 ---- a/src/attr/_make.py -+++ b/src/attr/_make.py -@@ -3,7 +3,10 @@ from __future__ import absolute_import, division, print_function - import copy - import linecache - import sys --import threading -+try: -+ import threading -+except ImportError: -+ import dummy_threading as threading - import uuid - import warnings - diff --git a/packages/pyparsing/meta.yaml b/packages/pyparsing/meta.yaml index c740b6af9..64e31ad75 100644 --- a/packages/pyparsing/meta.yaml +++ b/packages/pyparsing/meta.yaml @@ -2,8 +2,6 @@ package: name: pyparsing version: 2.4.7 source: - patches: - - patches/dummy_threading.patch sha256: c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1 url: https://files.pythonhosted.org/packages/c1/47/dfc9c342c9842bbe0036c7f763d2d6686bcf5eb1808ba3e170afdb282210/pyparsing-2.4.7.tar.gz test: diff --git a/packages/pyparsing/patches/dummy_threading.patch b/packages/pyparsing/patches/dummy_threading.patch deleted file mode 100644 index 05d173459..000000000 --- a/packages/pyparsing/patches/dummy_threading.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- pyparsing-2.2.0/pyparsing.py -+++ pyparsing-2.2.0/pyparsing.py -@@ -124,7 +124,10 @@ - try: - from _thread import RLock - except ImportError: -- from threading import RLock -+ try: -+ from threading import RLock -+ except ImportError: -+ from dummy_threading import RLock - - try: - # Python 3 diff --git a/packages/python-sat/meta.yaml b/packages/python-sat/meta.yaml index f6d9c3bf9..611b9ddca 100644 --- a/packages/python-sat/meta.yaml +++ b/packages/python-sat/meta.yaml @@ -7,7 +7,6 @@ source: url: https://github.com/pysathq/pysat/releases/download/0.1.6.dev6/python-sat-0.1.6.dev6.tar.gz patches: - - patches/dummy_threading.patch - patches/force_malloc.patch - patches/proper_build.patch diff --git a/packages/python-sat/patches/dummy_threading.patch b/packages/python-sat/patches/dummy_threading.patch deleted file mode 100644 index f78fa81f3..000000000 --- a/packages/python-sat/patches/dummy_threading.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/pysat/_utils.py b/pysat/_utils.py -index 8bdf132..74fb9fd 100644 ---- a/pysat/_utils.py -+++ b/pysat/_utils.py -@@ -32,7 +32,7 @@ - - # - #============================================================================== --import threading -+import dummy_threading as threading - - - # diff --git a/packages/pytz/meta.yaml b/packages/pytz/meta.yaml index dfc4c4338..ff572f512 100644 --- a/packages/pytz/meta.yaml +++ b/packages/pytz/meta.yaml @@ -2,8 +2,6 @@ package: name: pytz version: '2020.1' source: - patches: - - patches/dummy-threading.patch sha256: c35965d010ce31b23eeb663ed3cc8c906275d6be1a34393a1d73a41febf4a048 url: https://files.pythonhosted.org/packages/f4/f6/94fee50f4d54f58637d4b9987a1b862aeb6cd969e73623e02c5c00755577/pytz-2020.1.tar.gz test: diff --git a/packages/pytz/patches/dummy-threading.patch b/packages/pytz/patches/dummy-threading.patch deleted file mode 100644 index 88c926cab..000000000 --- a/packages/pytz/patches/dummy-threading.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff -ru pytz-2018.4.orig/pytz/lazy.py pytz-2018.4/pytz/lazy.py ---- pytz-2018.4.orig/pytz/lazy.py 2018-04-24 15:47:46.293980100 -0400 -+++ pytz-2018.4/pytz/lazy.py 2018-04-24 15:56:06.281648286 -0400 -@@ -1,4 +1,7 @@ --from threading import RLock -+try: -+ from threading import RLock -+except (ImportError, ModuleNotFoundError): -+ from dummy_threading import RLock - try: - from collections.abc import Mapping as DictMixin - except ImportError: # Python < 3.3 -Binary files pytz-2018.4.orig/pytz/__pycache__/lazy.cpython-36.pyc and pytz-2018.4/pytz/__pycache__/lazy.cpython-36.pyc differ diff --git a/packages/scipy/meta.yaml b/packages/scipy/meta.yaml index 4180399b0..f04d9e067 100644 --- a/packages/scipy/meta.yaml +++ b/packages/scipy/meta.yaml @@ -20,7 +20,6 @@ source: - patches/force_malloc.patch - patches/disable_scipy_stats_mvn.patch - patches/skip-fortran-fails-to-link.patch - - patches/dummy_threading.patch - patches/skip_ellip_harm_2_pyx_ctypes.patch build: diff --git a/packages/scipy/patches/dummy_threading.patch b/packages/scipy/patches/dummy_threading.patch deleted file mode 100644 index d1bb1237e..000000000 --- a/packages/scipy/patches/dummy_threading.patch +++ /dev/null @@ -1,115 +0,0 @@ -commit cfd6c4b18c5f338842d2ee509bfb2d3a3c6f6439 -Author: Roman Yurchak -Date: Mon Oct 15 15:40:48 2018 +0200 - - Use dummy_threading - -diff --git a/scipy/interpolate/tests/test_gil.py b/scipy/interpolate/tests/test_gil.py -index df3ab3bc4..974b68ada 100644 ---- a/scipy/interpolate/tests/test_gil.py -+++ b/scipy/interpolate/tests/test_gil.py -@@ -1,7 +1,7 @@ - from __future__ import division, print_function, absolute_import - - import itertools --import threading -+import dummy_threading as threading - import time - - import numpy as np -diff --git a/scipy/ndimage/tests/test_filters.py b/scipy/ndimage/tests/test_filters.py -index 8c56393a6..8ff85547c 100644 ---- a/scipy/ndimage/tests/test_filters.py -+++ b/scipy/ndimage/tests/test_filters.py -@@ -129,7 +129,7 @@ def test_gaussian_truncate(): - - class TestThreading(TestCase): - def check_func_thread(self, n, fun, args, out): -- from threading import Thread -+ from dummy_threading import Thread - thrds = [Thread(target=fun, args=args, kwargs={'output': out[x]}) for x in range(n)] - [t.start() for t in thrds] - [t.join() for t in thrds] -diff --git a/scipy/signal/signaltools.py b/scipy/signal/signaltools.py -index df7107684..2b9a18422 100644 ---- a/scipy/signal/signaltools.py -+++ b/scipy/signal/signaltools.py -@@ -4,7 +4,7 @@ - from __future__ import division, print_function, absolute_import - - import warnings --import threading -+import dummy_threading as threading - - from . import sigtools - from scipy._lib.six import callable -diff --git a/scipy/sparse/tests/test_sparsetools.py b/scipy/sparse/tests/test_sparsetools.py -index 7a3c903cc..cc495d500 100644 ---- a/scipy/sparse/tests/test_sparsetools.py -+++ b/scipy/sparse/tests/test_sparsetools.py -@@ -4,7 +4,7 @@ import sys - import os - import gc - import re --import threading -+import dummy_threading as threading - - from nose import SkipTest - import numpy as np -diff --git a/scipy/spatial/ckdtree.pyx b/scipy/spatial/ckdtree.pyx -index 2f98613a7..c9f657cf3 100644 ---- a/scipy/spatial/ckdtree.pyx -+++ b/scipy/spatial/ckdtree.pyx -@@ -17,8 +17,7 @@ from libc.string cimport memset, memcpy - - cimport cython - --from multiprocessing import cpu_count --import threading -+import dummy_threading as threading - - cdef extern from "limits.h": - long LONG_MAX -@@ -26,7 +25,7 @@ cdef extern from "limits.h": - cdef extern from "ckdtree_methods.h": - int number_of_processors - --number_of_processors = cpu_count() -+number_of_processors = 1 - - from libcpp.vector cimport vector - from libc cimport string -@@ -91,7 +90,7 @@ cdef extern from "cpp_utils.h": - # coo_entry wrapper - # ================= - --cdef class coo_entries: -+cdef class coo_entries(object): - - cdef: - readonly object __array_interface__ -diff --git a/scipy/spatial/qhull.pyx b/scipy/spatial/qhull.pyx -index ba33fadbe..644a57eaf 100644 ---- a/scipy/spatial/qhull.pyx -+++ b/scipy/spatial/qhull.pyx -@@ -10,7 +10,7 @@ Wrappers for Qhull triangulation, plus some additional N-D geometry utilities - # Distributed under the same BSD license as Scipy. - # - --import threading -+import dummy_threading as threading - import numpy as np - cimport numpy as np - cimport cython -diff --git a/scipy/special/_ellip_harm.py b/scipy/special/_ellip_harm.py -index 62e50655e..61e9949cc 100644 ---- a/scipy/special/_ellip_harm.py -+++ b/scipy/special/_ellip_harm.py -@@ -1,6 +1,6 @@ - from __future__ import division, print_function, absolute_import - --import threading -+import dummy_threading as threading - import numpy as np - - from ._ufuncs import _ellip_harm diff --git a/src/tests/test_python.py b/src/tests/test_python.py index 711646c72..ec6c50534 100644 --- a/src/tests/test_python.py +++ b/src/tests/test_python.py @@ -190,12 +190,9 @@ def test_python2js_numpy_scalar(selenium_standalone): def test_pythonexc2js(selenium): - try: + msg = "ZeroDivisionError" + with pytest.raises(selenium.JavascriptException, match=msg): selenium.run_js('return pyodide.runPython("5 / 0")') - except selenium.JavascriptException as e: - assert "ZeroDivisionError" in str(e) - else: - assert False, "Expected exception" def test_js2python(selenium): @@ -481,7 +478,8 @@ def test_pyproxy_destroy(selenium): f = Foo() """ ) - try: + msg = "Object has already been destroyed" + with pytest.raises(selenium.JavascriptException, match=msg): selenium.run_js( """ let f = pyodide.pyimport('f'); @@ -490,10 +488,6 @@ def test_pyproxy_destroy(selenium): f.get_value(); """ ) - except selenium.JavascriptException as e: - assert "Object has already been destroyed" in str(e) - else: - assert False, "Expected exception" def test_jsproxy(selenium): @@ -745,33 +739,28 @@ def test_runpythonasync_no_imports(selenium_standalone): def test_runpythonasync_missing_import(selenium_standalone): - try: + msg = "ModuleNotFoundError" + with pytest.raises(selenium_standalone.JavascriptException, match=msg): selenium_standalone.run_async( """ import foo """ ) - except selenium_standalone.JavascriptException as e: - assert "ModuleNotFoundError" in str(e) - else: - assert False def test_runpythonasync_exception(selenium_standalone): - try: + msg = "ZeroDivisionError" + with pytest.raises(selenium_standalone.JavascriptException, match=msg): selenium_standalone.run_async( """ 42 / 0 """ ) - except selenium_standalone.JavascriptException as e: - assert "ZeroDivisionError" in str(e) - else: - assert False def test_runpythonasync_exception_after_import(selenium_standalone): - try: + msg = "ZeroDivisionError" + with pytest.raises(selenium_standalone.JavascriptException, match=msg): selenium_standalone.run_async( """ import numpy as np @@ -779,10 +768,6 @@ def test_runpythonasync_exception_after_import(selenium_standalone): 42 / 0 """ ) - except selenium_standalone.JavascriptException as e: - assert "ZeroDivisionError" in str(e) - else: - assert False def test_py(selenium_standalone): diff --git a/src/tests/test_stdlib_fixes.py b/src/tests/test_stdlib_fixes.py new file mode 100644 index 000000000..b29b668fe --- /dev/null +++ b/src/tests/test_stdlib_fixes.py @@ -0,0 +1,75 @@ +import pytest + + +def test_threading_import(selenium): + # Importing threading works + selenium.run( + """ + from threading import Thread + """ + ) + + selenium.run( + """ + from threading import RLock + + with RLock(): + pass + """ + ) + + selenium.run( + """ + from threading import Lock + + with Lock(): + pass + """ + ) + + selenium.run( + """ + import threading + threading.local() + """ + ) + + # Starting a thread doesn't work + msg = "can't start new thread" + with pytest.raises(selenium.JavascriptException, match=msg): + selenium.run( + """ + from threading import Thread + + def set_state(): + return + th = Thread(target=set_state) + th.start() + """ + ) + + +def test_multiprocessing(selenium): + selenium.run("import multiprocessing") + + res = selenium.run( + """ + from multiprocessing import cpu_count + cpu_count() + """ + ) + assert isinstance(res, int) + assert res > 0 + + msg = "Resource temporarily unavailable" + with pytest.raises(selenium.JavascriptException, match=msg): + selenium.run( + """ + from multiprocessing import Process + + def func(): + return + process = Process(target=func) + process.start() + """ + ) diff --git a/src/tests/test_webworker.py b/src/tests/test_webworker.py index d7a56ff28..01b7baea4 100644 --- a/src/tests/test_webworker.py +++ b/src/tests/test_webworker.py @@ -1,3 +1,6 @@ +import pytest + + def test_runwebworker(selenium_standalone): output = selenium_standalone.run_webworker( """ @@ -29,33 +32,28 @@ def test_runwebworker_no_imports(selenium_standalone): def test_runwebworker_missing_import(selenium_standalone): - try: + msg = "ModuleNotFoundError" + with pytest.raises(selenium_standalone.JavascriptException, match=msg): selenium_standalone.run_webworker( """ import foo """ ) - except selenium_standalone.JavascriptException as e: - assert "ModuleNotFoundError" in str(e) - else: - assert False def test_runwebworker_exception(selenium_standalone): - try: + msg = "ZeroDivisionError" + with pytest.raises(selenium_standalone.JavascriptException, match=msg): selenium_standalone.run_webworker( """ 42 / 0 """ ) - except selenium_standalone.JavascriptException as e: - assert "ZeroDivisionError" in str(e) - else: - assert False def test_runwebworker_exception_after_import(selenium_standalone): - try: + msg = "ZeroDivisionError" + with pytest.raises(selenium_standalone.JavascriptException, match=msg): selenium_standalone.run_webworker( """ import numpy as np @@ -63,10 +61,6 @@ def test_runwebworker_exception_after_import(selenium_standalone): 42 / 0 """ ) - except selenium_standalone.JavascriptException as e: - assert "ZeroDivisionError" in str(e) - else: - assert False def test_runwebworker_micropip(selenium_standalone):