Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow relative imports in translated functions #1081

Merged

Conversation

Christopher-Chianelli
Copy link
Contributor

  • CPython will check globals for __name__, which it uses to determine the absolute package name from a relative package name

    • This means that we need to add the __name__ entry to all Python global maps, even if __name__ is not used directly by any function in the module
  • Fix default loading for one call signature

  • Make ConstraintCollector.__hash__ raise a TypeError, to give an informative error message

  • Make PythonInterpreter importModule return a PythonLikeObject, so C modules can be imported

  • Use an WrappedExceptionMeta to rename the WrappedException class returned

Fixes #967

- CPython will check globals for `__name__`, which it uses to determine the absolute package name from a relative package name

  - This means that we need to add the `__name__` entry to all Python global maps, even if `__name__` is not used directly by any function in the module

- Fix default loading for one call signature

- Make `ConstraintCollector.__hash__` raise a TypeError, to give an informative error message

- Make PythonInterpreter importModule return a PythonLikeObject, so C modules can be imported

- Use an WrappedExceptionMeta to rename the WrappedException class returned

Fixes TimefoldAI#967
Copy link

sonarqubecloud bot commented Sep 9, 2024

@Christopher-Chianelli Christopher-Chianelli merged commit 037450f into TimefoldAI:main Sep 11, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better error message: KeyError: "'__name__' not in globals"
2 participants