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
f4ffae2b
Kaydet (Commit)
f4ffae2b
authored
Eki 22, 2009
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#7035: improve docs of the various <method>_errors() functions, and give them docstrings.
üst
030d6581
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
20 deletions
+42
-20
codecs.rst
Doc/library/codecs.rst
+25
-15
codecs.c
Python/codecs.c
+17
-5
No files found.
Doc/library/codecs.rst
Dosyayı görüntüle @
f4ffae2b
...
@@ -54,7 +54,7 @@ It defines the following functions:
...
@@ -54,7 +54,7 @@ It defines the following functions:
*incrementalencoder* and *incrementaldecoder*: These have to be factory
*incrementalencoder* and *incrementaldecoder*: These have to be factory
functions providing the following interface:
functions providing the following interface:
``factory(errors='strict')``
``factory(errors='strict')``
The factory functions must return objects providing the interfaces defined by
The factory functions must return objects providing the interfaces defined by
the base classes :class:`IncrementalEncoder` and :class:`IncrementalDecoder`,
the base classes :class:`IncrementalEncoder` and :class:`IncrementalDecoder`,
...
@@ -63,20 +63,24 @@ It defines the following functions:
...
@@ -63,20 +63,24 @@ It defines the following functions:
*streamreader* and *streamwriter*: These have to be factory functions providing
*streamreader* and *streamwriter*: These have to be factory functions providing
the following interface:
the following interface:
``factory(stream, errors='strict')``
``factory(stream, errors='strict')``
The factory functions must return objects providing the interfaces defined by
The factory functions must return objects providing the interfaces defined by
the base classes :class:`StreamWriter` and :class:`StreamReader`, respectively.
the base classes :class:`StreamWriter` and :class:`StreamReader`, respectively.
Stream codecs can maintain state.
Stream codecs can maintain state.
Possible values for errors are ``'strict'`` (raise an exception in case of an
Possible values for errors are
encoding error), ``'replace'`` (replace malformed data with a suitable
replacement marker, such as ``'?'``), ``'ignore'`` (ignore malformed data and
* ``'strict'``: raise an exception in case of an encoding error
continue without further notice), ``'xmlcharrefreplace'`` (replace with the
* ``'replace'``: replace malformed data with a suitable replacement marker,
appropriate XML character reference (for encoding only)) and
such as ``'?'`` or ``'\ufffd'``
``'backslashreplace'`` (replace with backslashed escape sequences (for encoding
* ``'ignore'``: ignore malformed data and continue without further notice
only)) as well as any other error handling name defined via
* ``'xmlcharrefreplace'``: replace with the appropriate XML character
:func:`register_error`.
reference (for encoding only)
* ``'backslashreplace'``: replace with backslashed escape sequences (for
encoding only
as well as any other error handling name defined via :func:`register_error`.
In case a search function cannot find a given encoding, it should return
In case a search function cannot find a given encoding, it should return
``None``.
``None``.
...
@@ -177,27 +181,33 @@ functions which use :func:`lookup` for the codec lookup:
...
@@ -177,27 +181,33 @@ functions which use :func:`lookup` for the codec lookup:
.. function:: strict_errors(exception)
.. function:: strict_errors(exception)
Implements the ``strict`` error handling.
Implements the ``strict`` error handling: each encoding or decoding error
raises a :exc:`UnicodeError`.
.. function:: replace_errors(exception)
.. function:: replace_errors(exception)
Implements the ``replace`` error handling.
Implements the ``replace`` error handling: malformed data is replaced with a
suitable replacement character such as ``'?'`` in bytestrings and
``'\ufffd'`` in Unicode strings.
.. function:: ignore_errors(exception)
.. function:: ignore_errors(exception)
Implements the ``ignore`` error handling.
Implements the ``ignore`` error handling: malformed data is ignored and
encoding or decoding is continued without further notice.
.. function:: xmlcharrefreplace_errors(exception)
.. function:: xmlcharrefreplace_errors(exception)
Implements the ``xmlcharrefreplace`` error handling.
Implements the ``xmlcharrefreplace`` error handling (for encoding only): the
unencodable character is replaced by an appropriate XML character reference.
.. function:: backslashreplace_errors(exception)
.. function:: backslashreplace_errors(exception)
Implements the ``backslashreplace`` error handling.
Implements the ``backslashreplace`` error handling (for encoding only): the
unencodable character is replaced by a backslashed escape sequence.
To simplify working with encoded files or stream, the module also defines these
To simplify working with encoded files or stream, the module also defines these
utility functions:
utility functions:
...
...
Python/codecs.c
Dosyayı görüntüle @
f4ffae2b
...
@@ -774,7 +774,9 @@ static int _PyCodecRegistry_Init(void)
...
@@ -774,7 +774,9 @@ static int _PyCodecRegistry_Init(void)
{
{
"strict_errors"
,
"strict_errors"
,
strict_errors
,
strict_errors
,
METH_O
METH_O
,
PyDoc_STR
(
"Implements the 'strict' error handling, which "
"raises a UnicodeError on coding errors."
)
}
}
},
},
#ifdef Py_USING_UNICODE
#ifdef Py_USING_UNICODE
...
@@ -783,7 +785,9 @@ static int _PyCodecRegistry_Init(void)
...
@@ -783,7 +785,9 @@ static int _PyCodecRegistry_Init(void)
{
{
"ignore_errors"
,
"ignore_errors"
,
ignore_errors
,
ignore_errors
,
METH_O
METH_O
,
PyDoc_STR
(
"Implements the 'ignore' error handling, which "
"ignores malformed data and continues."
)
}
}
},
},
{
{
...
@@ -791,7 +795,9 @@ static int _PyCodecRegistry_Init(void)
...
@@ -791,7 +795,9 @@ static int _PyCodecRegistry_Init(void)
{
{
"replace_errors"
,
"replace_errors"
,
replace_errors
,
replace_errors
,
METH_O
METH_O
,
PyDoc_STR
(
"Implements the 'replace' error handling, which "
"replaces malformed data with a replacement marker."
)
}
}
},
},
{
{
...
@@ -799,7 +805,10 @@ static int _PyCodecRegistry_Init(void)
...
@@ -799,7 +805,10 @@ static int _PyCodecRegistry_Init(void)
{
{
"xmlcharrefreplace_errors"
,
"xmlcharrefreplace_errors"
,
xmlcharrefreplace_errors
,
xmlcharrefreplace_errors
,
METH_O
METH_O
,
PyDoc_STR
(
"Implements the 'xmlcharrefreplace' error handling, "
"which replaces an unencodable character with the "
"appropriate XML character reference."
)
}
}
},
},
{
{
...
@@ -807,7 +816,10 @@ static int _PyCodecRegistry_Init(void)
...
@@ -807,7 +816,10 @@ static int _PyCodecRegistry_Init(void)
{
{
"backslashreplace_errors"
,
"backslashreplace_errors"
,
backslashreplace_errors
,
backslashreplace_errors
,
METH_O
METH_O
,
PyDoc_STR
(
"Implements the 'backslashreplace' error handling, "
"which replaces an unencodable character with a "
"backslashed escape sequence."
)
}
}
}
}
#endif
#endif
...
...
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