Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1dc0d91b
Commit
1dc0d91b
authored
Mar 17, 2006
by
Neal Norwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove sys.exc_type, sys.exc_value, sys.exc_traceback
parent
0bc5b7f1
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
36 additions
and
58 deletions
+36
-58
Demo/classes/Complex.py
Demo/classes/Complex.py
+1
-1
Demo/pdist/server.py
Demo/pdist/server.py
+1
-1
Demo/sockets/gopher.py
Demo/sockets/gopher.py
+2
-1
Doc/api/exceptions.tex
Doc/api/exceptions.tex
+3
-6
Doc/api/intro.tex
Doc/api/intro.tex
+2
-5
Doc/ext/extending.tex
Doc/ext/extending.tex
+2
-3
Doc/lib/libtraceback.tex
Doc/lib/libtraceback.tex
+3
-8
Doc/ref/ref7.tex
Doc/ref/ref7.tex
+7
-13
Lib/SimpleXMLRPCServer.py
Lib/SimpleXMLRPCServer.py
+2
-2
Lib/idlelib/WindowList.py
Lib/idlelib/WindowList.py
+2
-2
Lib/lib-tk/Tkinter.py
Lib/lib-tk/Tkinter.py
+1
-1
Lib/traceback.py
Lib/traceback.py
+1
-3
Mac/Tools/IDE/PyDebugger.py
Mac/Tools/IDE/PyDebugger.py
+7
-4
Mac/Tools/IDE/PyEdit.py
Mac/Tools/IDE/PyEdit.py
+1
-3
Python/sysmodule.c
Python/sysmodule.c
+0
-4
Tools/faqwiz/faqw.py
Tools/faqwiz/faqw.py
+1
-1
No files found.
Demo/classes/Complex.py
View file @
1dc0d91b
...
...
@@ -233,7 +233,7 @@ def checkop(expr, a, b, value, fuzz = 1e-6):
try
:
result
=
eval
(
expr
)
except
:
result
=
sys
.
exc_
type
result
=
sys
.
exc_
info
()[
0
]
print
'->'
,
result
if
isinstance
(
result
,
str
)
or
isinstance
(
value
,
str
):
ok
=
(
result
==
value
)
...
...
Demo/pdist/server.py
View file @
1dc0d91b
...
...
@@ -83,7 +83,7 @@ class Server:
method
=
getattr
(
self
,
methodname
)
reply
=
(
None
,
apply
(
method
,
args
),
id
)
except
:
reply
=
(
sys
.
exc_
type
,
sys
.
exc_value
,
id
)
reply
=
(
sys
.
exc_
info
()[:
2
]
,
id
)
if
id
<
0
and
reply
[:
2
]
==
(
None
,
None
):
if
self
.
_verbose
>
1
:
print
"Suppress reply"
return
1
...
...
Demo/sockets/gopher.py
View file @
1dc0d91b
...
...
@@ -191,7 +191,8 @@ def browse_menu(selector, host, port):
try
:
browserfunc
(
i_selector
,
i_host
,
i_port
)
except
(
IOError
,
socket
.
error
):
print
'***'
,
sys
.
exc_type
,
':'
,
sys
.
exc_value
t
,
v
,
tb
=
sys
.
exc_info
()
print
'***'
,
t
,
':'
,
v
else
:
print
'Unsupported object type'
...
...
Doc/api/exceptions.tex
View file @
1dc0d91b
...
...
@@ -23,12 +23,9 @@ carefully propagated, additional calls into the Python/C API may not
behave as intended and may fail in mysterious ways.
The error indicator consists of three Python objects corresponding to
\withsubitem
{
(in module sys)
}{
\ttindex
{
exc
_
type
}
\ttindex
{
exc
_
value
}
\ttindex
{
exc
_
traceback
}}
the Python variables
\code
{
sys.exc
_
type
}
,
\code
{
sys.exc
_
value
}
and
\code
{
sys.exc
_
traceback
}
. API functions exist to interact with the
error indicator in various ways. There is a separate error indicator
for each thread.
the result of
\code
{
sys.exc
_
info()
}
. API functions exist to interact
with the error indicator in various ways. There is a separate
error indicator for each thread.
% XXX Order of these should be more thoughtful.
% Either alphabetical or some kind of structure.
...
...
Doc/api/intro.tex
View file @
1dc0d91b
...
...
@@ -400,15 +400,12 @@ exception state.
The full exception state consists of three objects (all of which can
be
\NULL
): the exception type, the corresponding exception
value, and the traceback. These have the same meanings as the Python
\withsubitem
{
(in module sys)
}{
\ttindex
{
exc
_
type
}
\ttindex
{
exc
_
value
}
\ttindex
{
exc
_
traceback
}}
objects
\code
{
sys.exc
_
type
}
,
\code
{
sys.exc
_
value
}
, and
\code
{
sys.exc
_
traceback
}
; however, they are not the same: the Python
result of
\code
{
sys.exc
_
info()
}
; however, they are not the same: the Python
objects represent the last exception being handled by a Python
\keyword
{
try
}
\ldots\ \keyword
{
except
}
statement, while the C level
exception state only exists while an exception is being passed on
between C functions until it reaches the Python bytecode interpreter's
main loop, which takes care of transferring it to
\code
{
sys.exc
_
type
}
main loop, which takes care of transferring it to
\code
{
sys.exc
_
info()
}
and friends.
Note that starting with Python 1.5, the preferred, thread-safe way to
...
...
Doc/ext/extending.tex
View file @
1dc0d91b
...
...
@@ -120,9 +120,8 @@ variable is \NULL{} no exception has occurred. A second global
variable stores the ``associated value'' of the exception (the second
argument to
\keyword
{
raise
}
). A third variable contains the stack
traceback in case the error originated in Python code. These three
variables are the C equivalents of the Python variables
\code
{
sys.exc
_
type
}
,
\code
{
sys.exc
_
value
}
and
\code
{
sys.exc
_
traceback
}
(see
the section on module
\module
{
sys
}
in the
variables are the C equivalents of the result in Python of
\method
{
sys.exc
_
info()
}
(see the section on module
\module
{
sys
}
in the
\citetitle
[../lib/lib.html]
{
Python Library Reference
}
). It is
important to know about them to understand how errors are passed
around.
...
...
Doc/lib/libtraceback.tex
View file @
1dc0d91b
...
...
@@ -12,9 +12,8 @@ when you want to print stack traces under program control, such as in a
``wrapper'' around the interpreter.
The module uses traceback objects --- this is the object type that is
stored in the variables
\code
{
sys.exc
_
traceback
}
(deprecated) and
\code
{
sys.last
_
traceback
}
and returned as the third item from
\function
{
sys.exc
_
info()
}
.
stored in the
\code
{
sys.last
_
traceback
}
variable and returned
as the third item from
\function
{
sys.exc
_
info()
}
.
\obindex
{
traceback
}
The module defines the following functions:
...
...
@@ -41,11 +40,7 @@ with a caret indicating the approximate position of the error.
\end{funcdesc}
\begin{funcdesc}
{
print
_
exc
}{
\optional
{
limit
\optional
{
, file
}}}
This is a shorthand for
\code
{
print
_
exception(sys.exc
_
type,
sys.exc
_
value, sys.exc
_
traceback,
\var
{
limit
}
,
\var
{
file
}
)
}
. (In
fact, it uses
\function
{
sys.exc
_
info()
}
to retrieve the same
information in a thread-safe way instead of using the deprecated
variables.)
This is a shorthand for
\code
{
print
_
exception(*
\function
{
sys.exc
_
info()
}}
.
\end{funcdesc}
\begin{funcdesc}
{
format
_
exc
}{
\optional
{
limit
}}
...
...
Doc/ref/ref7.tex
View file @
1dc0d91b
...
...
@@ -250,21 +250,15 @@ occurs in the try clause of the inner handler, the outer handler will
not handle the exception.)
Before an except clause's suite is executed, details about the
exception are assigned to three variables in the
\module
{
sys
}
\refbimodindex
{
sys
}
module:
\code
{
sys.exc
_
type
}
receives
the object identifying the exception;
\code
{
sys.exc
_
value
}
receives
the exception's parameter;
\code
{
sys.exc
_
traceback
}
receives a
exception are stored in the
\module
{
sys
}
\refbimodindex
{
sys
}
module
and can be access via
\function
{
sys.exc
_
info()
}
.
\function
{
sys.exc
_
info()
}
returns a 3-tuple consisting of:
\code
{
exc
_
type
}
receives
the object identifying the exception;
\code
{
exc
_
value
}
receives
the exception's parameter;
\code
{
exc
_
traceback
}
receives a
traceback object
\obindex
{
traceback
}
(see section~
\ref
{
traceback
}
)
identifying the point in the program where the exception occurred.
These details are also available through the
\function
{
sys.exc
_
info()
}
function, which returns a tuple
\code
{
(
\var
{
exc
_
type
}
,
\var
{
exc
_
value
}
,
\var
{
exc
_
traceback
}
)
}
. Use of the corresponding variables is
deprecated in favor of this function, since their use is unsafe in a
threaded program. As of Python 1.5, the variables are restored to
their previous values (before the call) when returning from a function
that handled an exception.
\withsubitem
{
(in module sys)
}{
\ttindex
{
exc
_
type
}
\ttindex
{
exc
_
value
}
\ttindex
{
exc
_
traceback
}}
\function
{
sys.exc
_
info()
}
values are restored to their previous values
(before the call) when returning from a function that handled an exception.
The optional
\keyword
{
else
}
clause is executed if and when control
flows off the end of the
\keyword
{
try
}
clause.
\footnote
{
...
...
Lib/SimpleXMLRPCServer.py
View file @
1dc0d91b
...
...
@@ -261,7 +261,7 @@ class SimpleXMLRPCDispatcher:
except
:
# report exception back to server
response
=
xmlrpclib
.
dumps
(
xmlrpclib
.
Fault
(
1
,
"%s:%s"
%
(
sys
.
exc_type
,
sys
.
exc_value
)
),
xmlrpclib
.
Fault
(
1
,
"%s:%s"
%
sys
.
exc_info
()[:
2
]
),
encoding
=
self
.
encoding
,
allow_none
=
self
.
allow_none
,
)
...
...
@@ -362,7 +362,7 @@ class SimpleXMLRPCDispatcher:
except
:
results
.
append
(
{
'faultCode'
:
1
,
'faultString'
:
"%s:%s"
%
(
sys
.
exc_type
,
sys
.
exc_value
)
}
'faultString'
:
"%s:%s"
%
sys
.
exc_info
()[:
2
]
}
)
return
results
...
...
Lib/idlelib/WindowList.py
View file @
1dc0d91b
...
...
@@ -45,8 +45,8 @@ class WindowList:
try
:
callback
()
except
:
print
"warning: callback failed in WindowList"
,
\
sys
.
exc_type
,
":"
,
sys
.
exc_value
t
,
v
,
tb
=
sys
.
exc_info
()
print
"warning: callback failed in WindowList"
,
t
,
":"
,
v
registry
=
WindowList
()
...
...
Lib/lib-tk/Tkinter.py
View file @
1dc0d91b
...
...
@@ -1108,7 +1108,7 @@ class Misc:
def
_report_exception
(
self
):
"""Internal function."""
import
sys
exc
,
val
,
tb
=
sys
.
exc_
type
,
sys
.
exc_value
,
sys
.
exc_traceback
exc
,
val
,
tb
=
sys
.
exc_
info
()
root
=
self
.
_root
()
root
.
report_callback_exception
(
exc
,
val
,
tb
)
def
_configure
(
self
,
cmd
,
cnf
,
kw
):
...
...
Lib/traceback.py
View file @
1dc0d91b
...
...
@@ -203,9 +203,7 @@ def _some_str(value):
def
print_exc
(
limit
=
None
,
file
=
None
):
"""Shorthand for 'print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback, limit, file)'.
(In fact, it uses sys.exc_info() to retrieve the same information
in a thread-safe way.)"""
"""Shorthand for 'print_exception(*sys.exc_info(), limit, file)'."""
if
file
is
None
:
file
=
sys
.
stderr
try
:
...
...
Mac/Tools/IDE/PyDebugger.py
View file @
1dc0d91b
...
...
@@ -105,7 +105,8 @@ class Debugger(bdb.Bdb):
raise
'spam'
except
:
pass
frame
=
sys
.
exc_traceback
.
tb_frame
tb
=
sys
.
exc_info
()[
2
]
frame
=
tb
.
tb_frame
while
frame
is
not
None
:
del
frame
.
f_trace
frame
=
frame
.
f_back
...
...
@@ -527,7 +528,7 @@ class Debugger(bdb.Bdb):
raise
bdb
.
BdbQuit
except
:
print
'XXX Exception during debugger interaction.'
,
\
self
.
formatexception
(
sys
.
exc_
type
,
sys
.
exc_value
)
self
.
formatexception
(
sys
.
exc_
info
[:
2
]
)
import
traceback
traceback
.
print_exc
()
return
self
.
trace_dispatch
...
...
@@ -855,7 +856,8 @@ def startfromhere():
try
:
raise
'spam'
except
:
frame
=
sys
.
exc_traceback
.
tb_frame
.
f_back
tb
=
sys
.
exc_info
()[
2
]
frame
=
tb
.
tb_frame
.
f_back
d
.
start
(
frame
)
def
startfrombottom
():
...
...
@@ -876,7 +878,8 @@ def _getbottomframe():
raise
'spam'
except
:
pass
frame
=
sys
.
exc_traceback
.
tb_frame
tb
=
sys
.
exc_info
()[
2
]
frame
=
tb
.
tb_frame
while
1
:
if
frame
.
f_code
.
co_name
==
'mainloop'
or
frame
.
f_back
is
None
:
break
...
...
Mac/Tools/IDE/PyEdit.py
View file @
1dc0d91b
...
...
@@ -1212,7 +1212,7 @@ def execstring(pytext, globals, locals, filename="<string>", debugging=0,
except
:
if
debugging
:
sys
.
settrace
(
None
)
PyDebugger
.
postmortem
(
sys
.
exc_type
,
sys
.
exc_value
,
sys
.
exc_traceback
)
PyDebugger
.
postmortem
(
*
sys
.
exc_info
()
)
return
else
:
tracebackwindow
.
traceback
(
1
,
filename
)
...
...
@@ -1289,7 +1289,6 @@ class _EditorDefaultSettings:
settings
=
FontSettings
.
FontDialog
(
self
.
fontsettings
,
self
.
tabsettings
)
if
settings
:
self
.
fontsettings
,
self
.
tabsettings
=
settings
sys
.
exc_traceback
=
None
self
.
w
.
fonttext
.
set
(
self
.
template
%
(
self
.
fontsettings
[
0
],
self
.
fontsettings
[
2
]))
def
close
(
self
):
...
...
@@ -1327,7 +1326,6 @@ def geteditorprefs():
fontsettings
=
prefs
.
pyedit
.
fontsettings
=
(
"Geneva"
,
0
,
10
,
(
0
,
0
,
0
))
tabsettings
=
prefs
.
pyedit
.
tabsettings
=
(
8
,
1
)
windowsize
=
prefs
.
pyedit
.
windowsize
=
(
500
,
250
)
sys
.
exc_traceback
=
None
return
fontsettings
,
tabsettings
,
windowsize
def
seteditorprefs
(
fontsettings
,
tabsettings
,
windowsize
):
...
...
Python/sysmodule.c
View file @
1dc0d91b
...
...
@@ -179,10 +179,6 @@ sys_exc_clear(PyObject *self, PyObject *noargs)
Py_XDECREF
(
tmp_type
);
Py_XDECREF
(
tmp_value
);
Py_XDECREF
(
tmp_tb
);
/* For b/w compatibility */
PySys_SetObject
(
"exc_type"
,
Py_None
);
PySys_SetObject
(
"exc_value"
,
Py_None
);
PySys_SetObject
(
"exc_traceback"
,
Py_None
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
...
...
Tools/faqwiz/faqw.py
View file @
1dc0d91b
...
...
@@ -27,7 +27,7 @@ try:
except
SystemExit
,
n
:
sys
.
exit
(
n
)
except
:
t
,
v
,
tb
=
sys
.
exc_
type
,
sys
.
exc_value
,
sys
.
exc_traceback
t
,
v
,
tb
=
sys
.
exc_
info
()
print
import
cgi
cgi
.
print_exception
(
t
,
v
,
tb
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment