-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix: set __file__ on submodules #5584
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
Changes from 3 commits
b77521b
8d579fa
bddc1e0
8a00fd6
4682e14
ef1319e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1336,6 +1336,19 @@ class module_ : public object { | |
| if (doc && options::show_user_defined_docstrings()) { | ||
| result.attr("__doc__") = pybind11::str(doc); | ||
| } | ||
|
|
||
| #ifdef GRAALVM_PYTHON | ||
| // GraalPy doesn't support PyModule_GetFilenameObject, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is fine if you want to keep it, but the official We have 7
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, done. |
||
| // so getting by attribute | ||
| handle this_module = m_ptr; | ||
| result.attr("__file__") = this_module.attr("__file__"); | ||
| #else | ||
| handle this_file = PyModule_GetFilenameObject(m_ptr); | ||
| if (!this_file) { | ||
| throw error_already_set(); | ||
| } | ||
| result.attr("__file__") = this_file; | ||
| #endif | ||
| attr(name) = result; | ||
| return result; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion applied with commit 4682e14