Skip to content
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

bpo-34936: Fix TclError in tkinter.Spinbox.selection_element() #9760

Merged
merged 7 commits into from Oct 18, 2018

Conversation

j4321
Copy link
Contributor

@j4321 j4321 commented Oct 8, 2018

Spinbox.selection_element() raises TclError: expected integer but got "none" while it should return the currently selected element according to the docstring.

  • I removed the call to self._getints in Spinbox.selection since the result is never a string of integers. For consistency with the previous behavior, Spinbox.selection still returns () when the result of self.tk.call((self._w, 'selection') + args) is an empty string.
  • I added tests for the Spinbox.selection_element method.

https://bugs.python.org/issue34936

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

I suggest to inline this method. It doesn't do something that deserves moving to a special method.

@j4321
Copy link
Contributor Author

j4321 commented Oct 12, 2018

@serhiy-storchaka I am not sure I understand what you mean. Should I just not use selection() in selection_element() and undo my changes of selection()?

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Oct 12, 2018

I suggest to use self.tk.call() in selection_element(). And maybe in other methods.

By the way, docstrings of some selection_* methods (containing "Returns an empty string.") are not correct.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

LGTM. Just added few nitpicks.

@@ -3750,25 +3750,25 @@ def selection_adjust(self, index):
select to commands. If the selection isn't currently in
the spinbox, then a new selection is created to include
the characters between index and the most recent selection
anchor point, inclusive. Returns an empty string.
anchor point, inclusive. Returns an empty tuple.
Copy link
Member

@serhiy-storchaka serhiy-storchaka Oct 18, 2018

Choose a reason for hiding this comment

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

I suggest just deleting the last sentence. It is not particularly useful.

Lib/tkinter/test/test_tkinter/test_widgets.py Show resolved Hide resolved
@@ -522,6 +522,9 @@ def test_selection_methods(self):
self.assertEqual(widget.selection_get(), '2345')
widget.selection_adjust(0)
self.assertEqual(widget.selection_get(), '12345')

def test_selection_element_methods(self):
Copy link
Member

@serhiy-storchaka serhiy-storchaka Oct 18, 2018

Choose a reason for hiding this comment

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

Just test_selection_element.

@miss-islington
Copy link
Contributor

miss-islington commented Oct 18, 2018

Thanks @j4321 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6.
🐍🍒🤖

@miss-islington
Copy link
Contributor

miss-islington commented Oct 18, 2018

Thanks @j4321 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7.
🐍🍒🤖

@miss-islington
Copy link
Contributor

miss-islington commented Oct 18, 2018

Thanks @j4321 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒🤖

@miss-islington
Copy link
Contributor

miss-islington commented Oct 18, 2018

Sorry, @j4321 and @serhiy-storchaka, I could not cleanly backport this to 3.6 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 1deea5e53991b46351f6bb395b22365c9455ed88 3.6

@miss-islington
Copy link
Contributor

miss-islington commented Oct 18, 2018

Sorry, @j4321 and @serhiy-storchaka, I could not cleanly backport this to 3.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 1deea5e53991b46351f6bb395b22365c9455ed88 3.7

@miss-islington
Copy link
Contributor

miss-islington commented Oct 18, 2018

Sorry, @j4321 and @serhiy-storchaka, I could not cleanly backport this to 2.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 1deea5e53991b46351f6bb395b22365c9455ed88 2.7

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Oct 18, 2018

Oh, conflicts. I suppose this is because of new methods and tests added in master only. Do you mind to backport this PR to the 3.7 branch @j4321? Then I think it will be possible to backport it from 3.7 to 3.6 automatically.

@j4321
Copy link
Contributor Author

j4321 commented Oct 18, 2018

@serhiy-storchaka I am not sure about what I am supposed to do. I just know that the backport pull request should be named "[3.7] bpo-34936: Fix TclError in tkinter.Spinbox.selection_element()(GH-9760)"

@bedevere-bot
Copy link

bedevere-bot commented Oct 18, 2018

GH-9957 is a backport of this pull request to the 3.7 branch.

