Issue 3835: tkinter goes into an infinite loop (pydoc.gui) (original) (raw)

Created on 2008-09-11 13:20 by HWJ, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue_3835.diff gpolo,2008-09-17 13:08 review
issue_3835_2.diff asvetlov,2012-03-13 18:15 review
Messages (15)
msg73021 - (view) Author: Helmut Jarausch (HWJ) Date: 2008-09-11 13:20
With version 3.0 (SVN 66386) import pydoc pydoc.gui() gives >>> Exception in thread Thread-1: Traceback (most recent call last): File "/usr/local/lib/python3.0/threading.py", line 507, in _bootstrap_inner self.run() File "/usr/local/lib/python3.0/threading.py", line 462, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.0/pydoc.py", line 1989, in serve DocServer(port, callback).serve_until_quit() File "/usr/local/lib/python3.0/pydoc.py", line 1971, in __init__ self.base.__init__(self, self.address, self.handler) File "/usr/local/lib/python3.0/socketserver.py", line 401, in __init__ self.server_activate() File "/usr/local/lib/python3.0/pydoc.py", line 1982, in server_activate if self.callback: self.callback(self) File "/usr/local/lib/python3.0/pydoc.py", line 2072, in ready text='Python documentation server at\n' + server.url) File "/usr/local/lib/python3.0/tkinter/__init__.py", line 1199, in configure return self._configure('configure', cnf, kw) File "/usr/local/lib/python3.0/tkinter/__init__.py", line 1190, in _configure self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) _tkinter.TclError: out of stack space (infinite loop?)
msg73237 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2008-09-14 21:33
What tcl/tk version are you using ? Also, can you put a "print(_flatten((self._w, cmd)) + self._options(cnf))" before the line 1190 in /usr/local/lib/python3.0/tkinter/__init__.py and tell what it shows when you call pydoc.gui ?
msg73259 - (view) Author: Helmut Jarausch (HWJ) Date: 2008-09-15 12:50
I'm using Tcl/Tk 8.5.4 here print(":::") print(_flatten((self._w, cmd)) + self._options(cnf)) produces: ::: ('.3073836300', 'configure', '-yscrollcommand', '3077632332set') ::: ('.3073835564.3073835660', 'configure', '-text', 'Python documentation server at\nhttp://localhost:7464/') >>> Exception in thread Thread-1: Traceback (most recent call last): File "/usr/local/lib/python3.0/threading.py", line 507, in _bootstrap_inner self.run() File "/usr/local/lib/python3.0/threading.py", line 462, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.0/pydoc.py", line 1989, in serve DocServer(port, callback).serve_until_quit() File "/usr/local/lib/python3.0/pydoc.py", line 1971, in __init__ self.base.__init__(self, self.address, self.handler) File "/usr/local/lib/python3.0/socketserver.py", line 401, in __init__ self.server_activate() File "/usr/local/lib/python3.0/pydoc.py", line 1982, in server_activate if self.callback: self.callback(self) File "/usr/local/lib/python3.0/pydoc.py", line 2072, in ready text='Python documentation server at\n' + server.url) File "/usr/local/lib/python3.0/tkinter/__init__.py", line 1201, in configure return self._configure('configure', cnf, kw) File "/usr/local/lib/python3.0/tkinter/__init__.py", line 1192, in _configure self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) _tkinter.TclError: out of stack space (infinite loop?)
msg73265 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2008-09-15 15:29
Uhm, is it caused only by the combination of tk 8.5.4 and py3k, or does the same happen with tk 8.5.4 and python-trunk ? What about tk 8.5.3 (or some other of tk 8.5 series) or even tk 8.4.16 and {python-trunk, py3k} ? It would be good if you could test some other combination, specially because I can't reproduce it here with other versions (but I'm compiling 8.5.4 here now).
msg73302 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2008-09-16 15:18
Just reproduced the issue under python-trunk with tcl/tk 8.5.4 and 8.5.3
msg73303 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2008-09-16 15:41
But it happens only if you don't build tcl/tk with --enable-threads =)
msg73304 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2008-09-16 17:00
If you remove the widget.config calls in GUI.ready you will notice the problem "goes away", but note that this method is called from another thread while you have a non-thread-safe tcl/tk lib (I'm assuming you didn't compile it with --enable-threads). So.. using multiple threads in Python while Tcl is compiled without --enable-threads isn't supported at all. To reproduce the problem try this (change Tkinter to tkinter if py3k): import threading import Tkinter lbl = Tkinter.Label(text="hi") threading.Thread(target=lambda: lbl.configure(text="hi there")).start() lbl.mainloop() If your tcl/tk libs weren't compiled with --enable-threads this should get you an "TclError: out of stack space (infinite loop?)". A documentation note may be added somewhere, but nothing much else is going to happen (that is what I believe at least).
msg73324 - (view) Author: Helmut Jarausch (HWJ) Date: 2008-09-17 08:07
Many thanks, that solved the problem. Since the cause of the problem wasn't easy to find out (for me, at least) would be possible to check at import time if Tcl/Tk has been configured with threads enabled? Helmut.
msg73332 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2008-09-17 13:08
The patch attached checks for that when an interpreter is created, not really at import time but should be enough. But my real concern is that tkinter thinks it will work properly when Python is using threads and Tcl wasn't compiled with --enable-threads. Maybe that was true some time ago or maybe in other platforms, but isn't the case anymore.
msg155640 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-03-13 18:15
Push updated patch for tip (3.3) head
msg155664 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-03-13 20:59
New changeset d731dcda2611 by Martin v. Löwis in branch 'default': Issue #3835: Refuse to use unthreaded Tcl in threaded Python. http://hg.python.org/cpython/rev/d731dcda2611
msg155665 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2012-03-13 21:00
Thanks for the patch!
msg155763 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-03-14 16:40
New changeset 7cbc48324938 by Andrew Svetlov in branch 'default': Revert the patch for issue 3835 because failed on Windows buildbot http://hg.python.org/cpython/rev/7cbc48324938
msg155764 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-03-14 16:43
Recall to 'open' state
msg155765 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-03-14 16:50
Close as 'not a bug' because Guilherme's test to reproduce the bug from works good at least for Linux. Windows version of Tcl/Tk compiled without threading support. So current behavior is correct and should not to be fixed.
History
Date User Action Args
2022-04-11 14:56:39 admin set github: 48085
2012-03-14 16:50:16 asvetlov set status: open -> closedresolution: rejectedmessages: +
2012-03-14 16:43:09 asvetlov set status: closed -> openresolution: fixed -> (no value)messages: +
2012-03-14 16:40:18 python-dev set messages: +
2012-03-13 21:00:09 loewis set status: open -> closednosy: + loewismessages: + resolution: fixed
2012-03-13 20:59:23 python-dev set nosy: + python-devmessages: +
2012-03-13 18:15:54 asvetlov set files: + issue_3835_2.diffnosy: + asvetlovmessages: +
2011-02-04 00:08:25 eric.araujo set nosy:gpolo, HWJcomponents: + Tkinterversions: + Python 3.3, - Python 3.0
2008-09-17 13:10:11 gpolo set priority: normal
2008-09-17 13:08:48 gpolo set files: + issue_3835.diffkeywords: + patchmessages: +
2008-09-17 08:07:43 HWJ set messages: +
2008-09-16 17:00:02 gpolo set messages: +
2008-09-16 15:41:20 gpolo set messages: +
2008-09-16 15🔞44 gpolo set messages: +
2008-09-15 15:29:26 gpolo set messages: +
2008-09-15 12:50:48 HWJ set messages: +
2008-09-14 21:33:52 gpolo set nosy: + gpolomessages: +
2008-09-11 13:20:28 HWJ create