From 38c10cc4a4d92825a29f8f8ee7f96b2a9fd88fad Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sun, 28 Nov 2021 13:02:25 -0800 Subject: [PATCH 1/2] Apply @maukoquiroga's suggested fix to #1053 --- openfisca_core/taxbenefitsystems/tax_benefit_system.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openfisca_core/taxbenefitsystems/tax_benefit_system.py b/openfisca_core/taxbenefitsystems/tax_benefit_system.py index 26e37a7b81..cc1c543f11 100644 --- a/openfisca_core/taxbenefitsystems/tax_benefit_system.py +++ b/openfisca_core/taxbenefitsystems/tax_benefit_system.py @@ -5,9 +5,9 @@ import logging import os import pkg_resources +import sys import traceback import typing -from imp import find_module, load_module from openfisca_core import commons, periods, variables from openfisca_core.entities import Entity @@ -188,11 +188,13 @@ def add_variables_from_file(self, file_path): # As Python remembers loaded modules by name, in order to prevent collisions, we need to make sure that: # - Files with the same name, but located in different directories, have a different module names. Hence the file path hash in the module name. # - The same file, loaded by different tax and benefit systems, has distinct module names. Hence the `id(self)` in the module name. - module_name = '{}_{}_{}'.format(id(self), hash(os.path.abspath(file_path)), file_name) + module_name = f"{id(self)}_{hash(os.path.abspath(file_path))}_{file_name}" - module_directory = os.path.dirname(file_path) try: - module = load_module(module_name, *find_module(file_name, [module_directory])) + spec = importlib.util.spec_from_file_location(module_name, file_path) + module = importlib.util.module_from_spec(spec) + sys.modules[module_name] = module + spec.loader.exec_module(module) except NameError as e: logging.error(str(e) + ": if this code used to work, this error might be due to a major change in OpenFisca-Core. Checkout the changelog to learn more: ") raise From c3bd47238d305af42dfa254a251adb20e9c92de4 Mon Sep 17 00:00:00 2001 From: Mahdi Ben Jelloul Date: Wed, 15 Dec 2021 07:15:40 +0100 Subject: [PATCH 2/2] Bump --- CHANGELOG.md | 6 ++++++ setup.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba0b7714cc..fb65cab458 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +### 35.7.5 [#1090](https://github.com/openfisca/openfisca-core/pull/1090) + +#### Technical changes + +- Remove calls to deprecated imp module + ### 35.7.4 [#1083](https://github.com/openfisca/openfisca-core/pull/1083) #### Technical changes diff --git a/setup.py b/setup.py index 2cba798a57..a07db66a33 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ setup( name = 'OpenFisca-Core', - version = '35.7.4', + version = '35.7.5', author = 'OpenFisca Team', author_email = 'contact@openfisca.org', classifiers = [