bpo-28869: Skip one additional frame when type.__new__ is called not directly from type.__call__.#14166
bpo-28869: Skip one additional frame when type.__new__ is called not directly from type.__call__.#14166serhiy-storchaka wants to merge 8 commits intopython:mainfrom
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 |
ilevkivskyi
left a comment
There was a problem hiding this comment.
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.
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