Skip to content

gh-80762: Fix dir() on MagicMock with tuple specs - #12753

Merged
serhiy-storchaka merged 5 commits into
python:mainfrom
dsem:fix-issue-36581
Aug 12, 2026
Merged

gh-80762: Fix dir() on MagicMock with tuple specs#12753
serhiy-storchaka merged 5 commits into
python:mainfrom
dsem:fix-issue-36581

Conversation

@dsem

@dsem dsem commented Apr 9, 2019

Copy link
Copy Markdown
Contributor

@the-knights-who-say-ni

Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

You can check yourself to see if the CLA has been received.

Thanks again for your contribution, we look forward to reviewing it!

@dsem
dsem force-pushed the fix-issue-36581 branch 2 times, most recently from c292b21 to e6878dd Compare April 9, 2019 23:53
@kushaldas

Copy link
Copy Markdown
Member

@dsem this PR needs update.

@matrixise

Copy link
Copy Markdown
Member

@brettcannon I can't change the CLA label and the CLA has been signed (checked on bpo).

@matrixise

Copy link
Copy Markdown
Member

@dsem There is a problem with your commit, you have used another user for your commit. You have committed with fp-dsem and not dsem. Could you fix this point, because without that, the CLA is not found and we can't merge it.

Also,

  • could you fix the issue with test_unittest?
  • update your PR with master?

Thank you

@dsem
dsem force-pushed the fix-issue-36581 branch from e6878dd to d67c29d Compare May 7, 2019 22:42
@dsem
dsem force-pushed the fix-issue-36581 branch 2 times, most recently from d6ad8f9 to 95aefc1 Compare May 7, 2019 23:29
@dsem

dsem commented May 7, 2019

Copy link
Copy Markdown
Contributor Author

Nice find about me using the wrong username. I believe I've addressed all the issues now.

Thanks!

@dsem
dsem force-pushed the fix-issue-36581 branch from 95aefc1 to 434d8d3 Compare May 7, 2019 23:50
@csabella csabella added the type-feature A feature request or enhancement label Jun 5, 2019
@github-actions

Copy link
Copy Markdown

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

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Sep 21, 2025
@bedevere-app

bedevere-app Bot commented Aug 11, 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.

@serhiy-storchaka serhiy-storchaka changed the title bpo-36581: Fix dir() on MagicMock with tuple specs gh-80762: Fix dir() on MagicMock with tuple specs Aug 12, 2026
Comment thread Lib/unittest/mock.py Outdated
Comment thread Lib/unittest/mock.py Outdated
Comment on lines +164 to +166
# checks for list, tuples, or sets
# XXXX badly named!
return type(obj) in (list, tuple)
return type(obj) in (list, tuple, set)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This change is unrelated to the original issue, and it is also breaking -- changes user visible behavior for spec=set(). If you need this change, open a new issue with separate discussion.

@bedevere-app

bedevere-app Bot commented Aug 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.

Accepting sets in _is_list() would change the meaning of a set *spec*
from mirroring a set object to a list of attribute names, and affect
also __class__, isinstance() and create_autospec().

A tuple *spec* has been supported since the initial import and is used
in tests, but it was never documented.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@serhiy-storchaka serhiy-storchaka removed the stale Stale PR or inactive for long period of time. label Aug 12, 2026
A tuple *spec* worked before, except in dir(), so this is a fix, not a
new feature.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34031832 | 📁 Comparing 0879591 against main (3d6a505)

  🔍 Preview build  

2 files changed
± library/unittest.mock.html
± whatsnew/changelog.html

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Updated documentation. Tuple of string is now officially supported. LGTM now.

@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) August 12, 2026 12:30
@serhiy-storchaka
serhiy-storchaka merged commit 38ce104 into python:main Aug 12, 2026
54 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants