homepage

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: IDLE: Detect Python files even if name doesn't end in .py
Type: enhancement Stage: patch review
Components: IDLE Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: amaury.forgeotdarc, ggenellina, roger.serwy, terry.reedy, weirdink13
Priority: normal Keywords: patch

Created on 2009年08月29日 21:44 by ggenellina, last changed 2022年04月11日 14:56 by admin.

Files
File name Uploaded Description Edit
EditorWindow.diff ggenellina, 2009年11月14日 21:38
Messages (9)
msg92071 - (view) Author: Gabriel Genellina (ggenellina) Date: 2009年08月29日 21:44
A Python source file name doesn't necesarily end 
in .py/.pyw; on Linux, scripts usually have no 
extension but are recognized by its shebang line. 
Windows uses file type associations: .py files are of 
type Python.File, and .pyc files are Python.NoConFile.
This patch makes IDLE recognize as a Python source 
(and colorize) any file of those types, regardless of 
extension.
http://permalink.gmane.org/
gmane.comp.python.general/636011
msg92412 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009年09月08日 11:08
This makes sense, but the code should:
- not make the query when the extension is empty
- catch the WindowsError raised when the extension is not in the registry.
msg95259 - (view) Author: Gabriel Genellina (ggenellina) Date: 2009年11月14日 21:38
This new patch addresses the previous comments.
msg113184 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010年08月07日 16:56
I am a little puzzled by this issue.
1. Why would a Windows user use any extention other than .py or .pyw, which IDLE opens fine. How many people do something senseless like hand-registering, say 'xiq', as a python file?
2. .pyc files are binary files and NOT source code files and cannot be opened by IDLE as it will attempt to decode them into text. So why the check for that?
Also, I believe there is another issue to add a 'Treat this as Python code' entry to one of the menus. This would cover the case of files without extensions and files that are not python files but happen (on a case-by-case basis) to have python code embedded within.
So I am thinking that this should be closed.
msg165561 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2012年07月16日 00:49
This is related to issue6858. I assume that the point of this issue is to enable syntax highlighting by relying on the Windows registry?
msg165658 - (view) Author: Daniel Swanson (weirdink13) Date: 2012年07月16日 21:35
I am also somewhat puzzled by this issue.
The other day I was able to open some .txt files just to see if I could and they opened just fine.
Just now I tryed to open a .jpg file and I got an error message, but then again, why would someone save a python file as a jpeg image?
msg165668 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2012年07月17日 00:37
Is the error message a traceback? If so, could you open a separate issue for it?
msg166169 - (view) Author: Daniel Swanson (weirdink13) Date: 2012年07月22日 20:54
No. When I try to open the file a small window entitled "Specify file encoding" pops up that says 
"The file's encoding is invalid in Python 3.x.
Idle will convert it to UTF-8.
What is the current encoding of the file?"
followed by an entry widget that has "cp1252" and "ok" and "cancel" buttons. When I click "ok" the computer go "dunnn" and a error window titled "Decoding Error" that says "File C:\Python32\misc\bee.jpg Failed to Decode" with an "ok" button which, when clicked, closes idle (the edit window, not the shell). Does that answer your question?
msg228305 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014年10月03日 04:05
#6858 was the issue I referred to.
Recognizing #!...python, common on *nex, which the patch does not do, seems sensible. I thought about coding line, but general idea is not specific to python.
History
Date User Action Args
2022年04月11日 14:56:52adminsetgithub: 51053
2020年06月08日 01:02:36terry.reedysetversions: + Python 3.10, - Python 3.6, Python 3.7
2017年06月30日 00:51:55terry.reedysetassignee: terry.reedy
versions: + Python 3.6, Python 3.7, - Python 2.7, Python 3.4, Python 3.5
2014年10月03日 04:05:56terry.reedysetstage: patch review
messages: + msg228305
versions: + Python 2.7, Python 3.4, Python 3.5, - Python 3.2
2012年07月22日 20:54:13weirdink13setmessages: + msg166169
2012年07月17日 00:37:31roger.serwysetmessages: + msg165668
2012年07月16日 21:35:51weirdink13setnosy: + weirdink13
messages: + msg165658
2012年07月16日 00:49:15roger.serwysetnosy: + roger.serwy
messages: + msg165561
2010年08月07日 16:56:10terry.reedysetnosy: + terry.reedy

messages: + msg113184
versions: - Python 2.6, Python 3.1, Python 2.7
2009年11月14日 21:38:22ggenellinasetfiles: + EditorWindow.diff

messages: + msg95259
2009年11月14日 21:36:29ggenellinasetfiles: - EditorWindow.diff
2009年09月08日 11:08:40amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg92412
2009年08月29日 21:44:38ggenellinacreate

AltStyle によって変換されたページ (->オリジナル) /