classification
Title: IDLE: Detect Python files even if name doesn't end in .py
Type: enhancement Stage:
Components: IDLE Versions: Python 3.2
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, gagenellina, terry.reedy
Priority: normal Keywords: patch

Created on 2009-08-29 21:44 by gagenellina, last changed 2010-08-07 16:56 by terry.reedy.

Files
File name Uploaded Description Edit
EditorWindow.diff gagenellina, 2009-11-14 21:38 review
Messages (4)
msg92071 - (view) Author: Gabriel Genellina (gagenellina) 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 (gagenellina) 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.
History
Date User Action Args
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:22gagenellinasetfiles: + EditorWindow.diff

messages: + msg95259
2009-11-14 21:36:29gagenellinasetfiles: - EditorWindow.diff
2009-09-08 11:08:40amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg92412
2009-08-29 21:44:38gagenellinacreate