You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IDLE - pasting text doesn't delete selection #49374
Select the first line ("spam") and press control+c to copy.
Select the second line ("eggs") and press control+v to paste.
Expected result:
spam
spam
(With the caret at the end of the second line and no selection.)
Actual result (IDLE 2.6, Tk/Tcl 8.4, Linux):
spam
eggsspam
(With "eggs" selected and the caret at the end of the second line.)
I don't think this happens to me on Windows. It might be deliberate; I
know that Tk has slightly different behaviour on Windows and Linux. But
it doesn't seem to be consistent with other behaviour: for example, if
instead of pasting I start typing, the selected text is erased and the
typed text replaces it.
I can look into this myself, but I would appreciate if someone else can
confirm that this is not the expected behaviour, since perhaps it is
only my Windows background that leads me to expect this.
On Win7, I get the replacement behavior. I get the same in Notepad and Firefox, so this may be standard Windows behavior. What is standard in other linex and mac apps? If the tk difference is a standard platform difference, I might think we should leave it alone.
"What is standard in other linex and mac apps?"
-On Mac OS X 10.8.3 TextEdit I get the replacement behavior
-On Linux CentOS 6.4 gedit I get the replacement behavior
-On IDLE under the latest 3.4 pull I get the replacement behavior with Max OS X 10.8.3
-On IDLE under the latest 3.4 pull I get the eggsspam behavior with Linux CentOS 6.4 as Weeble described in the original bug report
So from my perspective Linux is behaving differently than Windows and Mac OS X.
X11-based Tk follows general X11 practice with regard to text pasting. See http://wiki.tcl.tk/3771 for some background. Old school X11 users expect pasting to work that way. This is yet another instance where Tk attempts to conform to the platform it is running on. I recommend closing this issue as X11 Tk (and, hence, IDLE) has behaved like this forever and changing it would be painful for many current X11 IDLE users.
serwy commented on May 26, 2013
serwymannequin
Mannequin
More actions
There are many X11 applications that replace the selection with pasted text. GTK and Qt widgets behave that way. Here's a brief list: gedit (GTK), gummi (GTK), kate (Qt), texmaker (Qt).
Tkinter, for me, has become increasingly frustrating due to these subtle platform differences. (See bpo-14146, bpo-13582, and many more that deal with Tk on Mac.) For IDLE, I consider these behavior differences bugs.
The attached patch "fixes" this issue.
GuilhermeSimes commented on May 26, 2013
GuilhermeSimesmannequin
Mannequin
More actions
I think IDLE should ignore general X11 practice. I used Linux for years and have never seen this behavior before because almost all programs behave in the Mac/Windows way.
Unfortunately, there is no one right answer to paste behavior on X11, unlike on native Windows and Mac implementations where there is essentially system-wide consistent paste behavior enforced by the underlying operating system. As the Tk Wiki points out (and the comments hers concur), different users are going to have different expectations. If we want to make this behavior available with X11 Tk, then it really should be a user configurable option. Without providing an option, the overriding design principle is that the status quo wins a stalemate (http://www.boredomandlaziness.org/2011/02/status-quo-wins-stalemate.html).
I agree that the paste replace should be added as an option on linux, but without a broader survey of Linux Idle users to convince me otherwise, I have to agree that the default should stay as it is. I do not see any call to make the x11 behavior an option on mac and windows.
I haver verified Roger's patch does indeed fix the problem on Linux CentOS 6.4 with IDLE 3.4.
The Linux situation is complex. Basically as I see it over the years pure X11 applications are becoming extinct and most developers either use GTK (for GNOME) or QT (for KDE). I don't blame anybody for moving to one of these toolkits because writing a pure X11 application is painful. In the near future Wayland http://en.wikipedia.org/wiki/Wayland_(display_server_protocol) will take over and I wonder how many X11 applications will actually be ported. I agree with Roger we should try and make IDLE as consistent as possible across operating systems.
I had some trouble committing and pushing these patches. After deleting TEntry and committed the 2.7 and 3.5 patches and tried to do the usual 3.5 to default forward merge in TortoiseHG. I got
% hg merge --tool :merge --verbose 101861
resolving manifests
abort: case-folding collision between Lib/idlelib/pyshell.py and Lib/idlelib/PyShell.py
[command returned code 255 Fri Jun 10 22:33:09 2016]
This seems to be a known problem. After some effort to resolve the situation, I gave up and used my replaced my repository with a copy of my backup copy, to undo the things I had tried.
Since the renames on 5/22, I have done other merges without problem, but I rechecked and none involved a file where case was the only difference. I will try again by temporarily renaming pyshell back to PyShell first.
Serhiy: entry=entry as much as any name=expression pair to print the value of variable entry on test failure, either "entry=<tkinter.Entry object .58910800>)" or "entry=<tkinter.ttk.Entry object .58911024>)", as in
======================================================================
FAIL: test_paste_entry (main.PasteTest) (ans='two', end='end', entry=<tkinter.ttk.Entry object .58911024>)
Test pasting into an entry with and without a selection.
----------------------------------------------------------------------
Traceback (most recent call last):
File "F:\Python\dev\36\lib\idlelib\idle_test\test_editmenu.py", line 53, in test_paste_entryself.assertTrue(False)
AssertionError: False is not true
Activity
weeble commentedon Feb 1, 2009
Steps to reproduce:
spam
eggs
Expected result:
spam
spam
(With the caret at the end of the second line and no selection.)
Actual result (IDLE 2.6, Tk/Tcl 8.4, Linux):
spam
eggsspam
(With "eggs" selected and the caret at the end of the second line.)
I don't think this happens to me on Windows. It might be deliberate; I
know that Tk has slightly different behaviour on Windows and Linux. But
it doesn't seem to be consistent with other behaviour: for example, if
instead of pasting I start typing, the selected text is erased and the
typed text replaces it.
I can look into this myself, but I would appreciate if someone else can
confirm that this is not the expected behaviour, since perhaps it is
only my Windows background that leads me to expect this.
gpolo commentedon Feb 1, 2009
This is not really related to IDLE, it is how the Text widget behaves
under Linux, you will notice the same with tcl/tk 8.5.
Nevertheless, I would prefer to have the same results under Windows and
Linux.
gpolo commentedon Aug 1, 2009
btw, I just added a patch for bpo-3559 which could be easily adjusted
to work as described in this issue.
terryjreedy commentedon May 26, 2013
On Win7, I get the replacement behavior. I get the same in Notepad and Firefox, so this may be standard Windows behavior. What is standard in other linex and mac apps? If the tk difference is a standard platform difference, I might think we should leave it alone.
rovitotv commentedon May 26, 2013
"What is standard in other linex and mac apps?"
-On Mac OS X 10.8.3 TextEdit I get the replacement behavior
-On Linux CentOS 6.4 gedit I get the replacement behavior
-On IDLE under the latest 3.4 pull I get the replacement behavior with Max OS X 10.8.3
-On IDLE under the latest 3.4 pull I get the eggsspam behavior with Linux CentOS 6.4 as Weeble described in the original bug report
So from my perspective Linux is behaving differently than Windows and Mac OS X.
ned-deily commentedon May 26, 2013
X11-based Tk follows general X11 practice with regard to text pasting. See http://wiki.tcl.tk/3771 for some background. Old school X11 users expect pasting to work that way. This is yet another instance where Tk attempts to conform to the platform it is running on. I recommend closing this issue as X11 Tk (and, hence, IDLE) has behaved like this forever and changing it would be painful for many current X11 IDLE users.
serwy commentedon May 26, 2013
There are many X11 applications that replace the selection with pasted text. GTK and Qt widgets behave that way. Here's a brief list: gedit (GTK), gummi (GTK), kate (Qt), texmaker (Qt).
Tkinter, for me, has become increasingly frustrating due to these subtle platform differences. (See bpo-14146, bpo-13582, and many more that deal with Tk on Mac.) For IDLE, I consider these behavior differences bugs.
The attached patch "fixes" this issue.
GuilhermeSimes commentedon May 26, 2013
I think IDLE should ignore general X11 practice. I used Linux for years and have never seen this behavior before because almost all programs behave in the Mac/Windows way.
ned-deily commentedon May 26, 2013
Unfortunately, there is no one right answer to paste behavior on X11, unlike on native Windows and Mac implementations where there is essentially system-wide consistent paste behavior enforced by the underlying operating system. As the Tk Wiki points out (and the comments hers concur), different users are going to have different expectations. If we want to make this behavior available with X11 Tk, then it really should be a user configurable option. Without providing an option, the overriding design principle is that the status quo wins a stalemate (http://www.boredomandlaziness.org/2011/02/status-quo-wins-stalemate.html).
terryjreedy commentedon May 27, 2013
I agree that the paste replace should be added as an option on linux, but without a broader survey of Linux Idle users to convince me otherwise, I have to agree that the default should stay as it is. I do not see any call to make the x11 behavior an option on mac and windows.
rovitotv commentedon May 27, 2013
I haver verified Roger's patch does indeed fix the problem on Linux CentOS 6.4 with IDLE 3.4.
The Linux situation is complex. Basically as I see it over the years pure X11 applications are becoming extinct and most developers either use GTK (for GNOME) or QT (for KDE). I don't blame anybody for moving to one of these toolkits because writing a pure X11 application is painful. In the near future Wayland http://en.wikipedia.org/wiki/Wayland_(display_server_protocol) will take over and I wonder how many X11 applications will actually be ported. I agree with Roger we should try and make IDLE as consistent as possible across operating systems.
+1 for applying the patch.
19 remaining items
terryjreedy commentedon Jun 11, 2016
I had some trouble committing and pushing these patches. After deleting TEntry and committed the 2.7 and 3.5 patches and tried to do the usual 3.5 to default forward merge in TortoiseHG. I got
% hg merge --tool :merge --verbose 101861
resolving manifests
abort: case-folding collision between Lib/idlelib/pyshell.py and Lib/idlelib/PyShell.py
[command returned code 255 Fri Jun 10 22:33:09 2016]
This seems to be a known problem. After some effort to resolve the situation, I gave up and used my replaced my repository with a copy of my backup copy, to undo the things I had tried.
Since the renames on 5/22, I have done other merges without problem, but I rechecked and none involved a file where case was the only difference. I will try again by temporarily renaming pyshell back to PyShell first.
python-dev commentedon Jun 11, 2016
New changeset 99760b6a181e by Terry Jan Reedy in branch 'default':
Issue bpo-5124: Temporary pyshell rename to avoid case-folding collision in merge.
https://hg.python.org/cpython/rev/99760b6a181e
New changeset 6c469b50e198 by Terry Jan Reedy in branch '2.7':
Issue bpo-5124: Paste with selection should always replace.
https://hg.python.org/cpython/rev/6c469b50e198
New changeset f8b40e0d5913 by Terry Jan Reedy in branch '3.5':
Issue bpo-5124: Paste with selection should always replace.
https://hg.python.org/cpython/rev/f8b40e0d5913
python-dev commentedon Jun 11, 2016
New changeset 095e79636663 by Terry Jan Reedy in branch 'default':
Issue bpo-5124: rename PyShell back to pyshell and patch test for 3.6
https://hg.python.org/cpython/rev/095e79636663
python-dev commentedon Jun 11, 2016
New changeset 3017e41b0c99 by Terry Jan Reedy in branch '2.7':
Issue bpo-5124: NEWS entries.
https://hg.python.org/cpython/rev/3017e41b0c99
New changeset 62b949a179cb by Terry Jan Reedy in branch '3.5':
Issue bpo-5124: NEWS entries.
https://hg.python.org/cpython/rev/62b949a179cb
New changeset 2fc15579606b by Terry Jan Reedy in branch 'default':
Merge Issue bpo-5124: NEWS entries.
https://hg.python.org/cpython/rev/2fc15579606b
serhiy-storchaka commentedon Jun 11, 2016
ned-deily commentedon Jun 11, 2016
Terry, the 2.7 version of the test changes is causing buildbot and test_idle failures when the "gui" condition is not met. See, for example, http://buildbot.python.org/all/builders/AMD64%20Snow%20Leop%202.7/builds/1400.
python-dev commentedon Jun 11, 2016
New changeset 274308a3b8b6 by Terry Jan Reedy in branch '2.7':
Issue bpo-5124: For 2.7, move requires('gui') from module level to setUpClass.
https://hg.python.org/cpython/rev/274308a3b8b6
terryjreedy commentedon Jun 11, 2016
Oh right, requires('gui') does not work at module level in 2.7.
This should fix. Will try to check next round of bot builds.
terryjreedy commentedon Jun 11, 2016
The two stable buildbots that failed on test_idle before do not now: AMD64 SnowLeapard 1403, AMD64 Win 7 2258.
terryjreedy commentedon Jun 12, 2016
Serhiy: entry=entry as much as any name=expression pair to print the value of variable entry on test failure, either "entry=<tkinter.Entry object .58910800>)" or "entry=<tkinter.ttk.Entry object .58911024>)", as in
======================================================================
FAIL: test_paste_entry (main.PasteTest) (ans='two', end='end', entry=<tkinter.ttk.Entry object .58911024>)
Test pasting into an entry with and without a selection.
----------------------------------------------------------------------
serhiy-storchaka commentedon Jun 12, 2016
Ah, I looked on 3.5 change and missed that in 3.6 you test both tkinter.Entry and ttk.Entry.