CuriousLearner added a commit to CuriousLearner/cpython that referenced this pull request Oct 18, 2018
* master: (621 commits)
  Update opcode.h header comment to mention the source data file (pythonGH-9935)
  bpo-34936: Fix TclError in tkinter.Spinbox.selection_element(). (pythonGH-9760)
  Updated documentation on logging.debug(). (pythonGH-9946)
  bpo-34765: Update the install-sh file (pythonGH-9592)
  bpo-35008: Fix possible leaks in Element.__setstate__(). (pythonGH-9924)
  bpo-35011: Restore use of pyexpatns.h in libexpat (pythonGH-9939)
  bpo-24658: Fix read/write greater than 2 GiB on macOS (pythonGH-1705)
  Add missing comma to wsgiref doc (pythonGH-9932)
  bpo-23420: Verify the value of '-s' when execute the CLI of cProfile (pythonGH-9925)
  Doc: Fix is_prime (pythonGH-9909)
  In email docs, correct spelling of foregoing (python#9856)
  In email.parser in message_from_bytes, update `strict` to `policy` (python#9854)
  bpo-34997: Fix test_logging.ConfigDictTest.test_out_of_order (pythonGH-9913)
  Added CLI starter example to logging cookbook. (pythonGH-9910)
  bpo-34783: Fix test_nonexisting_script() (pythonGH-9896)
  bpo-23554: Change echo server example class name from EchoServerClientProtocol to EchoServerProtocol (pythonGH-9859)
  bpo-34989: python-gdb.py: fix current_line_num() (pythonGH-9889)
  Stop using deprecated logging API in Sphinx suspicious checker (pythonGH-9875)
  fix dangling keyfunc examples in documentation of heapq and sorted (python#1432)
  bpo-34844: logging.Formatter enhancement - Ensure style and format string matches in logging.Formatter  (pythonGH-9703)
  ...
CuriousLearner added a commit to CuriousLearner/cpython that referenced this pull request Oct 18, 2018
* master: (1787 commits)
  Update opcode.h header comment to mention the source data file (pythonGH-9935)
  bpo-34936: Fix TclError in tkinter.Spinbox.selection_element(). (pythonGH-9760)
  Updated documentation on logging.debug(). (pythonGH-9946)
  bpo-34765: Update the install-sh file (pythonGH-9592)
  bpo-35008: Fix possible leaks in Element.__setstate__(). (pythonGH-9924)
  bpo-35011: Restore use of pyexpatns.h in libexpat (pythonGH-9939)
  bpo-24658: Fix read/write greater than 2 GiB on macOS (pythonGH-1705)
  Add missing comma to wsgiref doc (pythonGH-9932)
  bpo-23420: Verify the value of '-s' when execute the CLI of cProfile (pythonGH-9925)
  Doc: Fix is_prime (pythonGH-9909)
  In email docs, correct spelling of foregoing (python#9856)
  In email.parser in message_from_bytes, update `strict` to `policy` (python#9854)
  bpo-34997: Fix test_logging.ConfigDictTest.test_out_of_order (pythonGH-9913)
  Added CLI starter example to logging cookbook. (pythonGH-9910)
  bpo-34783: Fix test_nonexisting_script() (pythonGH-9896)
  bpo-23554: Change echo server example class name from EchoServerClientProtocol to EchoServerProtocol (pythonGH-9859)
  bpo-34989: python-gdb.py: fix current_line_num() (pythonGH-9889)
  Stop using deprecated logging API in Sphinx suspicious checker (pythonGH-9875)
  fix dangling keyfunc examples in documentation of heapq and sorted (python#1432)
  bpo-34844: logging.Formatter enhancement - Ensure style and format string matches in logging.Formatter  (pythonGH-9703)
  ...
serhiy-storchaka pushed a commit to serhiy-storchaka/cpython that referenced this pull request Oct 19, 2018
…pythonGH-9760).

(cherry picked from commit 1deea5e)

Co-authored-by: Juliette Monsel <j4321@users.noreply.github.com>
serhiy-storchaka pushed a commit that referenced this pull request Oct 19, 2018
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 19, 2018
…onGH-9760) (pythonGH-9957)

(cherry picked from commit 1deea5e)
(cherry picked from commit bd9c2ce)

Co-authored-by: Juliette Monsel <j4321@users.noreply.github.com>
miss-islington added a commit that referenced this pull request Oct 19, 2018
) (GH-9957)

(cherry picked from commit 1deea5e)
(cherry picked from commit bd9c2ce)

Co-authored-by: Juliette Monsel <j4321@users.noreply.github.com>
serhiy-storchaka pushed a commit to serhiy-storchaka/cpython that referenced this pull request Oct 19, 2018
…pythonGH-9760) (pythonGH-9957)

(cherry picked from commit 1deea5e).
(cherry picked from commit bd9c2ce)

Co-authored-by: Juliette Monsel <j4321@users.noreply.github.com>
serhiy-storchaka added a commit that referenced this pull request Oct 21, 2018
…GH-9760) (GH-9957) (GH-9968)

(cherry picked from commit 1deea5e).
(cherry picked from commit bd9c2ce)

Co-authored-by: Juliette Monsel <j4321@users.noreply.github.com>
@serhiy-storchaka serhiy-storchaka removed their assignment Oct 28, 2018
yahya-abou-imran pushed a commit to yahya-abou-imran/cpython that referenced this pull request Nov 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants