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
fb6fd5d0
Kaydet (Commit)
fb6fd5d0
authored
Ock 07, 2011
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#10856: document (Base)Exception.args better.
üst
7603fa07
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
12 deletions
+26
-12
exceptions.rst
Doc/library/exceptions.rst
+26
-12
No files found.
Doc/library/exceptions.rst
Dosyayı görüntüle @
fb6fd5d0
...
@@ -18,12 +18,10 @@ equivalent, even if they have the same name.
...
@@ -18,12 +18,10 @@ equivalent, even if they have the same name.
The built-in exceptions listed below can be generated by the interpreter or
The built-in exceptions listed below can be generated by the interpreter or
built-in functions. Except where mentioned, they have an "associated value"
built-in functions. Except where mentioned, they have an "associated value"
indicating the detailed cause of the error. This may be a string or a tuple
indicating the detailed cause of the error. This may be a string or a tuple of
containing several items of information (e.g., an error code and a string
several items of information (e.g., an error code and a string explaining the
explaining the code). The associated value is usually passed to the exception
code). The associated value is usually passed as arguments to the exception
class's constructor. If the exception class is derived from the standard root
class's constructor.
class :exc:`BaseException`, the associated value is present as the exception
instance's :attr:`args` attribute.
User code can raise built-in exceptions. This can be used to test an exception
User code can raise built-in exceptions. This can be used to test an exception
handler or to report an error condition "just like" the situation in which the
handler or to report an error condition "just like" the situation in which the
...
@@ -38,16 +36,32 @@ defining exceptions is available in the Python Tutorial under
...
@@ -38,16 +36,32 @@ defining exceptions is available in the Python Tutorial under
The following exceptions are used mostly as base classes for other exceptions.
The following exceptions are used mostly as base classes for other exceptions.
.. XXX document with_traceback()
.. exception:: BaseException
.. exception:: BaseException
The base class for all built-in exceptions. It is not meant to be directly
The base class for all built-in exceptions. It is not meant to be directly
inherited by user-defined classes (for that use :exc:`Exception`). If
inherited by user-defined classes (for that
,
use :exc:`Exception`). If
:func:`bytes` or :func:`str` is called on an instance of this class, the
:func:`bytes` or :func:`str` is called on an instance of this class, the
representation of the argument(s) to the instance are returned or the empty
representation of the argument(s) to the instance are returned, or the empty
string when there were no arguments. All arguments are stored in :attr:`args`
string when there were no arguments.
as a tuple.
.. attribute:: args
The tuple of arguments given to the exception constructor. Some built-in
exceptions (like :exc:`IOError`) expect a certain number of arguments and
assign a special meaning to the elements of this tuple, while others are
usually called only with a single string giving an error message.
.. method:: with_traceback(tb)
This method sets *tb* as the new traceback for the exception and returns
the exception object. It is usually used in exception handling code like
this::
try:
...
except SomeException:
tb = sys.exc_info()[2]
raise OtherException(...).with_traceback(tb)
.. exception:: Exception
.. exception:: Exception
...
...
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