Professional IronPython



Download 20,35 Mb.
Pdf ko'rish
bet267/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   263   264   265   266   267   268   269   270   ...   453
254

CHAPTER 12
Debugging ironPython APPlicAtions
low-level functions in the 
sys
module. The following list is low-level modules you can use for special 
needs, but won’t normally use in your application.
➤➤
sys.excepthook(
type

value

traceback
)
: The system calls this low-level function each 
time it generates an exception. To use this function, you supply the same tuple of values as 
you receive when you call 
sys.exc_info()
.


sys._getframe([
depth
])
: The system calls this low-level function to display a frame 
object from the call stack. If the caller supplies a 
depth
value, the frame object is at that 
call stack depth. The default 
depth
value setting is 0. IronPython doesn’t appear to imple-
ment this function, but you may encounter it in other versions of Python, so it pays to 
know about this function.
If you want to control how much information the interpreter provides when you request a 
traceback

you can always set the 
sys.tracebacklimit
attribute. The 
sys.tracebacklimit
attribute defaults to 
1,000. It doesn’t actually appear when you perform a 
dir()
command. In fact, until you set it, printing 
the 
sys.tracebacklimit
attribute returns an 
AttributeError
. Use code like this
sys.tracebacklimit = 3
to modify the 
traceback
level. Now when you try to print the 
sys.tracebacklimit
attribute, you 
get back the value you supplied.
Using the traceback Module
The 
traceback
module adds to the capabilities of the 
sys
module described in the “Using the sys 
Module” section of the chapter. In addition, it adds to the standard exception handling capabilities 
of IronPython by making it easier to obtain complex information about exceptions in general. The 
traceback
module does focus on 
traceback
s, which are the IronPython equivalent of a call stack.
The most common call is 
traceback.print_exc()
. Essentially, this call prints out the current 
exception information. You can use it in a 
try...except
structure, much as you’d use the
sys.exc_info()
function, but with fewer limitations. Figure 12-6 shows a typical view of
the 
traceback.print_exc()
function in action.
FIgURE 12-6: 
Obtain traceback information with ease using the traceback.print_exc() function.
548592c12.indd 254
2/24/10 12:48:48 PM
www.finebook.ir



Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   263   264   265   266   267   268   269   270   ...   453




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish