From f4aab29c1ef358c5c1ceb97fb2fce7f34e4b9179 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20G=C3=B3rny?= Date: Tue, 26 May 2020 21:52:01 +0200 Subject: [PATCH] dev-python/tqdm: Port to py39 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Górny --- dev-python/tqdm/files/tqdm-4.46.0-py39.patch | 42 ++++++++++++++++++++ dev-python/tqdm/tqdm-4.46.0.ebuild | 6 ++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 dev-python/tqdm/files/tqdm-4.46.0-py39.patch diff --git a/dev-python/tqdm/files/tqdm-4.46.0-py39.patch b/dev-python/tqdm/files/tqdm-4.46.0-py39.patch new file mode 100644 index 000000000000..0734aa83b96f --- /dev/null +++ b/dev-python/tqdm/files/tqdm-4.46.0-py39.patch @@ -0,0 +1,42 @@ +From aeb52044ca29f37f1f98ee5a4f9ad774d557771e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= +Date: Tue, 26 May 2020 21:43:05 +0200 +Subject: [PATCH] Fix error due to missing sys.setcheckinterval in py3.9 + +Python 3.9 finally removed sys.setcheckinterval(). While the package +apparently tried to account for that, the logic is flawed and the second +getattr() raises an AttributeError even if its result is never used. +This caused tests to fail: + + File "/tmp/tqdm/tqdm/tests/tests_tqdm.py", line 126, in pretest + getattr(sys, 'setswitchinterval', getattr(sys, 'setcheckinterval'))(100) + AttributeError: module 'sys' has no attribute 'setcheckinterval' + +Refactor the code into a try/except construct that does not execute +the setcheckinterval() branch unless setswitchinterval() is actually +missing. While at it, scale the arguments a bit -- the current version +used either 100 instructions or 100 seconds that were rather of very +different magnitudes. +--- + tqdm/tests/tests_tqdm.py | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/tqdm/tests/tests_tqdm.py b/tqdm/tests/tests_tqdm.py +index a2dac52..5f322e6 100644 +--- a/tqdm/tests/tests_tqdm.py ++++ b/tqdm/tests/tests_tqdm.py +@@ -123,7 +123,10 @@ def cpu_timify(t, timer=None): + + def pretest(): + # setcheckinterval is deprecated +- getattr(sys, 'setswitchinterval', getattr(sys, 'setcheckinterval'))(100) ++ try: ++ sys.setswitchinterval(1) ++ except AttributeError: ++ sys.setcheckinterval(100) + + if getattr(tqdm, "_instances", False): + n = len(tqdm._instances) +-- +2.26.2 + diff --git a/dev-python/tqdm/tqdm-4.46.0.ebuild b/dev-python/tqdm/tqdm-4.46.0.ebuild index 4bafe9ec3365..2273ba0de862 100644 --- a/dev-python/tqdm/tqdm-4.46.0.ebuild +++ b/dev-python/tqdm/tqdm-4.46.0.ebuild @@ -4,7 +4,7 @@ EAPI=7 DISTUTILS_USE_SETUPTOOLS=rdepend -PYTHON_COMPAT=( pypy3 python{2_7,3_{6,7,8}} ) +PYTHON_COMPAT=( pypy3 python{2_7,3_{6,7,8,9}} ) inherit distutils-r1 @@ -25,6 +25,10 @@ IUSE="examples" distutils_enable_tests nose +PATCHES=( + "${FILESDIR}"/${P}-py39.patch +) + python_prepare_all() { sed -r \ -e "s:'nose'(,[[:space:]]*|)::" \ -- 2.26.2