Skip to content

Commit

Permalink
Update generator to work with python 3.12
Browse files Browse the repository at this point in the history
`imp` has been removed in python 3.12. I switched to the replacement suggested in the release notes. See: https://docs.python.org/3.12/whatsnew/3.12.html#imp

While I did not test previous python versions, the replacement function `types.ModuleType` is available since at least python 3.4
  • Loading branch information
eikesr authored Apr 24, 2024
1 parent 494f773 commit 29d5c87
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions flatdata-generator/flatdata/generator/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
See the LICENSE file in the root of this project for license details.
'''

import imp
import types

from flatdata.generator.tree.builder import build_ast
from flatdata.generator.tree.nodes.trivial.namespace import Namespace
Expand Down Expand Up @@ -70,7 +70,7 @@ def render_python_module(self, module_name=None, archive_name=None):
"""
root_namespace = self._find_root_namespace(self.tree)
module_code = self.render("py")
module = imp.new_module(module_name if module_name is not None else root_namespace.name)
module = types.ModuleType(module_name if module_name is not None else root_namespace.name)
#pylint: disable=exec-used
exec(module_code, module.__dict__)
if archive_name is None:
Expand Down

0 comments on commit 29d5c87

Please sign in to comment.