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
555a24f2
Kaydet (Commit)
555a24f2
authored
Ara 27, 2010
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #9738: Document encodings of error and warning functions
üst
ab9d8d64
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
24 deletions
+78
-24
exceptions.rst
Doc/c-api/exceptions.rst
+16
-9
pyerrors.h
Include/pyerrors.h
+46
-11
warnings.h
Include/warnings.h
+16
-4
No files found.
Doc/c-api/exceptions.rst
Dosyayı görüntüle @
555a24f2
...
@@ -148,7 +148,8 @@ in various ways. There is a separate error indicator for each thread.
...
@@ -148,7 +148,8 @@ in various ways. There is a separate error indicator for each thread.
This function sets the error indicator and returns *NULL*. *exception*
This function sets the error indicator and returns *NULL*. *exception*
should be a Python exception class. The *format* and subsequent
should be a Python exception class. The *format* and subsequent
parameters help format the error message; they have the same meaning and
parameters help format the error message; they have the same meaning and
values as in :c:func:`PyUnicode_FromFormat`.
values as in :c:func:`PyUnicode_FromFormat`. *format* is an ASCII-encoding
string.
.. c:function:: void PyErr_SetNone(PyObject *type)
.. c:function:: void PyErr_SetNone(PyObject *type)
...
@@ -218,7 +219,8 @@ in various ways. There is a separate error indicator for each thread.
...
@@ -218,7 +219,8 @@ in various ways. There is a separate error indicator for each thread.
Similar to :c:func:`PyErr_SetFromWindowsErr`, with the additional behavior that
Similar to :c:func:`PyErr_SetFromWindowsErr`, with the additional behavior that
if *filename* is not *NULL*, it is passed to the constructor of
if *filename* is not *NULL*, it is passed to the constructor of
:exc:`WindowsError` as a third parameter. Availability: Windows.
:exc:`WindowsError` as a third parameter. *filename* is decoded from UTF-8.
Availability: Windows.
.. c:function:: PyObject* PyErr_SetExcFromWindowsErrWithFilename(PyObject *type, int ierr, char *filename)
.. c:function:: PyObject* PyErr_SetExcFromWindowsErrWithFilename(PyObject *type, int ierr, char *filename)
...
@@ -232,7 +234,8 @@ in various ways. There is a separate error indicator for each thread.
...
@@ -232,7 +234,8 @@ in various ways. There is a separate error indicator for each thread.
Set file, line, and offset information for the current exception. If the
Set file, line, and offset information for the current exception. If the
current exception is not a :exc:`SyntaxError`, then it sets additional
current exception is not a :exc:`SyntaxError`, then it sets additional
attributes, which make the exception printing subsystem think the exception
attributes, which make the exception printing subsystem think the exception
is a :exc:`SyntaxError`.
is a :exc:`SyntaxError`. *filename* is decoded from the filesystem encoding
(:func:`sys.getfilesystemencoding`).
.. versionadded:: 3.2
.. versionadded:: 3.2
...
@@ -254,7 +257,7 @@ in various ways. There is a separate error indicator for each thread.
...
@@ -254,7 +257,7 @@ in various ways. There is a separate error indicator for each thread.
.. c:function:: int PyErr_WarnEx(PyObject *category, char *message, int stack_level)
.. c:function:: int PyErr_WarnEx(PyObject *category, char *message, int stack_level)
Issue a warning message. The *category* argument is a warning category (see
Issue a warning message. The *category* argument is a warning category (see
below) or *NULL*; the *message* argument is a
message
string. *stack_level* is a
below) or *NULL*; the *message* argument is a
n UTF-8 encoded
string. *stack_level* is a
positive number giving a number of stack frames; the warning will be issued from
positive number giving a number of stack frames; the warning will be issued from
the currently executing line of code in that stack frame. A *stack_level* of 1
the currently executing line of code in that stack frame. A *stack_level* of 1
is the function calling :c:func:`PyErr_WarnEx`, 2 is the function above that,
is the function calling :c:func:`PyErr_WarnEx`, 2 is the function above that,
...
@@ -294,13 +297,15 @@ in various ways. There is a separate error indicator for each thread.
...
@@ -294,13 +297,15 @@ in various ways. There is a separate error indicator for each thread.
is a straightforward wrapper around the Python function
is a straightforward wrapper around the Python function
:func:`warnings.warn_explicit`, see there for more information. The *module*
:func:`warnings.warn_explicit`, see there for more information. The *module*
and *registry* arguments may be set to *NULL* to get the default effect
and *registry* arguments may be set to *NULL* to get the default effect
described there.
described there. *message*, *filename* and *module* are UTF-8 encoded
strings.
.. c:function:: int PyErr_WarnFormat(PyObject *category, Py_ssize_t stack_level, const char *format, ...)
.. c:function:: int PyErr_WarnFormat(PyObject *category, Py_ssize_t stack_level, const char *format, ...)
Function similar to :c:func:`PyErr_WarnEx`, but use
Function similar to :c:func:`PyErr_WarnEx`, but use
:c:func:`PyUnicode_FromFormat` to format the warning message.
:c:func:`PyUnicode_FromFormat` to format the warning message. *format* is
an ASCII-encoded string.
.. versionadded:: 3.2
.. versionadded:: 3.2
...
@@ -437,17 +442,19 @@ The following functions are used to create and modify Unicode exceptions from C.
...
@@ -437,17 +442,19 @@ The following functions are used to create and modify Unicode exceptions from C.
.. c:function:: PyObject* PyUnicodeDecodeError_Create(const char *encoding, const char *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
.. c:function:: PyObject* PyUnicodeDecodeError_Create(const char *encoding, const char *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
Create a :class:`UnicodeDecodeError` object with the attributes *encoding*,
Create a :class:`UnicodeDecodeError` object with the attributes *encoding*,
*object*, *length*, *start*, *end* and *reason*.
*object*, *length*, *start*, *end* and *reason*. *encoding* and *reason* are
UTF-8 encoded strings.
.. c:function:: PyObject* PyUnicodeEncodeError_Create(const char *encoding, const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
.. c:function:: PyObject* PyUnicodeEncodeError_Create(const char *encoding, const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
Create a :class:`UnicodeEncodeError` object with the attributes *encoding*,
Create a :class:`UnicodeEncodeError` object with the attributes *encoding*,
*object*, *length*, *start*, *end* and *reason*.
*object*, *length*, *start*, *end* and *reason*. *encoding* and *reason* are
UTF-8 encoded strings.
.. c:function:: PyObject* PyUnicodeTranslateError_Create(const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
.. c:function:: PyObject* PyUnicodeTranslateError_Create(const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
Create a :class:`UnicodeTranslateError` object with the attributes *object*,
Create a :class:`UnicodeTranslateError` object with the attributes *object*,
*length*, *start*, *end* and *reason*.
*length*, *start*, *end* and *reason*.
*reason* is an UTF-8 encoded string.
.. c:function:: PyObject* PyUnicodeDecodeError_GetEncoding(PyObject *exc)
.. c:function:: PyObject* PyUnicodeDecodeError_GetEncoding(PyObject *exc)
PyObject* PyUnicodeEncodeError_GetEncoding(PyObject *exc)
PyObject* PyUnicodeEncodeError_GetEncoding(PyObject *exc)
...
...
Include/pyerrors.h
Dosyayı görüntüle @
555a24f2
...
@@ -201,7 +201,9 @@ PyAPI_FUNC(PyObject *) PyErr_Format(
...
@@ -201,7 +201,9 @@ PyAPI_FUNC(PyObject *) PyErr_Format(
PyAPI_FUNC
(
PyObject
*
)
PyErr_SetFromWindowsErrWithFilenameObject
(
PyAPI_FUNC
(
PyObject
*
)
PyErr_SetFromWindowsErrWithFilenameObject
(
int
,
const
char
*
);
int
,
const
char
*
);
PyAPI_FUNC
(
PyObject
*
)
PyErr_SetFromWindowsErrWithFilename
(
PyAPI_FUNC
(
PyObject
*
)
PyErr_SetFromWindowsErrWithFilename
(
int
,
const
char
*
);
int
ierr
,
const
char
*
filename
/* decoded from UTF-8 */
);
#ifndef Py_LIMITED_API
#ifndef Py_LIMITED_API
/* XXX redeclare to use WSTRING */
/* XXX redeclare to use WSTRING */
PyAPI_FUNC
(
PyObject
*
)
PyErr_SetFromWindowsErrWithUnicodeFilename
(
PyAPI_FUNC
(
PyObject
*
)
PyErr_SetFromWindowsErrWithUnicodeFilename
(
...
@@ -211,7 +213,10 @@ PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int);
...
@@ -211,7 +213,10 @@ PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int);
PyAPI_FUNC
(
PyObject
*
)
PyErr_SetExcFromWindowsErrWithFilenameObject
(
PyAPI_FUNC
(
PyObject
*
)
PyErr_SetExcFromWindowsErrWithFilenameObject
(
PyObject
*
,
int
,
PyObject
*
);
PyObject
*
,
int
,
PyObject
*
);
PyAPI_FUNC
(
PyObject
*
)
PyErr_SetExcFromWindowsErrWithFilename
(
PyAPI_FUNC
(
PyObject
*
)
PyErr_SetExcFromWindowsErrWithFilename
(
PyObject
*
,
int
,
const
char
*
);
PyObject
*
exc
,
int
ierr
,
const
char
*
filename
/* decoded from UTF-8 */
);
#ifndef Py_LIMITED_API
#ifndef Py_LIMITED_API
PyAPI_FUNC
(
PyObject
*
)
PyErr_SetExcFromWindowsErrWithUnicodeFilename
(
PyAPI_FUNC
(
PyObject
*
)
PyErr_SetExcFromWindowsErrWithUnicodeFilename
(
PyObject
*
,
int
,
const
Py_UNICODE
*
);
PyObject
*
,
int
,
const
Py_UNICODE
*
);
...
@@ -243,27 +248,51 @@ int PySignal_SetWakeupFd(int fd);
...
@@ -243,27 +248,51 @@ int PySignal_SetWakeupFd(int fd);
#endif
#endif
/* Support for adding program text to SyntaxErrors */
/* Support for adding program text to SyntaxErrors */
PyAPI_FUNC
(
void
)
PyErr_SyntaxLocation
(
const
char
*
,
int
);
PyAPI_FUNC
(
void
)
PyErr_SyntaxLocation
(
PyAPI_FUNC
(
void
)
PyErr_SyntaxLocationEx
(
const
char
*
,
int
,
int
);
const
char
*
filename
,
/* decoded from the filesystem encoding */
PyAPI_FUNC
(
PyObject
*
)
PyErr_ProgramText
(
const
char
*
,
int
);
int
lineno
);
PyAPI_FUNC
(
void
)
PyErr_SyntaxLocationEx
(
const
char
*
filename
,
/* decoded from the filesystem encoding */
int
lineno
,
int
col_offset
);
PyAPI_FUNC
(
PyObject
*
)
PyErr_ProgramText
(
const
char
*
filename
,
/* decoded from the filesystem encoding */
int
lineno
);
/* The following functions are used to create and modify unicode
/* The following functions are used to create and modify unicode
exceptions from C */
exceptions from C */
/* create a UnicodeDecodeError object */
/* create a UnicodeDecodeError object */
PyAPI_FUNC
(
PyObject
*
)
PyUnicodeDecodeError_Create
(
PyAPI_FUNC
(
PyObject
*
)
PyUnicodeDecodeError_Create
(
const
char
*
,
const
char
*
,
Py_ssize_t
,
Py_ssize_t
,
Py_ssize_t
,
const
char
*
);
const
char
*
encoding
,
/* UTF-8 encoded string */
const
char
*
object
,
Py_ssize_t
length
,
Py_ssize_t
start
,
Py_ssize_t
end
,
const
char
*
reason
/* UTF-8 encoded string */
);
/* create a UnicodeEncodeError object */
/* create a UnicodeEncodeError object */
#ifndef Py_LIMITED_API
#ifndef Py_LIMITED_API
PyAPI_FUNC
(
PyObject
*
)
PyUnicodeEncodeError_Create
(
PyAPI_FUNC
(
PyObject
*
)
PyUnicodeEncodeError_Create
(
const
char
*
,
const
Py_UNICODE
*
,
Py_ssize_t
,
Py_ssize_t
,
Py_ssize_t
,
const
char
*
);
const
char
*
encoding
,
/* UTF-8 encoded string */
const
Py_UNICODE
*
object
,
Py_ssize_t
length
,
Py_ssize_t
start
,
Py_ssize_t
end
,
const
char
*
reason
/* UTF-8 encoded string */
);
#endif
#endif
/* create a UnicodeTranslateError object */
/* create a UnicodeTranslateError object */
#ifndef Py_LIMITED_API
#ifndef Py_LIMITED_API
PyAPI_FUNC
(
PyObject
*
)
PyUnicodeTranslateError_Create
(
PyAPI_FUNC
(
PyObject
*
)
PyUnicodeTranslateError_Create
(
const
Py_UNICODE
*
,
Py_ssize_t
,
Py_ssize_t
,
Py_ssize_t
,
const
char
*
);
const
Py_UNICODE
*
object
,
Py_ssize_t
length
,
Py_ssize_t
start
,
Py_ssize_t
end
,
const
char
*
reason
/* UTF-8 encoded string */
);
#endif
#endif
/* get the encoding attribute */
/* get the encoding attribute */
...
@@ -307,11 +336,17 @@ PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetReason(PyObject *);
...
@@ -307,11 +336,17 @@ PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetReason(PyObject *);
/* assign a new value to the reason attribute
/* assign a new value to the reason attribute
return 0 on success, -1 on failure */
return 0 on success, -1 on failure */
PyAPI_FUNC
(
int
)
PyUnicodeEncodeError_SetReason
(
PyAPI_FUNC
(
int
)
PyUnicodeEncodeError_SetReason
(
PyObject
*
,
const
char
*
);
PyObject
*
exc
,
const
char
*
reason
/* UTF-8 encoded string */
);
PyAPI_FUNC
(
int
)
PyUnicodeDecodeError_SetReason
(
PyAPI_FUNC
(
int
)
PyUnicodeDecodeError_SetReason
(
PyObject
*
,
const
char
*
);
PyObject
*
exc
,
const
char
*
reason
/* UTF-8 encoded string */
);
PyAPI_FUNC
(
int
)
PyUnicodeTranslateError_SetReason
(
PyAPI_FUNC
(
int
)
PyUnicodeTranslateError_SetReason
(
PyObject
*
,
const
char
*
);
PyObject
*
exc
,
const
char
*
reason
/* UTF-8 encoded string */
);
/* These APIs aren't really part of the error implementation, but
/* These APIs aren't really part of the error implementation, but
...
...
Include/warnings.h
Dosyayı görüntüle @
555a24f2
...
@@ -8,10 +8,22 @@ extern "C" {
...
@@ -8,10 +8,22 @@ extern "C" {
PyAPI_FUNC
(
PyObject
*
)
_PyWarnings_Init
(
void
);
PyAPI_FUNC
(
PyObject
*
)
_PyWarnings_Init
(
void
);
#endif
#endif
PyAPI_FUNC
(
int
)
PyErr_WarnEx
(
PyObject
*
,
const
char
*
,
Py_ssize_t
);
PyAPI_FUNC
(
int
)
PyErr_WarnEx
(
PyAPI_FUNC
(
int
)
PyErr_WarnFormat
(
PyObject
*
,
Py_ssize_t
,
const
char
*
,
...);
PyObject
*
category
,
PyAPI_FUNC
(
int
)
PyErr_WarnExplicit
(
PyObject
*
,
const
char
*
,
const
char
*
,
int
,
const
char
*
message
,
/* UTF-8 encoded string */
const
char
*
,
PyObject
*
);
Py_ssize_t
stack_level
);
PyAPI_FUNC
(
int
)
PyErr_WarnFormat
(
PyObject
*
category
,
Py_ssize_t
stack_level
,
const
char
*
format
,
/* ASCII-encoded string */
...);
PyAPI_FUNC
(
int
)
PyErr_WarnExplicit
(
PyObject
*
category
,
const
char
*
message
,
/* UTF-8 encoded string */
const
char
*
filename
,
/* UTF-8 encoded string */
int
lineno
,
const
char
*
module
,
/* UTF-8 encoded string */
PyObject
*
registry
);
/* DEPRECATED: Use PyErr_WarnEx() instead. */
/* DEPRECATED: Use PyErr_WarnEx() instead. */
#ifndef Py_LIMITED_API
#ifndef Py_LIMITED_API
...
...
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