Skip to content

Lib: Improve IDLE launcher script for clarity and safety #138100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions Lib/idlelib/idle.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import os.path
import os
import sys

def add_idlelib_to_path():
"""
Adds the parent directory of the current file's parent directory
to sys.path to allow running IDLE from a non-standard location.
"""
idlelib_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
if idlelib_dir not in sys.path:
sys.path.insert(0, idlelib_dir)
return idlelib_dir

# Enable running IDLE with idlelib in a non-standard location.
# This was once used to run development versions of IDLE.
# Because PEP 434 declared idle.py a public interface,
# removal should require deprecation.
idlelib_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if idlelib_dir not in sys.path:
sys.path.insert(0, idlelib_dir)
def main():
"""
Import and run IDLE's main shell.
"""
add_idlelib_to_path()
try:
from idlelib.pyshell import main as idle_main
except ImportError as e:
print("Could not import idlelib.pyshell:", e)
sys.exit(1)
idle_main()

from idlelib.pyshell import main # This is subject to change
main()
if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,4 @@ This Python distribution contains *no* GNU General Public License (GPL) code,
so it may be used in proprietary projects. There are interfaces to some GNU
code but these are entirely optional.

All trademarks referenced herein are property of their respective holders.
All trademarks referenced herein are property of their respective holders.
1 change: 1 addition & 0 deletions iOS/testbed/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def clone_testbed(
print(f"{target} already exists; aborting without creating project.")
sys.exit(10)


if framework is None:
if not (
source / "Python.xcframework/ios-arm64_x86_64-simulator/bin"
Expand Down
Loading