-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Introduce UserDefinedExceptionClassVariable
#146504
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
Introduce UserDefinedExceptionClassVariable
#146504
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/146504
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 7507f1c with merge base 50c9f6d ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
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.
UserDefinedExceptionClassVariable and UserDefinedExceptionObjectVariable still own an ExceptionVariable
return variables.ConstantVariable(None) | ||
return super().call_method(tx, name, args, kwargs) | ||
|
||
def __getattr__(self, name): |
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.
Why do we need this?
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.
The UserDefinedExceptionObjectVariable holds an exception variable under the hood (self.exc_vt
). This function is to redirect some of the calls to the underlying self.exc_vt
variable if the outer object doesn't overload it. For instance, a getattr(obj, '__context__')
will redirect to getattr(obj.exc_vt, '__context__')
.
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.
Would it be better to manually write out what methods we're passing along? Otherwise the code gets harder to read. e.g. if you just need __context__
then just define a context property that calls self.exc_vt
so I guess the question is, how many fields do you need to pass through?
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.
Just two. I changed the implementation, so this is more explicit.
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.
Looks good to me, I'll defer to @anijain2305 for the final review (and what to do about the getattr piece)
Starting merge as part of PR stack under #146502 |
1 similar comment
Starting merge as part of PR stack under #146502 |
) Pull Request resolved: #146499 Approved by: https://github.com/zou3519, https://github.com/anijain2305 ghstack dependencies: #146504
Pull Request resolved: #146502 Approved by: https://github.com/anijain2305, https://github.com/williamwen42, https://github.com/zou3519 ghstack dependencies: #146504, #146499
Stack from ghstack (oldest at bottom):
contextlib.suppress
#147990raise ... from ...
#148766StopIteration
#148765__context/cause/suppress_context/traceback__
to Exception #146499UserDefinedExceptionClassVariable
#146504cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @chauhang @amjames