Skip to content

gh-97928: Partially restore the behavior of tkinter.Text.count() by default #115031

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

Merged

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Feb 5, 2024

By default, it preserves an inconsistent behavior of older Python versions: packs the count into a 1-tuple if only one or none options are specified (including 'update').
Except that setting wantobjects to 0 no longer affects the result.

Add a new parameter return_ints: specifying return_ints=True makes Text.count() returning the single count as an integer.


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

@serhiy-storchaka serhiy-storchaka changed the title gh-98484: Partially restore the behavior of tkinter.Text.count() by default gh-97928: Partially restore the behavior of tkinter.Text.count() by default Feb 5, 2024
@serhiy-storchaka serhiy-storchaka force-pushed the tkinter-text-count-return_ints branch from 9f6e1db to 26aea45 Compare February 5, 2024 17:00
…) by default

By default, it preserves an inconsistent behavior of older Python
versions: packs the count into a 1-tuple if only one or none
options are specified (including 'update'), returns None instead of 0.
Except that setting wantobjects to 0 no longer affects the result.

Add a new parameter return_ints: specifying return_ints=True makes
Text.count() always returning the single count as an integer
insteaf of a 1-tuple or None.
@serhiy-storchaka serhiy-storchaka force-pushed the tkinter-text-count-return_ints branch from 26aea45 to e44adec Compare February 5, 2024 17:01
Copy link
Member

@terryjreedy terryjreedy left a comment

Choose a reason for hiding this comment

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

Looks ok with an optional comment deletion and two questions. EDIT Sufficiently answered.
The added tests look correct.

@serhiy-storchaka serhiy-storchaka merged commit d2c4baa into python:main Feb 11, 2024
@serhiy-storchaka serhiy-storchaka deleted the tkinter-text-count-return_ints branch February 11, 2024 10:43
fsc-eriker pushed a commit to fsc-eriker/cpython that referenced this pull request Feb 14, 2024
…) by default (pythonGH-115031)

By default, it preserves an inconsistent behavior of older Python
versions: packs the count into a 1-tuple if only one or none
options are specified (including 'update'), returns None instead of 0.
Except that setting wantobjects to 0 no longer affects the result.

Add a new parameter return_ints: specifying return_ints=True makes
Text.count() always returning the single count as an integer
instead of a 1-tuple or None.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants