Skip to content

gh-141218: Fix inaccurate object comparison documentation#141221

Merged
hugovk merged 3 commits intopython:mainfrom
mohsinm-dev:fix-gh-141218-object-comparison-docs
Dec 16, 2025
Merged

gh-141218: Fix inaccurate object comparison documentation#141221
hugovk merged 3 commits intopython:mainfrom
mohsinm-dev:fix-gh-141218-object-comparison-docs

Conversation

@mohsinm-dev
Copy link
Copy Markdown
Contributor

@mohsinm-dev mohsinm-dev commented Nov 8, 2025

Summary

Fixes issue #141218 by correcting inaccurate documentation about object comparison.

Problem: The current documentation states "Objects of different types, except different numeric types, never compare equal" which is factually incorrect.

Counter-example:

>>> frozenset([1, 2]) == {1, 2}
True

Solution: Changed to "Objects of different types, unless documented otherwise, never compare equal" to account for all documented exceptions.

Documented exceptions include:

  • Numeric types (int, float, complex) - already mentioned
  • set/frozenset comparisons - documented later in same file
  • dict subclass comparisons (defaultdict, Counter, OrderedDict)

Changes

  • Updated Doc/library/stdtypes.rst line 167
  • Added news entry in Misc/NEWS.d/next/Documentation/

Test plan

  • Documentation builds successfully with make html
  • Verified change maintains consistency with existing specific type documentation
  • Tested that the issue examples work as described
  • Confirmed change is minimal and maintains readability

The fix improves documentation accuracy while maintaining clarity and consistency.


📚 Documentation preview 📚: https://cpython-previews--141221.org.readthedocs.build/

Changed "Objects of different types, except different numeric types, never
compare equal" to "Objects of different types, unless documented otherwise,
never compare equal" to account for documented exceptions like set/frozenset
comparisons.
@python-cla-bot
Copy link
Copy Markdown

python-cla-bot bot commented Nov 8, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@skirpichev
Copy link
Copy Markdown
Member

I suggest just revert news. Its usually not required for docs changes.

@skirpichev skirpichev added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Nov 10, 2025
Co-authored-by: Bénédikt Tran <[email protected]>
@hugovk hugovk merged commit b372bd7 into python:main Dec 16, 2025
32 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Dec 16, 2025
@miss-islington-app
Copy link
Copy Markdown

Thanks @mohsinm-dev for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 16, 2025
…onGH-141221)

(cherry picked from commit b372bd7)

Co-authored-by: Mohsin Mehmood <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 16, 2025
…onGH-141221)

(cherry picked from commit b372bd7)

Co-authored-by: Mohsin Mehmood <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
@bedevere-app
Copy link
Copy Markdown

bedevere-app bot commented Dec 16, 2025

GH-142810 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Dec 16, 2025
@bedevere-app
Copy link
Copy Markdown

bedevere-app bot commented Dec 16, 2025

GH-142811 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Dec 16, 2025
hugovk pushed a commit that referenced this pull request Dec 16, 2025
hugovk pushed a commit that referenced this pull request Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants