-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-28869: Skip one additional frame when type.__new__ is called not directly from type.__call__. #14166
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
base: main
Are you sure you want to change the base?
bpo-28869: Skip one additional frame when type.__new__ is called not directly from type.__call__. #14166
Conversation
* Move handling of one-argument call of type() from type.__new__() to type.__call__(). * Move deducing __module__ from the caller's frame from type.__new__() to type.__call__().
94ab8b0
to
6b14bb1
Compare
@serhiy-storchaka I like this approach, please let me know when this is ready for review (I assume tests are needed and some comments explaining this behavior). |
Yes, it needs tests and documenting. Also this PR contains actually two changes. I am not sure that both of them should be backported, but it is difficult to make one without making other. |
I just have tested, and seems there is no undesired behavior change. So I just need to write tests and a NEWS entry. |
Unfortunately it does not work. Not setting |
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.
I have one question/comment. Also if we are going this way, I think this deserves a comment in the code explaining the motivation.
} | ||
while (depth-- > 0 && f->f_back) { | ||
f = f->f_back; | ||
} |
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.
Unless I am missing something, depth
can be only either 0 or 1, maybe it is better to use a name like skip
or nested
and write this as:
if (skip_frame && f->f_back) {
f = f->f_back;
}
It looks like this may also fix https://bugs.python.org/issue37948 |
I am not sure it is a good solution. |
https://bugs.python.org/issue28869