Bug 281751 - python crashes when sending an empty string to some Tkinter widgets
Summary: python crashes when sending an empty string to some Tkinter widgets
Alias: None
Product: Fedora
Classification: Fedora
Component: python
Version: 7
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: James Antill
QA Contact: Fedora Extras Quality Assurance
Depends On:
Blocks: F8Target 312701
TreeView+ depends on / blocked
Reported: 2007-09-07 01:31 UTC by Stephen P. Schaefer
Modified: 2007-11-30 22:12 UTC (History)
5 users (show)

Fixed In Version: 2.5-14.fc7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2007-10-29 19:03:20 UTC
Type: ---

Attachments (Terms of Use)

Description Stephen P. Schaefer 2007-09-07 01:31:42 UTC
Description of problem:

Python exits with the following error:

python: ./Modules/_tkinter.c:941: AsObj: Assertion `size < size *
sizeof(Tcl_UniChar)' failed.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. Put the following script in t.py:
# -*- coding: utf-8 -*-
import sys, Tkinter, unicodedata
reload(sys)                              # restore module sys from disk
sys.setdefaultencoding('utf-8')    # or whatever codec you need
del sys.setdefaultencoding               # ensure against later accidents
Tkinter.Button(text=u"", command=sys.exit).pack( )
Tkinter.mainloop( )

2. run the program as: python t.py
Actual results:

python: ./Modules/_tkinter.c:941: AsObj: Assertion `size < size *
sizeof(Tcl_UniChar)' failed.

Expected results:

A button window containing no text.

Additional info:

Comment 1 Stephen P. Schaefer 2007-09-07 01:35:49 UTC
The script contains some extra cruft.  This simplification also generates the error:

import sys, Tkinter
Tkinter.Button(text=u"", command=sys.exit).pack( )
Tkinter.mainloop( )

Comment 2 Stewart Adam 2007-10-07 22:02:55 UTC
I can confirm this with python/tkinter tkinter-2.5.1-11.fc8.

Is this problem easy to fix? It's preventing pysol (bug 312701) from running

Comment 3 Stewart Adam 2007-10-07 22:05:04 UTC
I forgot to mention, this bug is not present when manually compiling Python:

Probably something we are passing to %configure or a patch is introducing the bug.

Comment 4 Stephen P. Schaefer 2007-10-18 20:44:41 UTC
The bug is present in multiple other widgets.  For instance,

import sys, Tkinter
Tkinter.Text(text=u"").pack( )
Tkinter.mainloop( )

Comment 5 Stephen P. Schaefer 2007-10-18 23:33:15 UTC
Here's a patch, which I've also supplied to bugs.python.org:

--- Python-2.5-fc7/Modules/_tkinter.c   2006-08-11 22:33:36.000000000 -0400
+++ Python-2.5/Modules/_tkinter.c       2007-10-18 18:44:40.000000000 -0400
@@ -938,7 +938,7 @@
 #if defined(Py_UNICODE_WIDE) && TCL_UTF_MAX == 3
                Tcl_UniChar *outbuf;
                Py_ssize_t i;
-               assert(size < size * sizeof(Tcl_UniChar));
+               assert(size == 0 || size < size * sizeof(Tcl_UniChar));
                outbuf = (Tcl_UniChar*)ckalloc(size * sizeof(Tcl_UniChar));
                if (!outbuf) {

Comment 6 James Antill 2007-10-19 16:15:09 UTC
 This should now be fixed, please test.

Comment 7 Jason Tibbitts 2007-10-19 20:19:19 UTC
I didn't see anything in bodhi about this so I pulled the packages from koji
(http://koji.fedoraproject.org/koji/buildinfo?buildID=21649) and update; pysol
at least works without problems now.

Could this fix please make it into F8?  There may still be time to slide it in
before the absolute freeze.

Comment 8 Jason Tibbitts 2007-10-21 18:25:02 UTC
It seems that it's just not that easy to find pending updates in bodhi because
there are a bunch of hits on python and the result list is neither sorted nor
sortable.  The update is at
I've commented there.

Comment 9 Stephen P. Schaefer 2007-10-22 15:17:52 UTC
I didn't know where to find the changed version until comment #7.  The URL in
comment #8 refused my credentials.  Now that I've installed *-2.5-14.fc7*,
things are working fine for me.  If there is a specified testing regimen I
should follow, please give a URL for that.  Thanks.

Comment 10 Warren Togami 2007-10-22 15:50:50 UTC
We need this fix in F8 as well.

Comment 11 Fedora Update System 2007-10-24 07:17:38 UTC
python-2.5-14.fc7 has been pushed to the Fedora 7 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update python'

Comment 12 Kevin J. Cummings 2007-10-24 21:35:42 UTC
# yum --enablerepo=updates-testing update python
google                    100% |=========================|  951 B    00:00     
fedora                    100% |=========================| 2.1 kB    00:00     
updates-testing           100% |=========================| 2.3 kB    00:00     
primary.sqlite.bz2        100% |=========================| 141 kB    00:00     
updates                   100% |=========================| 2.3 kB    00:00     
adobe-linux-i386          100% |=========================|  951 B    00:00     
Setting up Update Process
Could not find update match for python
No Packages marked for Update

Comment 13 Fedora Update System 2007-10-29 19:03:15 UTC
python-2.5-14.fc7 has been pushed to the Fedora 7 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.