Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
871cf161
Kaydet (Commit)
871cf161
authored
Eki 20, 1997
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Documented exc_info(); also updated exc_type and last_type docs.
üst
fb5cef11
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
114 additions
and
36 deletions
+114
-36
libsys.tex
Doc/lib/libsys.tex
+57
-18
libsys.tex
Doc/libsys.tex
+57
-18
No files found.
Doc/lib/libsys.tex
Dosyayı görüntüle @
871cf161
...
@@ -26,19 +26,52 @@ It is always available.
...
@@ -26,19 +26,52 @@ It is always available.
modules.)
modules.)
\end{datadesc}
\end{datadesc}
\begin{funcdesc}
{
exc
_
info
}{}
This function returns a tuple of three values that give information
about the exception that is currently being handled. The information
returned is specific both to the current thread and to the current
stack frame. If the current stack frame is not handling an exception,
the information is taken from the calling stack frame, or its caller,
and so on until a stack frame is found that is handling an exception.
Here, ``handling an exception'' is defined as ``executing or having
executed an
\code
{
except
}
clause.'' For any stack frame, only
information about the most recently handled exception is accessible.
If no exception is being handled anywhere on the stack, a tuple
containing three
\code
{
None
}
values is returned. Otherwise, the
values returned are
\code
{
(
\var
{
type
}
,
\var
{
value
}
,
\var
{
traceback
}
)
}
.
Their meaning is:
\var
{
type
}
gets the exception type of the exception
being handled (a string or class object);
\var
{
value
}
gets the
exception parameter (its
\dfn
{
associated value
}
or the second argument
to
\code
{
raise
}
, which is always a class instance if the exception
type is a class object);
\var
{
traceback
}
gets a traceback object (see
the Reference Manual) which encapsulates the call stack at the point
where the exception originally occurred.
\obindex
{
traceback
}
\strong
{
Warning:
}
assigning the
\var
{
traceback
}
return value to a
local variable in a function that is handling an exception will cause
a circular reference. This will prevent anything referenced by a local
variable in the same function or by the traceback from being garbage
collected. Since most functions don't need access to the traceback,
the best solution is to use something like
\code
{
type, value = sys.exc
_
info()[:2]
}
to extract only the exception type and value. If you do need the
traceback, make sure to delete it after use (best done with a
\code
{
try-finally
}
statement) or to call
\code
{
sys.exc
_
info()
}
in a
function that does not itself handle an exception.
\end{funcdesc}
\begin{datadesc}
{
exc
_
type
}
\begin{datadesc}
{
exc
_
type
}
\dataline
{
exc
_
value
}
\dataline
{
exc
_
value
}
\dataline
{
exc
_
traceback
}
\dataline
{
exc
_
traceback
}
These three variables are not always defined; they are set when an
Use of these three variables is deprecated; they contain the same
exception handler (an
\code
{
except
}
clause of a
\code
{
try
}
statement) is
values as returned by
\code
{
sys.exc
_
info()
}
above. However, since
invoked. Their meaning is:
\code
{
exc
_
type
}
gets the exception type of
they are global variables, they are not specific to the current
the exception being handled;
\code
{
exc
_
value
}
gets the exception
thread, so their use is not safe in a multi-threaded program. When no
parameter (its
\dfn
{
associated value
}
or the second argument to
exception is being handled,
\code
{
sys.exc
_
type
}
is set to
\code
{
None
}
\code
{
raise
}
);
\code
{
exc
_
traceback
}
gets a traceback object (see the
and the other two are undefined.
Reference Manual) which
encapsulates the call stack at the point where the exception
originally occurred.
\obindex
{
traceback
}
\end{datadesc}
\end{datadesc}
\begin{datadesc}
{
exec
_
prefix
}
\begin{datadesc}
{
exec
_
prefix
}
...
@@ -74,14 +107,20 @@ where \emph{VER} is equal to \code{sys.version[:3]}.
...
@@ -74,14 +107,20 @@ where \emph{VER} is equal to \code{sys.version[:3]}.
\begin{datadesc}
{
last
_
type
}
\begin{datadesc}
{
last
_
type
}
\dataline
{
last
_
value
}
\dataline
{
last
_
value
}
\dataline
{
last
_
traceback
}
\dataline
{
last
_
traceback
}
These three variables are not always defined; they are set when an
These three variables are not always defined; they are set when an
exception is not handled and the interpreter prints an error message
exception is not handled and the interpreter prints an error message
and a stack traceback. Their intended use is to allow an interactive
and a stack traceback. Their intended use is to allow an interactive
user to import a debugger module and engage in post-mortem debugging
user to import a debugger module and engage in post-mortem debugging
without having to re-execute the command that caused the error (which
without having to re-execute the command that caused the error.
may be hard to reproduce). The meaning of the variables is the same
(Typical use is
\code
{
import pdb; pdb.pm()
}
to enter the post-mortem
as that of
\code
{
exc
_
type
}
,
\code
{
exc
_
value
}
and
\code
{
exc
_
tracaback
}
,
debugger; see the chapter ``The Python Debugger'' for more
respectively.
information.)
\stmodindex
{
pdb
}
The meaning of the variables is the same
as that of the return values from
\code
{
sys.exc
_
info()
}
above.
(Since there is only one interactive thread, thread-safety is not a
concern for these variables, unlike for
\code
{
sys.exc
_
type
}
etc.)
\end{datadesc}
\end{datadesc}
\begin{datadesc}
{
modules
}
\begin{datadesc}
{
modules
}
...
...
Doc/libsys.tex
Dosyayı görüntüle @
871cf161
...
@@ -26,19 +26,52 @@ It is always available.
...
@@ -26,19 +26,52 @@ It is always available.
modules.)
modules.)
\end{datadesc}
\end{datadesc}
\begin{funcdesc}
{
exc
_
info
}{}
This function returns a tuple of three values that give information
about the exception that is currently being handled. The information
returned is specific both to the current thread and to the current
stack frame. If the current stack frame is not handling an exception,
the information is taken from the calling stack frame, or its caller,
and so on until a stack frame is found that is handling an exception.
Here, ``handling an exception'' is defined as ``executing or having
executed an
\code
{
except
}
clause.'' For any stack frame, only
information about the most recently handled exception is accessible.
If no exception is being handled anywhere on the stack, a tuple
containing three
\code
{
None
}
values is returned. Otherwise, the
values returned are
\code
{
(
\var
{
type
}
,
\var
{
value
}
,
\var
{
traceback
}
)
}
.
Their meaning is:
\var
{
type
}
gets the exception type of the exception
being handled (a string or class object);
\var
{
value
}
gets the
exception parameter (its
\dfn
{
associated value
}
or the second argument
to
\code
{
raise
}
, which is always a class instance if the exception
type is a class object);
\var
{
traceback
}
gets a traceback object (see
the Reference Manual) which encapsulates the call stack at the point
where the exception originally occurred.
\obindex
{
traceback
}
\strong
{
Warning:
}
assigning the
\var
{
traceback
}
return value to a
local variable in a function that is handling an exception will cause
a circular reference. This will prevent anything referenced by a local
variable in the same function or by the traceback from being garbage
collected. Since most functions don't need access to the traceback,
the best solution is to use something like
\code
{
type, value = sys.exc
_
info()[:2]
}
to extract only the exception type and value. If you do need the
traceback, make sure to delete it after use (best done with a
\code
{
try-finally
}
statement) or to call
\code
{
sys.exc
_
info()
}
in a
function that does not itself handle an exception.
\end{funcdesc}
\begin{datadesc}
{
exc
_
type
}
\begin{datadesc}
{
exc
_
type
}
\dataline
{
exc
_
value
}
\dataline
{
exc
_
value
}
\dataline
{
exc
_
traceback
}
\dataline
{
exc
_
traceback
}
These three variables are not always defined; they are set when an
Use of these three variables is deprecated; they contain the same
exception handler (an
\code
{
except
}
clause of a
\code
{
try
}
statement) is
values as returned by
\code
{
sys.exc
_
info()
}
above. However, since
invoked. Their meaning is:
\code
{
exc
_
type
}
gets the exception type of
they are global variables, they are not specific to the current
the exception being handled;
\code
{
exc
_
value
}
gets the exception
thread, so their use is not safe in a multi-threaded program. When no
parameter (its
\dfn
{
associated value
}
or the second argument to
exception is being handled,
\code
{
sys.exc
_
type
}
is set to
\code
{
None
}
\code
{
raise
}
);
\code
{
exc
_
traceback
}
gets a traceback object (see the
and the other two are undefined.
Reference Manual) which
encapsulates the call stack at the point where the exception
originally occurred.
\obindex
{
traceback
}
\end{datadesc}
\end{datadesc}
\begin{datadesc}
{
exec
_
prefix
}
\begin{datadesc}
{
exec
_
prefix
}
...
@@ -74,14 +107,20 @@ where \emph{VER} is equal to \code{sys.version[:3]}.
...
@@ -74,14 +107,20 @@ where \emph{VER} is equal to \code{sys.version[:3]}.
\begin{datadesc}
{
last
_
type
}
\begin{datadesc}
{
last
_
type
}
\dataline
{
last
_
value
}
\dataline
{
last
_
value
}
\dataline
{
last
_
traceback
}
\dataline
{
last
_
traceback
}
These three variables are not always defined; they are set when an
These three variables are not always defined; they are set when an
exception is not handled and the interpreter prints an error message
exception is not handled and the interpreter prints an error message
and a stack traceback. Their intended use is to allow an interactive
and a stack traceback. Their intended use is to allow an interactive
user to import a debugger module and engage in post-mortem debugging
user to import a debugger module and engage in post-mortem debugging
without having to re-execute the command that caused the error (which
without having to re-execute the command that caused the error.
may be hard to reproduce). The meaning of the variables is the same
(Typical use is
\code
{
import pdb; pdb.pm()
}
to enter the post-mortem
as that of
\code
{
exc
_
type
}
,
\code
{
exc
_
value
}
and
\code
{
exc
_
tracaback
}
,
debugger; see the chapter ``The Python Debugger'' for more
respectively.
information.)
\stmodindex
{
pdb
}
The meaning of the variables is the same
as that of the return values from
\code
{
sys.exc
_
info()
}
above.
(Since there is only one interactive thread, thread-safety is not a
concern for these variables, unlike for
\code
{
sys.exc
_
type
}
etc.)
\end{datadesc}
\end{datadesc}
\begin{datadesc}
{
modules
}
\begin{datadesc}
{
modules
}
...
...
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