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.
Created on 2009年01月04日 15:16 by geon, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| defaultextension.patch | amaury.forgeotdarc, 2009年05月13日 17:00 | |||
| fix_defaultextension.diff | gpolo, 2009年08月01日 20:45 | |||
| issue4832.diff | roger.serwy, 2011年12月14日 18:49 | review | ||
| issue4832_rev1.patch | roger.serwy, 2012年07月09日 21:48 | review | ||
| issue4832_rev2.patch | ned.deily, 2012年07月10日 03:52 | review | ||
| Messages (27) | |||
|---|---|---|---|
| msg79062 - (view) | Author: Pavel Kosina (geon) | Date: 2009年01月04日 15:16 | |
There should not be necessity to write filename *with extension* at the saving dialog. It should be enough, at least on Windows, to put there just "hello" and get "hello.py". It is really complication especially for beginners. If they, as they are used to from another programs, put there just "hello", it is saved without extension ".py" what have 2 result: they cannot see any icons at that file and they are not able to run in, cause python.exe is bind with ".py". Hoping its not duplicate I haven't found anything like this here. |
|||
| msg86620 - (view) | Author: Daniel Diniz (ajaksu2) * (Python triager) | Date: 2009年04月26日 22:17 | |
I get the .py automatically on Linux, is this an intended behavior difference or should this issue be considered a bug instead? |
|||
| msg87695 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2009年05月13日 17:00 | |
I think I found the relevant documentation: http://wiki.tcl.tk/1842 """ On Unix, when typing a filename without extension, the first extension belonging to the currently selected filetype will be appended to the filename. On Windows, this is not the case, but one can define a fixed extension with the -defaultextension option. To get the same behaviour on Unix, use -defaultextension {}. """ I tried to add "defaultextension=.py", (see attached patch) the problem is that now it seems impossible to create a file without an extension... |
|||
| msg87702 - (view) | Author: Daniel Diniz (ajaksu2) * (Python triager) | Date: 2009年05月13日 19:07 | |
Amaury, Your patch also forces '.py' to any saved file on Linux, but using 'defaultextension = ""' it works correctly here. Does if fix things on Windows? |
|||
| msg87703 - (view) | Author: Pavel Kosina (geon) | Date: 2009年05月13日 19:46 | |
Trying to patch the latest revision 72608 and it didnt work, here on winxp. C:\prg\Python30\Lib\idlelib>svn update Restored 'IOBinding.py' At revision 72608. C:\prg\Python30\Lib\idlelib>patch IOBinding.py defaultextension.patch --verbose Hmm... Looks like a unified diff to me... The text leading up to this was: -------------------------- |Index: Lib/idlelib/IOBinding.py |=================================================================== |--- Lib/idlelib/IOBinding.py (revision 72282) |+++ Lib/idlelib/IOBinding.py (working copy) -------------------------- Patching file IOBinding.py using Plan A... Hunk #1 succeeded at 480 (offset -45 lines). Hmm... Ignoring the trailing garbage. done If I do the patch by hand, it works. All files are saved with ext. .py. When set 'defaultextension = ""', it is save well too, but then IDLE crashed immediately. |
|||
| msg91168 - (view) | Author: Guilherme Polo (gpolo) * (Python committer) | Date: 2009年08月01日 20:45 | |
I'm attaching a very similar patch that I tested on Linux and Windows. It just combines the default behaviour with the details required for Windows, that is, the default extension is set to '.py' for Windows and '' elsewhere (the default). |
|||
| msg91260 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2009年08月04日 17:47 | |
With this new patch, is it possible to create a file without extension on Windows? |
|||
| msg91262 - (view) | Author: Guilherme Polo (gpolo) * (Python committer) | Date: 2009年08月04日 18:05 | |
> With this new patch, is it possible to create a file without extension > on Windows? It is tricky but, answering your question, you could enter a name ending with a period to save without an extension. It seems this isn't going anywhere then. The default behaviour on Linux is to get the .py already, so this patch changes nothing there. On Windows no extension is set by default, and with this patch it is always .py if no extension is specified. |
|||
| msg110962 - (view) | Author: Tal Einat (taleinat) * (Python committer) | Date: 2010年07月20日 20:13 | |
On Windows, I can't think of any common reason to want to save a file edited in IDLE without the .py extension. On the other hand, accidentally forgetting the .py extension is annoying, and users have come to expect a default extension being added by applications (e.g. MS Office).
Guilherme's patch (applied manually) works fine here on Windows7. I'm +1 for committing this if it has been tested to work as expected on Linux and OSX.
(minor nit-pick: could use sys.platform.startswith('win') instead of slicing)
|
|||
| msg110964 - (view) | Author: Brian Curtin (brian.curtin) * (Python committer) | Date: 2010年07月20日 20:23 | |
I would forget about slicing or using startswith. "win32" is the platform name for Python on Windows whether or not it's 64-bit (see PC/pyconfig.h), so I'd just check """sys.platform == 'win32'""" |
|||
| msg110966 - (view) | Author: Guilherme Polo (gpolo) * (Python committer) | Date: 2010年07月20日 20:31 | |
Sorry but this is just bikeshedding, whoever commits can make this change or if it had been committed without this "improvement" then anyone could adjust without needing a new issue. |
|||
| msg130399 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2011年03月09日 02:23 | |
The behavior (for Windows) I expect and would like is that the default extension would be .py, .txt, or nothing, depending on the selection in the 'save as type' box in the SaveAS dialog. (.pyw, being rare, would have to be explicitly typed.) Of course, doubled extensions like .py.py should be avoided. I believe other apps on Windows do something like this, but I should check. I have no idea how the other systems differ. |
|||
| msg149466 - (view) | Author: Roger Serwy (roger.serwy) * (Python committer) | Date: 2011年12月14日 18:49 | |
I was unable to produce the crash that Pavel described in msg87703. Just adding "defaultextension=''" solves this issue for Windows and still preserves the correct behavior on Linux. Amaury's quote of tcl/tk documentation in msg87695 mentions this as well. I tested this on Linux with 2.7.1 and 3.2 and on Windows Vista using 2.7.1 and 3.2.2. Attached is a diff against 3.3a0. |
|||
| msg165128 - (view) | Author: Roger Serwy (roger.serwy) * (Python committer) | Date: 2012年07月09日 21:48 | |
issue4832_rev1.patch is a complete patch against 3.3. This is also part of issue13504, "7) ANNOYANCE: It’s too easy to forget the .py extension when saving a file." |
|||
| msg165135 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2012年07月09日 23:29 | |
I tested with defaultextension='' on Windows and it works well. If no extension is entered (no '.' in name), .py or .txt is added for the .py/w and .txt filetype choices. If there is a . in the name, nothing is added. If one wants x.y.py, one must type the whole name. So typing x.pyw does not get .py added on top of it. This needs to be documented in the Idle help file. Should the change only be made to 3.3, or also to 3.2/2.7? The old behavior of typing .py still works, so that does not break. Typing no . to get no extension (rare) will break unless one selects '*.* all files' (which one should do anyway as it is standard Windows behavior). I think uniform across versions is better so people who learn leaving out .py on 3.3 can also leave it out in future 2.7 and 3.2, which should come out about the same time as 3.3.0. Whether just one or two or three versions, how do people used to the old (buggy in my opinion) behavior find out about the change. A splash line on startup "See help for new 'save as' behavior" ? Anything I should know about *nix or mac behavior, at least for the doc? Ned, does this change work on macs? |
|||
| msg165147 - (view) | Author: Roger Serwy (roger.serwy) * (Python committer) | Date: 2012年07月10日 02:44 | |
Your description applied to the behavior on Ubuntu 11.04. |
|||
| msg165154 - (view) | Author: Ned Deily (ned.deily) * (Python committer) | Date: 2012年07月10日 03:52 | |
As usual, there seem to be small but significant differences among the implementations. Testing with the three OS X Tk implementations shows that currently: 1. Aqua Tk 8.5 and Aqua Tk 8.4 do not supply a default extension when saving. With patch issue4832.diff applied, they still incorrectly do not supply a default extension. (Note, Aqua Tk's do not supply a file type filter in the Save File dialog box.) 2. X11 Tk 8.5 behaves like other Unix X11 Tk's: a default based on the selected File Type filter is used, i.e. .py for "Python files, .txt for "Text file". Applying the patch does not change that correct behavior. I tested a variation of Guilherme's patch which supplies a defaultextension of '.py' but only for OS X (rather than Windows). With that patch (issue4832_rev2.patch): 1. Aqua Tk 8.5 now correctly supplies a default extension of '.py' on saves if the user does not enter an extension as part of the file name. 2. Aqua Tk 8.4 behavior is unchanged: it still incorrectly does not supply an extension if the user does not. I don't see how to fix that but the use of Aqua Tk 8.4 is diminishing. 3. X11 Tk 8.5 behavior is unchanged: it still correctly supplies a default based on the selected File Type. Since Aqua Tk 8.5 is the major Tk for OS X these days (it has been the system default since OS X 10.6) and the patch improves things for it, I'd like to see this go in. I did test it on a Debian Linux X11. It should behave the same on Windows as Roger's previous patch but it would be good to test it again. As far as documentation changes, I don't see the need to have anything more than the usual IDLE/NEWS.txt file entry. |
|||
| msg165199 - (view) | Author: Roger Serwy (roger.serwy) * (Python committer) | Date: 2012年07月10日 19:36 | |
I tried issue4832_rev2.patch on Ubuntu 11.04 with Tk 8.5 and it still behaves as Terry described. |
|||
| msg165346 - (view) | Author: Ned Deily (ned.deily) * (Python committer) | Date: 2012年07月13日 00:39 | |
Terry, are you planning to commit this? If not, I can do it. It would be good to get this into 3.3.0b2 since it does fix an important usability issue. |
|||
| msg165347 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2012年07月13日 01:19 | |
I agree. Go ahead. But what do you think of applying to 2.7 and or 3.2? I want to add a sentence to Idle help, which I want to edit for the tooltips issue also. But that is not a rush. |
|||
| msg165371 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年07月13日 07:45 | |
New changeset 677a9326b4d4 by Ned Deily in branch 'default': Issue #4832: Modify IDLE to save files with .py extension by http://hg.python.org/cpython/rev/677a9326b4d4 |
|||
| msg165372 - (view) | Author: Ned Deily (ned.deily) * (Python committer) | Date: 2012年07月13日 07:50 | |
Committed for 3.3. I'm +0.5 for 2.7 and 3.2. It seems like a bug to me. Terry, I'll leave it up to you to handle that and any further doc updates you want to make. |
|||
| msg197461 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2013年09月10日 18:40 | |
With PEP 434, this can and I think should be backported. I should have done it for 2.7.5 and will try to do soon. |
|||
| msg228638 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2014年10月06日 04:30 | |
Better late than never. At least on Windows, with has defaultextension = '', changeing "Save as type" to "Text files" changes the default to ".txt". I presume that this bonus feature is not available on OSX, where defaultextension = '.py'. Before I update the doc (just before 2.7.9), can someone tell me what happens with linux, where defaultextension is '', as on Windows? |
|||
| msg228651 - (view) | Author: Saimadhav Heblikar (Saimadhav.Heblikar) * | Date: 2014年10月06日 10:05 | |
I will try to describe the behavior on linux: (Format used is "what i type in file name" -> "name which gets written to disk") 1. When files of type is: Python Files a -> a.py b.py -> b.py c.py.py -> c.py.py d.py.abc -> d.py.abc (!) e.abc -> e.abc (!) 2. When files of type is: text file Same behavior as before, with .txt instead of .py/.pyw 3. When files of type is: All files a -> a b.py -> b.py c.py.py -> c.py.py d.py.abc -> d.py.abc e.abc -> e.abc I hopefully have tried most of the combinations. If I have left out any, please let me know and I'll try them out. |
|||
| msg228727 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2014年10月06日 19:19 | |
Thank you. It was in particular the switching between a -> a.py and a -> a.txt that I described and wanted verified for linux. The fact that names with extensions are left unchanged is important too. I will have to think about how to describe this succinctly. |
|||
| msg229133 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2014年10月12日 09:39 | |
Misdirected push message copied here. New changeset 69cdf71bda12 by Terry Jan Reedy in branch '2.7': Issue #3832: backport 677a9326b4d4 to 2.7 (and delete some obsolete code). https://hg.python.org/cpython/rev/69cdf71bda12 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:43 | admin | set | github: 49082 |
| 2020年06月08日 00:29:28 | terry.reedy | unlink | issue13504 dependencies |
| 2020年06月06日 16:01:46 | terry.reedy | link | issue27965 superseder |
| 2014年10月12日 09:39:39 | terry.reedy | set | messages: + msg229133 |
| 2014年10月06日 19:19:54 | brian.curtin | set | nosy:
- brian.curtin |
| 2014年10月06日 19:19:10 | terry.reedy | set | messages: + msg228727 |
| 2014年10月06日 10:05:14 | Saimadhav.Heblikar | set | messages: + msg228651 |
| 2014年10月06日 04:30:11 | terry.reedy | set | status: open -> closed versions: + Python 2.7, - Python 3.3 nosy: + Saimadhav.Heblikar messages: + msg228638 resolution: fixed stage: commit review -> resolved |
| 2014年02月04日 12:02:59 | taleinat | set | nosy:
- taleinat |
| 2013年09月10日 18:40:47 | terry.reedy | set | messages: + msg197461 |
| 2012年07月13日 07:50:30 | ned.deily | set | messages:
+ msg165372 title: idle filename extension -> IDLE does not supply a default ext of .py on Windows or OS X for new file saves |
| 2012年07月13日 07:45:38 | python-dev | set | nosy:
+ python-dev messages: + msg165371 |
| 2012年07月13日 01:19:11 | terry.reedy | set | messages: + msg165347 |
| 2012年07月13日 00:39:06 | ned.deily | set | messages: + msg165346 |
| 2012年07月10日 19:36:53 | roger.serwy | set | messages: + msg165199 |
| 2012年07月10日 03:52:36 | ned.deily | set | files:
+ issue4832_rev2.patch messages: + msg165154 |
| 2012年07月10日 02:44:16 | roger.serwy | set | messages: + msg165147 |
| 2012年07月09日 23:29:18 | terry.reedy | set | nosy:
+ ned.deily messages: + msg165135 assignee: terry.reedy stage: patch review -> commit review |
| 2012年07月09日 21:48:36 | roger.serwy | link | issue13504 dependencies |
| 2012年07月09日 21:48:25 | roger.serwy | set | files:
+ issue4832_rev1.patch messages: + msg165128 stage: patch review |
| 2011年12月14日 18:49:55 | roger.serwy | set | files:
+ issue4832.diff nosy: + roger.serwy messages: + msg149466 |
| 2011年12月10日 03:52:09 | terry.reedy | link | issue10364 superseder |
| 2011年03月09日 02:23:07 | terry.reedy | set | nosy:
terry.reedy, amaury.forgeotdarc, taleinat, ajaksu2, gpolo, geon, brian.curtin messages: + msg130399 |
| 2011年03月09日 02:16:22 | terry.reedy | set | nosy:
+ terry.reedy versions: + Python 3.3, - Python 3.1, Python 2.7 |
| 2010年07月20日 20:31:43 | gpolo | set | messages: + msg110966 |
| 2010年07月20日 20:23:40 | brian.curtin | set | nosy:
+ brian.curtin messages: + msg110964 |
| 2010年07月20日 20:13:29 | taleinat | set | nosy:
+ taleinat messages: + msg110962 |
| 2009年08月04日 18:05:51 | gpolo | set | messages: + msg91262 |
| 2009年08月04日 17:47:49 | amaury.forgeotdarc | set | messages: + msg91260 |
| 2009年08月01日 20:45:07 | gpolo | set | files:
+ fix_defaultextension.diff messages: + msg91168 |
| 2009年05月13日 19:46:43 | geon | set | messages: + msg87703 |
| 2009年05月13日 19:07:02 | ajaksu2 | set | messages: + msg87702 |
| 2009年05月13日 17:00:16 | amaury.forgeotdarc | set | files:
+ defaultextension.patch nosy: + amaury.forgeotdarc messages: + msg87695 keywords: + patch |
| 2009年04月26日 22:17:11 | ajaksu2 | set | priority: normal versions: - Python 2.6, Python 2.5, Python 3.0 nosy: + ajaksu2, gpolo messages: + msg86620 type: behavior -> enhancement |
| 2009年01月04日 15:16:01 | geon | create | |