File: tkinter-import.diff

package info (click to toggle)
python3.13 3.13.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 121,328 kB
  • sloc: python: 704,014; ansic: 653,914; xml: 31,250; sh: 5,844; cpp: 4,326; makefile: 1,981; objc: 787; lisp: 502; javascript: 213; asm: 75; csh: 12
file content (34 lines) | stat: -rw-r--r-- 908 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Description: Suggest installation of python3-tk package
 We split Tk out into a separate binary package. Help users who try to import
 it, without it installed.

Forwarded: not-needed

--- a/Lib/tkinter/__init__.py
+++ b/Lib/tkinter/__init__.py
@@ -35,7 +35,10 @@
 import sys
 import types
 
-import _tkinter # If this fails your Python may not be configured for Tk
+try:
+    import _tkinter
+except ImportError as msg:
+    raise ImportError(str(msg) + ', please install the python3-tk package')
 TclError = _tkinter.TclError
 from tkinter.constants import *
 import re
--- a/Lib/turtle.py
+++ b/Lib/turtle.py
@@ -98,7 +98,10 @@
 extensions in mind. These will be commented and documented elsewhere.
 """
 
-import tkinter as TK
+try:
+    import tkinter as TK
+except ImportError as msg:
+    raise ImportError(str(msg) + ', please install the python3-tk package')
 import types
 import math
 import time