From e137cab0354fa1a3c99bea6ee894dc5bd151fd59 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 30 Oct 2023 11:59:46 +0000 Subject: [PATCH] Allow to import cpython module multiple times --- src/sage/cpython/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sage/cpython/__init__.py b/src/sage/cpython/__init__.py index 5deff221609..cb262984002 100644 --- a/src/sage/cpython/__init__.py +++ b/src/sage/cpython/__init__.py @@ -12,7 +12,8 @@ # Monkey-patch ExtensionFileLoader to allow IPython to find the sources # of Cython files. See https://github.com/sagemath/sage/issues/24681 from importlib.machinery import ExtensionFileLoader as _ExtensionFileLoader -del _ExtensionFileLoader.get_source +if hasattr(_ExtensionFileLoader, 'get_source'): + del _ExtensionFileLoader.get_source del _ExtensionFileLoader # Work around a Cygwin-specific bug caused by sqlite3; see