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
2c53971b
Kaydet (Commit)
2c53971b
authored
Eyl 20, 2010
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
add PyErr_SyntaxLocationEx, to support adding a column offset
üst
26d64aee
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
1 deletion
+32
-1
exceptions.rst
Doc/c-api/exceptions.rst
+14
-0
pyerrors.h
Include/pyerrors.h
+1
-0
errors.c
Python/errors.c
+17
-1
No files found.
Doc/c-api/exceptions.rst
Dosyayı görüntüle @
2c53971b
...
@@ -294,6 +294,20 @@ in various ways. There is a separate error indicator for each thread.
...
@@ -294,6 +294,20 @@ in various ways. There is a separate error indicator for each thread.
parameter specifying the exception type to be raised. Availability: Windows.
parameter specifying the exception type to be raised. Availability: Windows.
.. cfunction:: void PyErr_SyntaxLocationEx(char *filename, int lineno, int col_offset)
Set file, line, and offset information for the current exception. If the
current exception is not a :exc:`SyntaxError`, then it sets additional
attributes, which make the exception printing subsystem think the exception
is a :exc:`SyntaxError`.
.. cfunction:: void PyErr_SyntaxLocation(char *filename, int lineno)
Like :cfunc:`PyErr_SyntaxLocationExc`, but the col_offset parameter is
omitted.
.. cfunction:: void PyErr_BadInternalCall()
.. cfunction:: void PyErr_BadInternalCall()
This is a shorthand for ``PyErr_SetString(PyExc_SystemError, message)``,
This is a shorthand for ``PyErr_SetString(PyExc_SystemError, message)``,
...
...
Include/pyerrors.h
Dosyayı görüntüle @
2c53971b
...
@@ -229,6 +229,7 @@ int PySignal_SetWakeupFd(int fd);
...
@@ -229,6 +229,7 @@ int PySignal_SetWakeupFd(int fd);
/* 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
(
const
char
*
,
int
);
PyAPI_FUNC
(
void
)
PyErr_SyntaxLocationEx
(
const
char
*
,
int
,
int
);
PyAPI_FUNC
(
PyObject
*
)
PyErr_ProgramText
(
const
char
*
,
int
);
PyAPI_FUNC
(
PyObject
*
)
PyErr_ProgramText
(
const
char
*
,
int
);
/* The following functions are used to create and modify unicode
/* The following functions are used to create and modify unicode
...
...
Python/errors.c
Dosyayı görüntüle @
2c53971b
...
@@ -780,12 +780,18 @@ PyErr_WriteUnraisable(PyObject *obj)
...
@@ -780,12 +780,18 @@ PyErr_WriteUnraisable(PyObject *obj)
extern
PyObject
*
PyModule_GetWarningsModule
(
void
);
extern
PyObject
*
PyModule_GetWarningsModule
(
void
);
void
PyErr_SyntaxLocation
(
const
char
*
filename
,
int
lineno
)
{
PyErr_SyntaxLocationEx
(
filename
,
lineno
,
-
1
);
}
/* Set file and line information for the current exception.
/* Set file and line information for the current exception.
If the exception is not a SyntaxError, also sets additional attributes
If the exception is not a SyntaxError, also sets additional attributes
to make printing of exceptions believe it is a syntax error. */
to make printing of exceptions believe it is a syntax error. */
void
void
PyErr_SyntaxLocation
(
const
char
*
filename
,
int
lineno
)
PyErr_SyntaxLocation
Ex
(
const
char
*
filename
,
int
lineno
,
int
col_offset
)
{
{
PyObject
*
exc
,
*
v
,
*
tb
,
*
tmp
;
PyObject
*
exc
,
*
v
,
*
tb
,
*
tmp
;
...
@@ -802,6 +808,16 @@ PyErr_SyntaxLocation(const char *filename, int lineno)
...
@@ -802,6 +808,16 @@ PyErr_SyntaxLocation(const char *filename, int lineno)
PyErr_Clear
();
PyErr_Clear
();
Py_DECREF
(
tmp
);
Py_DECREF
(
tmp
);
}
}
if
(
col_offset
>=
0
)
{
tmp
=
PyLong_FromLong
(
col_offset
);
if
(
tmp
==
NULL
)
PyErr_Clear
();
else
{
if
(
PyObject_SetAttrString
(
v
,
"offset"
,
tmp
))
PyErr_Clear
();
Py_DECREF
(
tmp
);
}
}
if
(
filename
!=
NULL
)
{
if
(
filename
!=
NULL
)
{
tmp
=
PyUnicode_FromString
(
filename
);
tmp
=
PyUnicode_FromString
(
filename
);
if
(
tmp
==
NULL
)
if
(
tmp
==
NULL
)
...
...
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