]> granicus.if.org Git - python/commitdiff
Issue #6157: Fixed tkinter.Text.debug(). tkinter.Text.bbox() now raises
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 3 Nov 2013 12:34:25 +0000 (14:34 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 3 Nov 2013 12:34:25 +0000 (14:34 +0200)
TypeError instead of TclError on wrong number of arguments.  Original patch
by Guilherme Polo.

1  2 
Lib/tkinter/__init__.py
Lib/tkinter/test/test_tkinter/test_widgets.py
Misc/NEWS

index a9618b090ce232fd0f4bd055510a788ba9c56c16,9cb228429da9a169e149db4984e480fd76b55d07..22a41acc0da36b79087ab9f39086a317d32350f6
@@@ -2911,11 -2950,11 +2911,11 @@@ class Text(Widget, XView, YView)
  
          """
          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):
index 7b89c74f97e9d512ff7bcfbf8841cbe25e307196,1ed306a7ebb3f6d02226cfd3a894859e1361ac5c..e38fb3f88f62a0b8cc8273aeda4f54cfaec845b6
@@@ -610,6 -610,19 +610,19 @@@ class TextTest(AbstractWidgetTest, unit
          else:
              self.checkEnumParam(widget, 'wrap', 'char', 'none', 'word')
  
 -        self.assertRaises(tkinter.TclError, widget.bbox)
 -        self.assertRaises(tkinter.TclError, widget.bbox, '1.1', 'end')
+     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 --cc Misc/NEWS
index 661a6ddb0d2b46d506da0041a3491380d9db794c,26fc76cb721a92d7bc16d10b3611dcb5a52b1581..3c0e5117a40d399c02edf7089eda58e1003c378a
+++ b/Misc/NEWS
@@@ -25,38 -40,75 +25,42 @@@ Core and Builtin
  - Issue #18603: Ensure that PyOS_mystricmp and PyOS_mystrnicmp are in the
    Python executable and not removed by the linker's optimizer.
  
 -- Issue #19279: UTF-7 decoder no more produces illegal strings.
 -
 -- Fix macro expansion of _PyErr_OCCURRED(), and make sure to use it in at
 -  least one place so as to avoid regressions.
 -
 -- Issue #19014: memoryview.cast() is now allowed on zero-length views.
 -
 -- Issue #19098: Prevent overflow in the compiler when the recursion limit is set
 -  absurdly high.
 -
 -- Issue #18942: sys._debugmallocstats() output was damaged on Windows.
 -
 -- Issue #18667: Add missing "HAVE_FCHOWNAT" symbol to posix._have_functions.
 -
 -- Issue #18368: PyOS_StdioReadline() no longer leaks memory when realloc()
 -  fails.
 -
 -- Issue #16741: Fix an error reporting in int().
 -
 -- Issue #17899: Fix rare file descriptor leak in os.listdir().
 -
 -- Issue #18552: Check return value of PyArena_AddPyObject() in
 -  obj2ast_object().
 -
 -- Issue #18560: Fix potential NULL pointer dereference in sum().
 -
 -- Issue #15905: Fix theoretical buffer overflow in handling of sys.argv[0],
 -  prefix and exec_prefix if the operation system does not obey MAXPATHLEN.
 -
 -- Issue #18344: Fix potential ref-leaks in _bufferedreader_read_all().
 -
 -- Issue #17872: Fix a segfault in marshal.load() when input stream returns
 -  more bytes than requested.
 +- Issue #19306: Add extra hints to the faulthandler module's stack
 +  dumps that these are "upside down".
  
 -- Issue #18426: Fix NULL pointer dereference in C extension import when
 -  PyModule_GetDef() returns an error.
 +Library
 +-------
  
 -- Issue #18328: Reorder ops in PyThreadState_Delete*() functions. Now the
 -  tstate is first removed from TLS and then deallocated.
++- Issue #6157: Fixed tkinter.Text.debug().  tkinter.Text.bbox() now raises
++  TypeError instead of TclError on wrong number of arguments.  Original patch
++  by Guilherme Polo.
 -- Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise
 -  OverflowError when an argument of %c format is out of range.
 +- Issue #6160: The bbox() method of tkinter.Spinbox now returns a tuple of
 +  integers instead of a string.  Based on patch by Guilherme Polo.
  
 -- Issue #18137: Detect integer overflow on precision in float.__format__()
 -  and complex.__format__().
 +- Issue #19403: contextlib.redirect_stdout is now reentrant
  
 -- Issue #18183: Fix various unicode operations on strings with large unicode
 -  codepoints.
 +- Issue #19286: Directories in ``package_data`` are no longer added to
 +  the filelist, preventing failure outlined in the ticket.
  
 -- Issue #18180: Fix ref leak in _PyImport_GetDynLoadWindows().
 +- Issue #15114: The html.parser module now raises a DeprecationWarning when the
 +  strict argument of HTMLParser or the HTMLParser.error method are used.
  
 -- Issue #18038: SyntaxError raised during compilation sources with illegal
 -  encoding now always contains an encoding name.
 +- Issue #19410: Undo the special-casing removal of '' for
 +  importlib.machinery.FileFinder.
  
 -- Issue #17644: Fix a crash in str.format when curly braces are used in square
 -  brackets.
 +- Issue #19424: Fix the warnings module to accept filename containing surrogate
 +  characters.
  
 -- Issue #17983: Raise a SyntaxError for a ``global __class__`` statement in a
 -  class body.
 +- Issue #19435: Fix directory traversal attack on CGIHttpRequestHandler.
  
 -- Issue #17927: Frame objects kept arguments alive if they had been copied into
 -  a cell, even if the cell was cleared.
 +- Issue #19227: Remove pthread_atfork() handler. The handler was added to
 +  solve #18747 but has caused issues.
  
 -Library
 --------
 +- Issue #19420: Fix reference leak in module initalization code of
 +  _hashopenssl.c
  
 -- Issue #19395: Raise an exception when attempting to pickle a bz2 or lzma
 -  compressor/decompressor object, rather than creating a pickle that would
 -  cause a segfault when loaded and used.
 +- Issue #19329: Optimized compiling charsets in regular expressions.
  
  - Issue #19227: Try to fix deadlocks caused by re-seeding then OpenSSL
    pseudo-random number generator on fork().