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
43ab100c
Kaydet (Commit)
43ab100c
authored
May 28, 2006
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix refleaks in UnicodeError get and set methods.
üst
2b330376
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
45 deletions
+56
-45
exceptions.c
Objects/exceptions.c
+56
-45
No files found.
Objects/exceptions.c
Dosyayı görüntüle @
43ab100c
/*
* New exceptions.c written in Iceland by Richard Jones and Georg Brandl.
*
* Thanks go to Tim Peters and Michael Hudson for debugging.
*/
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "structmember.h"
...
...
@@ -1037,56 +1043,57 @@ SyntaxError_str(PySyntaxErrorObject *self)
{
PyObject
*
str
;
PyObject
*
result
;
int
have_filename
=
0
;
int
have_lineno
=
0
;
char
*
buffer
=
NULL
;
if
(
self
->
msg
)
str
=
PyObject_Str
(
self
->
msg
);
else
str
=
PyObject_Str
(
Py_None
);
result
=
str
;
if
(
!
str
)
return
NULL
;
/* Don't fiddle with non-string return (shouldn't happen anyway) */
if
(
!
PyString_Check
(
str
))
return
str
;
/* XXX -- do all the additional formatting with filename and
lineno here */
if
(
str
!=
NULL
&&
PyString_Check
(
str
))
{
int
have_filename
=
0
;
int
have_lineno
=
0
;
char
*
buffer
=
NULL
;
have_filename
=
(
self
->
filename
!=
NULL
)
&&
PyString_Check
(
self
->
filename
);
have_lineno
=
(
self
->
lineno
!=
NULL
)
&&
PyInt_Check
(
self
->
lineno
);
if
(
have_filename
||
have_lineno
)
{
Py_ssize_t
bufsize
=
PyString_GET_SIZE
(
str
)
+
64
;
if
(
have_filename
)
bufsize
+=
PyString_GET_SIZE
(
self
->
filename
);
buffer
=
(
char
*
)
PyMem_MALLOC
(
bufsize
);
if
(
buffer
!=
NULL
)
{
if
(
have_filename
&&
have_lineno
)
PyOS_snprintf
(
buffer
,
bufsize
,
"%s (%s, line %ld)"
,
PyString_AS_STRING
(
str
),
my_basename
(
PyString_AS_STRING
(
self
->
filename
)),
PyInt_AsLong
(
self
->
lineno
));
else
if
(
have_filename
)
PyOS_snprintf
(
buffer
,
bufsize
,
"%s (%s)"
,
PyString_AS_STRING
(
str
),
my_basename
(
PyString_AS_STRING
(
self
->
filename
)));
else
if
(
have_lineno
)
PyOS_snprintf
(
buffer
,
bufsize
,
"%s (line %ld)"
,
PyString_AS_STRING
(
str
),
PyInt_AsLong
(
self
->
lineno
));
result
=
PyString_FromString
(
buffer
);
PyMem_FREE
(
buffer
);
if
(
result
==
NULL
)
result
=
str
;
else
Py_DECREF
(
str
);
}
}
}
have_filename
=
(
self
->
filename
!=
NULL
)
&&
PyString_Check
(
self
->
filename
);
have_lineno
=
(
self
->
lineno
!=
NULL
)
&&
PyInt_Check
(
self
->
lineno
);
if
(
!
have_filename
&&
!
have_lineno
)
return
str
;
Py_ssize_t
bufsize
=
PyString_GET_SIZE
(
str
)
+
64
;
if
(
have_filename
)
bufsize
+=
PyString_GET_SIZE
(
self
->
filename
);
buffer
=
PyMem_MALLOC
(
bufsize
);
if
(
buffer
==
NULL
)
return
str
;
if
(
have_filename
&&
have_lineno
)
PyOS_snprintf
(
buffer
,
bufsize
,
"%s (%s, line %ld)"
,
PyString_AS_STRING
(
str
),
my_basename
(
PyString_AS_STRING
(
self
->
filename
)),
PyInt_AsLong
(
self
->
lineno
));
else
if
(
have_filename
)
PyOS_snprintf
(
buffer
,
bufsize
,
"%s (%s)"
,
PyString_AS_STRING
(
str
),
my_basename
(
PyString_AS_STRING
(
self
->
filename
)));
else
/* only have_lineno */
PyOS_snprintf
(
buffer
,
bufsize
,
"%s (line %ld)"
,
PyString_AS_STRING
(
str
),
PyInt_AsLong
(
self
->
lineno
));
result
=
PyString_FromString
(
buffer
);
PyMem_FREE
(
buffer
);
if
(
result
==
NULL
)
result
=
str
;
else
Py_DECREF
(
str
);
return
result
;
}
...
...
@@ -1208,7 +1215,7 @@ set_ssize_t(PyObject **attr, Py_ssize_t value)
PyObject
*
obj
=
PyInt_FromSsize_t
(
value
);
if
(
!
obj
)
return
-
1
;
Py_
XDECREF
(
*
attr
);
Py_
CLEAR
(
*
attr
);
*
attr
=
obj
;
return
0
;
}
...
...
@@ -1236,7 +1243,7 @@ set_string(PyObject **attr, const char *value)
PyObject
*
obj
=
PyString_FromString
(
value
);
if
(
!
obj
)
return
-
1
;
Py_
XDECREF
(
*
attr
);
Py_
CLEAR
(
*
attr
);
*
attr
=
obj
;
return
0
;
}
...
...
@@ -1302,6 +1309,7 @@ PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start)
*
start
=
0
;
/*XXX check for values <0*/
if
(
*
start
>=
size
)
*
start
=
size
-
1
;
Py_DECREF
(
obj
);
return
0
;
}
return
-
1
;
...
...
@@ -1321,6 +1329,7 @@ PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start)
*
start
=
0
;
if
(
*
start
>=
size
)
*
start
=
size
-
1
;
Py_DECREF
(
obj
);
return
0
;
}
return
-
1
;
...
...
@@ -1368,6 +1377,7 @@ PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
*
end
=
1
;
if
(
*
end
>
size
)
*
end
=
size
;
Py_DECREF
(
obj
);
return
0
;
}
return
-
1
;
...
...
@@ -1387,6 +1397,7 @@ PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
*
end
=
1
;
if
(
*
end
>
size
)
*
end
=
size
;
Py_DECREF
(
obj
);
return
0
;
}
return
-
1
;
...
...
@@ -1630,8 +1641,8 @@ UnicodeDecodeError_init(PyObject *self, PyObject *args, PyObject *kwds)
static
PyObject
*
UnicodeDecodeError_str
(
PyObject
*
self
)
{
Py_ssize_t
start
;
Py_ssize_t
end
;
Py_ssize_t
start
=
0
;
Py_ssize_t
end
=
0
;
if
(
PyUnicodeDecodeError_GetStart
(
self
,
&
start
))
return
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