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: Consistently handle non .py source files
Type: enhancement Stage: test needed
Components: IDLE Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: terry.reedy
Priority: normal Keywords:

Created on 2022-02-14 03:33 by terry.reedy, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg413210 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2022-02-14 03:33
Python will attempt to execute any file it can decode to unicode text as a startup script.  It will only import .py files as a module.  #45447 turned on syntax coloring for .pyi stub files.  (.pyw files and files starting with "!#.*python" were already recognized as source (scripts).) It also added '.pyi' as a possible python extension in open and save dialogs.

For this issue, fix some other modules, as appropriate, for non-.py files.

Pathbrowser: Except for the files in sys.path, pathbrowser only shows .py files and directories including such.  It should be easy to also list .pyw and .pyi files and directories.  Perhaps a button could be added to list all files.

Open Module: Opens a module when given a valid import name.  So it cannot be used to open non-modules, which is to say, non .py files.  .pyi files are condensed modules, not startup files, but opening them would require considerable change since the import machinery is currently used.  We could add a message to the box saying, "To open a non-module (non .py) file, use File => Open."

Modulebrowser: This was originally called Classbrowser as it only browsed top-level classes and their methods.  It now browses all classes and def-ined functions and I renamed it to indicate the expanded scope. Since it only browses .py files, I did not know that I was theoretically narrowing the scope to exclude non-.py files.

Currently, when editing a non-.py file and trying to open a module browser, a window is opened and nothing happens.  This is the same as with a file with no classes or functions.  Either browse or display an error message.  The latter would include files with nothing to browse.

Anything else?
History
Date User Action Args
2022-04-11 14:59:56adminsetgithub: 90902
2022-02-14 03:33:18terry.reedycreate