-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix(regression): support embedded submodule #5650
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 8 commits
e6f029c
69dc30a
cd72edf
edefef4
c22a5b8
a8bbfd3
96c7daa
1972a8a
e922cc5
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 |
---|---|---|
|
@@ -1342,13 +1342,18 @@ class module_ : public object { | |
// GraalPy doesn't support PyModule_GetFilenameObject, | ||
// so getting by attribute (see PR #5584) | ||
handle this_module = m_ptr; | ||
result.attr("__file__") = this_module.attr("__file__"); | ||
if (hasattr(this_module, "__file__")) { | ||
result.attr("__file__") = this_module.attr("__file__"); | ||
} | ||
#else | ||
handle this_file = PyModule_GetFilenameObject(m_ptr); | ||
if (!this_file) { | ||
if (this_file) { | ||
result.attr("__file__") = this_file; | ||
} else if (PyErr_ExceptionMatches(PyExc_SystemError) != 0) { | ||
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. Ugh ... if we have to catch a I think it'll be best to get rid of this 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. Python even throws exceptions when iterating over ranges. I would expect Python's low level C error handling to be more lightweight (if one can say that when it comes to python) than what happens if this were translated to a C++ exception. 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. It should be extremely rare, this is only for embedded submodules, normally it works. I think it's probably fine to leave this way. 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. Up to you, I'm OK if you want to keep it. What still makes me feel uneasy: the risk of masking unexpected Which is of course extremely low, but not zero. (Google experience: anything that can happen, does happen.) 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. The function is part of the Stable API and just accesses a dictionary. My two cents: the current implementation is safe. 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. Do you have a link to the implementation handy? What's on my mind: Why does it raise I'd feel more cozy ignoring an But as I said, I'm fine with this. 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. The function explicitly sets the system error. I could not see any system errors in the source of the dictionary. 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. Thanks!
Seems like an unfortunate choice, to have it in the same class of exceptions as e.g. out-of-memory, but 🤷 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.
https://docs.python.org/3/library/exceptions.html#SystemError
Doesn’t seem too bad, I think it’s for things like this, exceptions that shouldn’t make it up to the user. |
||
PyErr_Clear(); | ||
} else { | ||
throw error_already_set(); | ||
} | ||
result.attr("__file__") = this_file; | ||
#endif | ||
attr(name) = result; | ||
return result; | ||
|
Uh oh!
There was an error while loading. Please reload this page.