GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-73055: Skip one additional frame when type.__new__ is called not directly from type.__call__. by serhiy-storchaka · Pull Request #14166 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jun 17, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

https://bugs.python.org/issue28869

  • Issue: __module__ attribute is not set correctly for a class created by direct metaclass call #73055

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka serhiy-storchaka added the DO-NOT-MERGE label Jun 17, 2019
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Jun 17, 2019
@bedevere-bot bedevere-bot added the awaiting core review label Jun 17, 2019
@serhiy-storchaka
bpo-28869: Change some details in type().
6b14bb1
* 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__().
@serhiy-storchaka
serhiy-storchaka force-pushed the type-call-set-module branch from 94ab8b0 to 6b14bb1 Compare June 17, 2019 19:12
@brettcannon brettcannon added the type-bug An unexpected behavior, bug, or error label Jun 21, 2019
@serhiy-storchaka
Merge branch 'master' into type-call-set-module
0aef546
@ilevkivskyi

ilevkivskyi commented Aug 7, 2019

Copy link
Copy Markdown
Member

@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).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ilevkivskyi ilevkivskyi mentioned this pull request Aug 7, 2019
gh-73055: Set class module to caller module in ABCMeta.__new__ #14126
Closed
@serhiy-storchaka

serhiy-storchaka commented Aug 7, 2019

Copy link
Copy Markdown
Member Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka

serhiy-storchaka commented Aug 7, 2019

Copy link
Copy Markdown
Member Author

I just have tested, and seems there is no undesired behavior change. So I just need to write tests and a NEWS entry.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka
Merge branch 'master' into type-call-set-module
c80cd51
@serhiy-storchaka

serhiy-storchaka commented Oct 7, 2019

Copy link
Copy Markdown
Member Author

Unfortunately it does not work. Not setting __module__ in the class dictionary does not help with the original issue, because __module__ will be looked up in the metaclass dictionary. Setting it in __call__() opens other questions and significantly complicates the code.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka added 3 commits October 13, 2019 13:42
@serhiy-storchaka
Skip additional frame if type.__new__ is not called from type.__call__.
fe3b8c6
@serhiy-storchaka
Rever moving handling of one-argument call of type().
8b76f9f
@serhiy-storchaka
Add a NEWS entry.
c8a471d
@serhiy-storchaka serhiy-storchaka changed the title [WIP] bpo-28869: Change some details in type(). bpo-28869: Skip one additional frame when type.__new__ is called not directly from type.__call__. Oct 13, 2019
@serhiy-storchaka serhiy-storchaka removed the DO-NOT-MERGE label Oct 13, 2019
ilevkivskyi
ilevkivskyi reviewed Oct 13, 2019
View reviewed changes

@ilevkivskyi ilevkivskyi left a comment

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Objects/typeobject.c
}
while (depth-- > 0 && f->f_back) {
f = f->f_back;
}

@ilevkivskyi ilevkivskyi Oct 13, 2019

Copy link
Copy Markdown
Member

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;
}

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ilevkivskyi

ilevkivskyi commented Nov 17, 2019

Copy link
Copy Markdown
Member

It looks like this may also fix https://bugs.python.org/issue37948

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka
Merge branch 'master' into type-call-set-module
32f0bfa
@serhiy-storchaka

serhiy-storchaka commented Mar 8, 2020

Copy link
Copy Markdown
Member Author

I am not sure it is a good solution.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka serhiy-storchaka added the DO-NOT-MERGE label Mar 8, 2020
@serhiy-storchaka
Merge branch 'master' into type-call-set-module
a0ad2ef
@githorse githorse mentioned this pull request May 22, 2020
get_type_hints crashes on TypedDict with non-builtin types from other modules python/mypy_extensions#11
Closed
@ezio-melotti ezio-melotti removed the CLA signed label Jul 13, 2022
@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 7, 2026
@serhiy-storchaka serhiy-storchaka changed the title bpo-28869: Skip one additional frame when type.__new__ is called not directly from type.__call__. gh-73055: Skip one additional frame when type.__new__ is called not directly from type.__call__. Aug 12, 2026
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Aug 14, 2026
@ambv

ambv commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

This PR has not been touched by a human in more than 5 years. Closing to cull the number of open pull requests. Do not reopen this pull request without getting a go-ahead from a triager or core developer on the related issue.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ambv ambv closed this Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ilevkivskyi ilevkivskyi ilevkivskyi left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review DO-NOT-MERGE type-bug An unexpected behavior, bug, or error

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@serhiy-storchaka @ilevkivskyi @ambv @brettcannon @the-knights-who-say-ni @ezio-melotti @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.