You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defadd_variables_from_file(self, file_path):
""" Adds all OpenFisca variables contained in a given file to the tax and benefit system. """try:
file_name=path.splitext(path.basename(file_path))[0]
module_name='{}_{}'.format(id(self), file_name) # If two tax and benefit systems load the same module, the second one should not replace the first one. Hence this unique module name.module_directory=path.dirname(file_path)
try:
module=load_module(module_name, *find_module(file_name, [module_directory]))
exceptNameErrorase:
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: <https://github.com/openfisca/openfisca-core/blob/master/CHANGELOG.md>")
raisepotential_variables= [getattr(module, item) foritemindir(module) ifnotitem.startswith('__')]
forpot_variableinpotential_variables:
# We only want to get the module classes defined in this module (not imported)ifisclass(pot_variable) and \
issubclass(pot_variable, Variable) and \
pot_variable.__module__.endswith(module_name): # <----------- THIS LINE HEREself.add_variable(pot_variable)
except:
log.error(u'Unable to load OpenFisca variables from file "{}"'.format(file_path))
raise
pot_variable.__module__.endswith(module_name)
If two modules have the same names (ie. two files) that will fail.
I managed to replicate this issue with less complexity (ie. only with the country-template package).
Edit: Two enters instead of one…
The text was updated successfully, but these errors were encountered:
Last week, I was in France countryside and I pair-programmed to code a local benefit.
I did not manage to show our product with all the extensions activated because I had an exception when loading the French tax benefit system.
To demo the issue, I created guillett/test_openfisca_extensions.
I managed to investigate the issue today and I think I found the culprit line.
openfisca_core/taxbenefitsystems.py:152
pot_variable.__module__.endswith(module_name)
If two modules have the same names (ie. two files) that will fail.
I managed to replicate this issue with less complexity (ie. only with the country-template package).
Edit: Two enters instead of one…
The text was updated successfully, but these errors were encountered: