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-77371: Clarify that types.new_class() kwds are class keywords by aribaskagan · Pull Request #161890 · python/cpython

Conversation

@aribaskagan

@aribaskagan aribaskagan commented Nov 12, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown

Fixes #77371.

help(types.new_class) only said "Create a class object dynamically using the appropriate metaclass." Callers coming from type(name, bases, dict) were treating kwds as that namespace. As discussed on the issue, kwds is the keywords of the class statement, and the body is filled in by exec_body. Doc/library/types.rst already says this, so it is unchanged. prepare_class() gets the same one-sentence note.

Before:

Create a class object dynamically using the appropriate metaclass.

After:

Create a class object dynamically using the appropriate metaclass.

*name*, *bases*, and *kwds* are the class name, the base classes,
and the keywords of the equivalent class definition (such as
'metaclass').  *kwds* is not a namespace like the third argument
of type().  For example:

    new_class('Test', (A, B), {'metaclass': Meta, 'foo': 42})

is equivalent to:

    class Test(A, B, metaclass=Meta, foo=42):
        pass

To populate the namespace, pass *exec_body*, a callable that takes
the newly created dictionary and populates it.  For example:

    new_class('C', (MyABC,), {},
              exec_body=lambda ns: ns.update(namespace))

AI assistance was used in preparing this change; I reviewed and tested it.

  • Issue: problem with ABCMeta.__prepare__ when called after types.new_class #77371

Sorry, something went wrong.

Uh oh!

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

All reactions
@aribaskagan
pythongh-77371: Clarify that types.new_class() kwds are class keywords
adf3991
kwds corresponds to keywords in the class statement, such as
metaclass, rather than the namespace dictionary accepted by type().
The class body is filled in by exec_body.  Note the same distinction
on prepare_class().

Co-authored-by: Kağan Arıbaş <[email protected]>
@aribaskagan
aribaskagan requested a review from AA-Turner as a code owner November 12, 2026 17:47
Copilot AI balanced review requested due to automatic review settings November 12, 2026 17:47
@python-cla-bot

python-cla-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

  • [email protected]

CLA not signed

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot mentioned this pull request Nov 12, 2026
problem with ABCMeta.__prepare__ when called after types.new_class #77371
Open
Copilot AI reviewed Nov 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app

bedevere-app Bot commented Nov 12, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

All reactions

Sorry, something went wrong.

Uh oh!

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T17:50:55.047307Z adf3991 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot added the awaiting review label Nov 12, 2026
chatgpt-codex-connector[bot]
chatgpt-codex-connector Bot reviewed Nov 12, 2026
View reviewed changes

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: adf39919c7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Lib/types.py
class Test(A, B, metaclass=Meta, foo=42):
pass

To populate the namespace, pass *exec_body*, a callable that takes

@chatgpt-codex-connector chatgpt-codex-connector Bot Nov 12, 2026

Copy link
Copy Markdown

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.

P2 Badge Describe exec_body's argument as a namespace mapping

With a metaclass whose __prepare__ returns a valid non-dict mapping, prepare_class() returns that object and new_class() passes it to exec_body; a mapping need not implement dictionary methods such as .update(), so calling it a “dictionary” can mislead callbacks that use dict-only methods, and the example immediately below uses .update(). Please use “prepared namespace” or “mapping,” as Doc/library/types.rst does.

AGENTS.md reference: AGENTS.md:L14-L14

Useful? React with 👍 / 👎.

Sorry, something went wrong.

Uh oh!

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

All reactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@chatgpt-codex-connector chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] left review comments
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

awaiting review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

problem with ABCMeta.__prepare__ when called after types.new_class

Uh oh!

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

2 participants

@aribaskagan
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 01402503 — 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.