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 — bpo-46417: Cleanup typeobject.c code by vstinner · Pull Request #30795 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Jan 22, 2022 •
edited by bedevere-bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member
  • Add comment to recurse_down_subclasses() explaining why it's safe
    to use a borrowed reference to tp_subclasses.
  • remove_all_subclasses() no longer accept NULL cases
  • type_set_bases() now relies on the fact that new_bases is not NULL.
  • type_dealloc_common() avoids PyErr_Fetch/PyErr_Restore if tp_bases
    is NULL.
  • remove_all_subclasses() makes sure that no exception is raised.
  • Don't test at runtime if tp_mro only contains types: rely on
    _PyType_CAST() assertion for that.
  • _PyStaticType_Dealloc() no longer clears tp_subclasses which is
    already NULL.
  • mro_hierarchy() avoids calling _PyType_GetSubclasses() if
    tp_subclasses is NULL.

Coding style:

  • Use Py_NewRef().
  • Add braces and move variable declarations to the first variable
    assignement.
  • Rename a few variables and parameters to use better names.

https://bugs.python.org/issue46417

Sorry, something went wrong.

Uh oh!

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

All reactions
@vstinner
bpo-46417: Cleanup typeobject.c code
be38dcc
* Add comment to recurse_down_subclasses() explaining why it's safe
  to use a borrowed reference to tp_subclasses.
* remove_all_subclasses() no longer accept NULL cases
* type_set_bases() now relies on the fact that new_bases is not NULL.
* type_dealloc_common() avoids PyErr_Fetch/PyErr_Restore if tp_bases
  is NULL.
* remove_all_subclasses() makes sure that no exception is raised.
* Don't test at runtime if tp_mro only contains types: rely on
  _PyType_CAST() assertion for that.
* _PyStaticType_Dealloc() no longer clears tp_subclasses which is
  already NULL.
* mro_hierarchy() avoids calling _PyType_GetSubclasses() if
  tp_subclasses is NULL.

Coding style:

* Use Py_NewRef().
* Add braces and move variable declarations to the first variable
  assignement.
* Rename a few variables and parameters to use better names.
@vstinner vstinner added the skip news label Jan 22, 2022
@vstinner
vstinner requested a review from markshannon as a code owner January 22, 2022 17:12
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Jan 22, 2022
@bedevere-bot bedevere-bot added the awaiting core review label Jan 22, 2022
@vstinner

vstinner commented Jan 22, 2022

Copy link
Copy Markdown
Member Author

test_concurrent_futures timed out on Address sanitizer and had to be re-run:

1 re-run test:
    test_concurrent_futures

10 slowest tests:
- test_concurrent_futures: 25 min
- test_peg_generator: 9 min 46 sec
- test_tools: 4 min 45 sec
- test_asyncio: 2 7min 18 sec
- test_weakref: 1 min 26 sec
- test_venv: 1 min 24 sec
- test_subprocess: 1 min 6 sec
- test_lib2to3: 1 min 1 sec
- test_pickle: 59.4 sec
- test_gdb: 58.5 sec
All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner
vstinner merged commit 3a4c15b into python:main Jan 22, 2022
@bedevere-bot bedevere-bot removed the awaiting core review label Jan 22, 2022
@vstinner
vstinner deleted the cleanup_typeobject branch January 22, 2022 17:56
@encukou

encukou commented Apr 8, 2024

Copy link
Copy Markdown
Member

In PyType_GetModuleByDef, the comment & assert is now out of date:

    // mro_invoke() ensures that the type MRO cannot be empty, so we don't have
    // to check i < PyTuple_GET_SIZE(mro) at the first loop iteration.
    assert(PyTuple_GET_SIZE(mro) >= 1);

With a for loop, the i < PyTuple_GET_SIZE(mro) check is done before each iteration.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Apr 8, 2024

Copy link
Copy Markdown
Member Author

Two years later, I don't recall why I replaced the while() loop with a for() loop. You can restore the while if you prefer.

encukou reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@encukou encukou mentioned this pull request Apr 9, 2024
gh-117142: Port _ctypes to multi-phase init #117181
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

skip news

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.

4 participants

@vstinner @encukou @the-knights-who-say-ni @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.