This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Text search gives bad count if called from variable trace
Type: Stage:
Components: Tkinter Versions: Python 3.0, Python 3.1, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gpolo Nosy List: gpolo, loewis, mkiever, reowen
Priority: normal Keywords: patch

Created on 2006-10-20 19:26 by reowen, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
text search bug.py reowen, 2006-10-20 19:26 Script to demonstrate the problem
issue_1581476.diff gpolo, 2009-01-02 22:35
Messages (9)
msg30329 - (view) Author: Russell Owen (reowen) Date: 2006-10-20 19:26
If Text search is called from a variable trace then the count variable is 
not be updated.

I see this with Python 2.4.3 and Aqua Tcl/Tk 8.4.11 on MacOS X 10.4.7. 
I have not tested it elsewhere.

Note that this works fine in tcl/tk so this appears to be a Tkinter issue.

To see the problem run the attached python script.

(The script also includes the equivalent tcl/tk code in its comments, so 
you can easily test the issue directly in tcl/tk if desired.)
msg30330 - (view) Author: Matthias Kievernagel (mkiever) * Date: 2007-01-19 20:50
Same behaviour on Linux and current Python trunk.
In addition I get an IndexError, if I delete the
last character of the search string.
Does Tk allow calling search with an empty pattern?

Tkinter could handle this (with a correct result)
with the following change in Tkinter.py / Text.search():

if pattern[0] == '-': args.append('--')
->
if pattern and pattern[0] == '-': args.append('--')

Greetings,
Matthias Kievernagel
msg76861 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2008-12-04 01:22
This is indeed a problem with Tkinter only, but I didn't check what is
causing it yet.

For the suggestion about fixing the search method regarding the pattern:
the fix is almost fine, but we need to disallow None as a pattern.
msg76881 - (view) Author: Matthias Kievernagel (mkiever) * Date: 2008-12-04 13:05
Nice to see someone working on this.
One thing I've checked (iirc):
You can set iVar in doSearch by hand like this:
    iVar.set(2)
    print 'iVar.get()', iVar.get()
And iVar rests at this value.
t.search does not change the value.

I don't know anything about how the tcl-interpreter
is embedded into python. I somehow had the impression
there might be a _tkinter limitation there.
Something like handling two callbacks into _tkinter
at the same time or the tcl interpreter being unresponsive
while calling a _tkinter function.
At that point I gave up. Seen nothing obvious in _tkinter/Tkinter.

Matthias Kievernagel
(mkiever/at/web/dot/de)
msg78895 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-01-02 22:35
Fixed the issue now.
_tkinter.call needs to use the TCL_EVAL_GLOBAL flag since all the
variables in Tkinter are global variables.

Matthias: your issue about the pattern should be placed in a different
issue.
msg79460 - (view) Author: Matthias Kievernagel (mkiever) * Date: 2009-01-09 10:27
>Matthias: your issue about the pattern should be placed in a 
>different
>issue.

Done as Issue4890.
Appended a simplified copy of the demo program
and a patch there. I do not understand your remark
about None though (see new issue).

Cheers,
Matthias Kievernagel
mkiever/at/web/dot/de
msg80944 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-02-02 15:47
The patch looks fine, please apply.

We should come up with a deprecation strategy for GlobalCall, though,
since that function is now mostly redundant.
msg80980 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-02-02 18:40
Uhm, is it fine to remove it for good in 3.1 ? And then add a warning in
2.7 when it gets called which in turns just call Tkapp_Call ?
msg80999 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-02-02 21:26
Commited in r69217 (r69219), r69220, r69222, r69223

Martin, I will open another ticket about GlobalCall deprecation, later
today.
History
Date User Action Args
2022-04-11 14:56:20adminsetgithub: 44153
2009-02-02 21:26:19gpolosetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg80999
2009-02-02 18:40:27gpolosetmessages: + msg80980
2009-02-02 15:47:46loewissetassignee: loewis -> gpolo
2009-02-02 15:47:37loewissetresolution: accepted
messages: + msg80944
2009-01-09 10:27:54mkieversetmessages: + msg79460
2009-01-02 22:35:31gpolosetfiles: + issue_1581476.diff
keywords: + patch
messages: + msg78895
versions: + Python 2.6, Python 3.0, Python 3.1, Python 2.7, - Python 2.4
2008-12-04 13:05:58mkieversetmessages: + msg76881
2008-12-04 01:23:00gpolosetmessages: + msg76861
2008-09-15 17:39:27gpolosetnosy: + gpolo
2006-10-20 19:26:07reowencreate