Skip to content

gh-136535: Tests: Correct Py_TPFLAGS_MANAGED_DICT in test_class.py #136538

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ever0de
Copy link

@ever0de ever0de commented Jul 11, 2025

The Py_TPFLAGS_MANAGED_DICT constant in Lib/test/test_class.py was incorrectly set to (1 << 2) instead of the correct (1 << 4) from object.h.

issue: #136535

@python-cla-bot
Copy link

python-cla-bot bot commented Jul 11, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app bedevere-app bot added awaiting review tests Tests in the Lib/test dir labels Jul 11, 2025
@bedevere-app
Copy link

bedevere-app bot commented Jul 11, 2025

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.

…ass.py`

The `Py_TPFLAGS_MANAGED_DICT` constant in `Lib/test/test_class.py`
was incorrectly set to (1 << 2) instead of the correct (1 << 4) from
object.h.
Copy link
Member

@corona10 corona10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I also double checked with the original reference:

#define Py_TPFLAGS_MANAGED_DICT (1 << 4)

I am waiting @Fidget-Spinner or @markshannon 's review also.

Copy link
Member

@corona10 corona10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi would you like to improve the test if the is Py_TPFLAGS_MANAGED_DICT wrongly set?

With my local change it is passed if I modify the value into 1 << 2, I prefer to prevent regression in the future.

@bedevere-app
Copy link

bedevere-app bot commented Jul 13, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@corona10 corona10 added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jul 13, 2025
@ever0de
Copy link
Author

ever0de commented Jul 13, 2025

Hi would you like to improve the test if the is Py_TPFLAGS_MANAGED_DICT wrongly set?

With my local change it is passed if I modify the value into 1 << 2, I prefer to prevent regression in the future.

Hello. I thought the test I added would prevent regression issues, but it didn't.
I think I can prevent this problem by checking Py_TPFLAGS_INLINE_VALUES (1 << 2 flag) in NoManagedDict. Would it be better to add it this way?
If you have any other better improvement suggestions, could you please propose them? Thank you!


class TestInlineValues(unittest.TestCase):

def test_flags(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revive test_flags also.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ever0de Oh it was my miss, you don't have to revive :(

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see, Should I drop this commit then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, please revert b39ca1a

Copy link
Member

@corona10 corona10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@@ -873,12 +877,31 @@ def __init__(self):
self.c = 3
self.d = 4

class VarSizedSubclass(tuple):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class VarSizedSubclass(tuple):
class VarSizedSubclass(tuple):

Py_TPFLAGS_MANAGED_DICT = (1 << 4)

class NoManagedDict:
__slots__ = ('a',)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
__slots__ = ('a',)
__slots__ = ('a',)

pep 8

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting merge needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy