Commit 7e9394ab authored by Guido van Rossum's avatar Guido van Rossum

add TkVersion,TclVersion; don't drop in debugger

parent 470be14c
...@@ -2,22 +2,20 @@ ...@@ -2,22 +2,20 @@
import tkinter import tkinter
from tkinter import TclError from tkinter import TclError
from types import *
CallableTypes = (FunctionType, MethodType,
BuiltinFunctionType, BuiltinMethodType,
ClassType, InstanceType)
class _Dummy: # Older versions of tkinter don't define these variables
def meth(self): return try:
TkVersion = eval(tkinter.TK_VERSION)
def _func(): except AttributeError:
pass TkVersion = 3.6
try:
FunctionType = type(_func) TclVersion = eval(tkinter.TCL_VERSION)
ClassType = type(_Dummy) except AttributeError:
MethodType = type(_Dummy.meth) TclVersion = 7.3
StringType = type('')
TupleType = type(())
ListType = type([])
DictionaryType = type({})
NoneType = type(None)
CallableTypes = (FunctionType, MethodType)
def _flatten(tuple): def _flatten(tuple):
res = () res = ()
...@@ -347,10 +345,10 @@ class Misc: ...@@ -347,10 +345,10 @@ class Misc:
self.tk.quit() self.tk.quit()
def _getints(self, string): def _getints(self, string):
if not string: return None if not string: return None
res = () return tuple(map(self.tk.getint, self.tk.splitlist(string)))
for v in self.tk.splitlist(string): def _getdoubles(self, string):
res = res + (self.tk.getint(v),) if not string: return None
return res return tuple(map(self.tk.getdouble, self.tk.splitlist(string)))
def _getboolean(self, string): def _getboolean(self, string):
if string: if string:
return self.tk.getboolean(string) return self.tk.getboolean(string)
...@@ -438,29 +436,9 @@ class _CallSafely: ...@@ -438,29 +436,9 @@ class _CallSafely:
except SystemExit, msg: except SystemExit, msg:
raise SystemExit, msg raise SystemExit, msg
except: except:
try: import traceback
try: print "Exception in Tkinter callback"
t = sys.exc_traceback traceback.print_exc()
while t:
sys.stderr.write(
' %s, line %s\n' %
(t.tb_frame.f_code,
t.tb_lineno))
t = t.tb_next
finally:
sys.stderr.write('%s: %s\n' %
(sys.exc_type,
sys.exc_value))
(sys.last_type,
sys.last_value,
sys.last_traceback) = (sys.exc_type,
sys.exc_value,
sys.exc_traceback)
import pdb
pdb.pm()
except:
print '*** Error in error handling ***'
print sys.exc_type, ':', sys.exc_value
class Wm: class Wm:
def aspect(self, def aspect(self,
......
...@@ -2,22 +2,20 @@ ...@@ -2,22 +2,20 @@
import tkinter import tkinter
from tkinter import TclError from tkinter import TclError
from types import *
CallableTypes = (FunctionType, MethodType,
BuiltinFunctionType, BuiltinMethodType,
ClassType, InstanceType)
class _Dummy: # Older versions of tkinter don't define these variables
def meth(self): return try:
TkVersion = eval(tkinter.TK_VERSION)
def _func(): except AttributeError:
pass TkVersion = 3.6
try:
FunctionType = type(_func) TclVersion = eval(tkinter.TCL_VERSION)
ClassType = type(_Dummy) except AttributeError:
MethodType = type(_Dummy.meth) TclVersion = 7.3
StringType = type('')
TupleType = type(())
ListType = type([])
DictionaryType = type({})
NoneType = type(None)
CallableTypes = (FunctionType, MethodType)
def _flatten(tuple): def _flatten(tuple):
res = () res = ()
...@@ -347,10 +345,10 @@ class Misc: ...@@ -347,10 +345,10 @@ class Misc:
self.tk.quit() self.tk.quit()
def _getints(self, string): def _getints(self, string):
if not string: return None if not string: return None
res = () return tuple(map(self.tk.getint, self.tk.splitlist(string)))
for v in self.tk.splitlist(string): def _getdoubles(self, string):
res = res + (self.tk.getint(v),) if not string: return None
return res return tuple(map(self.tk.getdouble, self.tk.splitlist(string)))
def _getboolean(self, string): def _getboolean(self, string):
if string: if string:
return self.tk.getboolean(string) return self.tk.getboolean(string)
...@@ -438,29 +436,9 @@ class _CallSafely: ...@@ -438,29 +436,9 @@ class _CallSafely:
except SystemExit, msg: except SystemExit, msg:
raise SystemExit, msg raise SystemExit, msg
except: except:
try: import traceback
try: print "Exception in Tkinter callback"
t = sys.exc_traceback traceback.print_exc()
while t:
sys.stderr.write(
' %s, line %s\n' %
(t.tb_frame.f_code,
t.tb_lineno))
t = t.tb_next
finally:
sys.stderr.write('%s: %s\n' %
(sys.exc_type,
sys.exc_value))
(sys.last_type,
sys.last_value,
sys.last_traceback) = (sys.exc_type,
sys.exc_value,
sys.exc_traceback)
import pdb
pdb.pm()
except:
print '*** Error in error handling ***'
print sys.exc_type, ':', sys.exc_value
class Wm: class Wm:
def aspect(self, def aspect(self,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment