diff -r f647a2c5f290 Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py Sat Nov 02 10:54:58 2013 +0200 +++ b/Lib/tkinter/__init__.py Sat Nov 02 11:51:51 2013 +0200 @@ -2911,11 +2911,11 @@ """ Widget.__init__(self, master, 'text', cnf, kw) - def bbox(self, *args): + def bbox(self, index): """Return a tuple of (x,y,width,height) which gives the bounding - box of the visible part of the character at the index in ARGS.""" + box of the visible part of the character at the given index.""" return self._getints( - self.tk.call((self._w, 'bbox') + args)) or None + self.tk.call(self._w, 'bbox', index)) or None def tk_textSelectTo(self, index): self.tk.call('tk_textSelectTo', self._w, index) def tk_textBackspace(self): @@ -2951,8 +2951,9 @@ def debug(self, boolean=None): """Turn on the internal consistency checks of the B-Tree inside the text widget according to BOOLEAN.""" - return self.tk.getboolean(self.tk.call( - self._w, 'debug', boolean)) + if boolean is None: + return self.tk.call(self._w, 'debug') + self.tk.call(self._w, 'debug', boolean) def delete(self, index1, index2=None): """Delete the characters between INDEX1 and INDEX2 (not included).""" self.tk.call(self._w, 'delete', index1, index2) @@ -3035,19 +3036,19 @@ then. Generates an error when the redo stack is empty. Does nothing when the undo option is false. """ - return self.edit("redo") + self.edit("redo") def edit_reset(self): """Clears the undo and redo stacks """ - return self.edit("reset") + self.edit("reset") def edit_separator(self): """Inserts a separator (boundary) on the undo stack. Does nothing when the undo option is false """ - return self.edit("separator") + self.edit("separator") def edit_undo(self): """Undoes the last edit action @@ -3058,7 +3059,7 @@ an error when the undo stack is empty. Does nothing when the undo option is false """ - return self.edit("undo") + self.edit("undo") def get(self, index1, index2=None): """Return the text from INDEX1 to INDEX2 (not included).""" diff -r f647a2c5f290 Lib/tkinter/test/test_tkinter/test_text.py --- a/Lib/tkinter/test/test_tkinter/test_text.py Sat Nov 02 10:54:58 2013 +0200 +++ b/Lib/tkinter/test/test_tkinter/test_text.py Sat Nov 02 11:51:51 2013 +0200 @@ -14,6 +14,17 @@ def tearDown(self): self.text.destroy() + def test_debug(self): + text = self.text + olddebug = text.debug() + try: + text.debug(0) + self.assertEqual(text.debug(), 0) + text.debug(1) + self.assertEqual(text.debug(), 1) + finally: + text.debug(olddebug) + self.assertEqual(text.debug(), olddebug) def test_search(self): text = self.text diff -r f647a2c5f290 Lib/tkinter/test/test_tkinter/test_widgets.py --- a/Lib/tkinter/test/test_tkinter/test_widgets.py Sat Nov 02 10:54:58 2013 +0200 +++ b/Lib/tkinter/test/test_tkinter/test_widgets.py Sat Nov 02 11:51:51 2013 +0200 @@ -598,6 +598,19 @@ else: self.checkEnumParam(widget, 'wrap', 'char', 'none', 'word') + def test_bbox(self): + widget = self.create() + bbox = widget.bbox('1.1') + self.assertEqual(len(bbox), 4) + for item in bbox: + self.assertIsInstance(item, int) + + self.assertIsNone(widget.bbox('end')) + self.assertRaises(tkinter.TclError, widget.bbox, 'noindex') + self.assertRaises(tkinter.TclError, widget.bbox, None) + self.assertRaises(TypeError, widget.bbox) + self.assertRaises(TypeError, widget.bbox, '1.1', 'end') + @add_standard_options(PixelSizeTests, StandardOptionsTests) class CanvasTest(AbstractWidgetTest, unittest.TestCase): diff -r f647a2c5f290 Misc/NEWS --- a/Misc/NEWS Sat Nov 02 10:54:58 2013 +0200 +++ b/Misc/NEWS Sat Nov 02 11:51:51 2013 +0200 @@ -31,6 +31,9 @@ Library ------- +- Issue #6157: Fixed tkinter.Text.debug() and cleaned up tkinter.Text. + Original patch by Guilherme Polo. + - Issue #19410: Undo the special-casing removal of '' for importlib.machinery.FileFinder.