From 0bcf65704ac65d78d48ede0c9556f3478b3a8a2994e15ea53d6e1d566eda7c9c Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Sun, 2 May 2021 17:07:37 +0000 Subject: [PATCH] Accepting request 889802 from home:bnavigator:branches:devel:languages:python:Factory - Make sure to close the import_failed.map file after the exception has been raised in order to avoid ResourceWarnings when the failing import is part of a try...except block. Please sync to the other flavors. This fixes test suite failures of packages with `-W error` and optional imports. (e.g. pytest-doctestplus) OBS-URL: https://build.opensuse.org/request/show/889802 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:Factory/python38?expand=0&rev=65 --- import_failed.py | 11 ++++++----- python38.changes | 7 +++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/import_failed.py b/import_failed.py index 7e83460..258b5a5 100644 --- a/import_failed.py +++ b/import_failed.py @@ -8,11 +8,12 @@ if __spec__: else: failed_name = __name__ -for line in open(failed_map_path): - package = line.split(':')[0] - imports = line.split(':')[1] - if failed_name in imports: - raise ImportError(f"""Module '{failed_name}' is not installed. +with open(failed_map_path) as fd: + for line in fd: + package = line.split(':')[0] + imports = line.split(':')[1] + if failed_name in imports: + raise ImportError(f"""Module '{failed_name}' is not installed. Use: sudo zypper install {package} to install it.""") diff --git a/python38.changes b/python38.changes index 02b2884..f9ffdf3 100644 --- a/python38.changes +++ b/python38.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Sun May 2 09:20:06 UTC 2021 - Ben Greiner + +- Make sure to close the import_failed.map file after the exception + has been raised in order to avoid ResourceWarnings when the + failing import is part of a try...except block. + ------------------------------------------------------------------- Wed Apr 28 17:32:55 UTC 2021 - Matej Cepl