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
720ddb62
Kaydet (Commit)
720ddb62
authored
Şub 16, 2006
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Use PyString_FromFormat for formatting error messages.
üst
e0e89f79
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
42 deletions
+36
-42
exceptions.c
Python/exceptions.c
+36
-42
No files found.
Python/exceptions.c
Dosyayı görüntüle @
720ddb62
...
@@ -1238,7 +1238,6 @@ UnicodeEncodeError__str__(PyObject *self, PyObject *arg)
...
@@ -1238,7 +1238,6 @@ UnicodeEncodeError__str__(PyObject *self, PyObject *arg)
Py_ssize_t
start
;
Py_ssize_t
start
;
Py_ssize_t
end
;
Py_ssize_t
end
;
PyObject
*
reasonObj
=
NULL
;
PyObject
*
reasonObj
=
NULL
;
char
buffer
[
1000
];
PyObject
*
result
=
NULL
;
PyObject
*
result
=
NULL
;
self
=
arg
;
self
=
arg
;
...
@@ -1260,32 +1259,30 @@ UnicodeEncodeError__str__(PyObject *self, PyObject *arg)
...
@@ -1260,32 +1259,30 @@ UnicodeEncodeError__str__(PyObject *self, PyObject *arg)
if
(
end
==
start
+
1
)
{
if
(
end
==
start
+
1
)
{
int
badchar
=
(
int
)
PyUnicode_AS_UNICODE
(
objectObj
)[
start
];
int
badchar
=
(
int
)
PyUnicode_AS_UNICODE
(
objectObj
)[
start
];
char
*
format
;
char
badchar_str
[
20
]
;
if
(
badchar
<=
0xff
)
if
(
badchar
<=
0xff
)
format
=
"'%.400s' codec can't encode character u'
\\
x%02x' in position %d: %.400s"
;
PyOS_snprintf
(
badchar_str
,
sizeof
(
badchar_str
),
"x%02x"
,
badchar
)
;
else
if
(
badchar
<=
0xffff
)
else
if
(
badchar
<=
0xffff
)
format
=
"'%.400s' codec can't encode character u'
\\
u%04x' in position %d: %.400s"
;
PyOS_snprintf
(
badchar_str
,
sizeof
(
badchar_str
),
"u%04x"
,
badchar
)
;
else
else
format
=
"'%.400s' codec can't encode character u'
\\
U%08x' in position %d: %.400s"
;
PyOS_snprintf
(
badchar_str
,
sizeof
(
badchar_str
),
"U%08x"
,
badchar
)
;
PyOS_snprintf
(
buffer
,
sizeof
(
buffer
),
result
=
PyString_FromFormat
(
format
,
"'%.400s' codec can't encode character u'
\\
%s' in position %zd: %.400s"
,
PyString_AS_STRING
(
encodingObj
),
PyString_AS_STRING
(
encodingObj
),
badchar
,
badchar
_str
,
start
,
start
,
PyString_AS_STRING
(
reasonObj
)
PyString_AS_STRING
(
reasonObj
)
);
);
}
}
else
{
else
{
/* XXX %zd? */
result
=
PyString_FromFormat
(
PyOS_snprintf
(
buffer
,
sizeof
(
buffer
),
"'%.400s' codec can't encode characters in position %zd-%zd: %.400s"
,
"'%.400s' codec can't encode characters in position %d-%d: %.400s"
,
PyString_AS_STRING
(
encodingObj
),
PyString_AS_STRING
(
encodingObj
),
(
int
)
start
,
start
,
(
int
)(
end
-
1
),
(
end
-
1
),
PyString_AS_STRING
(
reasonObj
)
PyString_AS_STRING
(
reasonObj
)
);
);
}
}
result
=
PyString_FromString
(
buffer
);
error:
error:
Py_XDECREF
(
reasonObj
);
Py_XDECREF
(
reasonObj
);
...
@@ -1324,7 +1321,6 @@ UnicodeDecodeError__str__(PyObject *self, PyObject *arg)
...
@@ -1324,7 +1321,6 @@ UnicodeDecodeError__str__(PyObject *self, PyObject *arg)
Py_ssize_t
start
;
Py_ssize_t
start
;
Py_ssize_t
end
;
Py_ssize_t
end
;
PyObject
*
reasonObj
=
NULL
;
PyObject
*
reasonObj
=
NULL
;
char
buffer
[
1000
];
PyObject
*
result
=
NULL
;
PyObject
*
result
=
NULL
;
self
=
arg
;
self
=
arg
;
...
@@ -1345,26 +1341,28 @@ UnicodeDecodeError__str__(PyObject *self, PyObject *arg)
...
@@ -1345,26 +1341,28 @@ UnicodeDecodeError__str__(PyObject *self, PyObject *arg)
goto
error
;
goto
error
;
if
(
end
==
start
+
1
)
{
if
(
end
==
start
+
1
)
{
/* XXX %zd? */
/* FromFormat does not support %02x, so format that separately */
PyOS_snprintf
(
buffer
,
sizeof
(
buffer
),
char
byte
[
4
];
"'%.400s' codec can't decode byte 0x%02x in position %d: %.400s"
,
PyOS_snprintf
(
byte
,
sizeof
(
byte
),
"%02x"
,
((
int
)
PyString_AS_STRING
(
objectObj
)[
start
])
&
0xff
);
result
=
PyString_FromFormat
(
"'%.400s' codec can't decode byte 0x%s in position %zd: %.400s"
,
PyString_AS_STRING
(
encodingObj
),
PyString_AS_STRING
(
encodingObj
),
((
int
)
PyString_AS_STRING
(
objectObj
)[
start
])
&
0xff
,
byte
,
(
int
)
start
,
start
,
PyString_AS_STRING
(
reasonObj
)
PyString_AS_STRING
(
reasonObj
)
);
);
}
}
else
{
else
{
/* XXX %zd? */
result
=
PyString_FromFormat
(
PyOS_snprintf
(
buffer
,
sizeof
(
buffer
),
"'%.400s' codec can't decode bytes in position %zd-%zd: %.400s"
,
"'%.400s' codec can't decode bytes in position %d-%d: %.400s"
,
PyString_AS_STRING
(
encodingObj
),
PyString_AS_STRING
(
encodingObj
),
(
int
)
start
,
start
,
(
int
)(
end
-
1
),
(
end
-
1
),
PyString_AS_STRING
(
reasonObj
)
PyString_AS_STRING
(
reasonObj
)
);
);
}
}
result
=
PyString_FromString
(
buffer
);
error:
error:
Py_XDECREF
(
reasonObj
);
Py_XDECREF
(
reasonObj
);
...
@@ -1442,7 +1440,6 @@ UnicodeTranslateError__str__(PyObject *self, PyObject *arg)
...
@@ -1442,7 +1440,6 @@ UnicodeTranslateError__str__(PyObject *self, PyObject *arg)
Py_ssize_t
start
;
Py_ssize_t
start
;
Py_ssize_t
end
;
Py_ssize_t
end
;
PyObject
*
reasonObj
=
NULL
;
PyObject
*
reasonObj
=
NULL
;
char
buffer
[
1000
];
PyObject
*
result
=
NULL
;
PyObject
*
result
=
NULL
;
self
=
arg
;
self
=
arg
;
...
@@ -1461,31 +1458,28 @@ UnicodeTranslateError__str__(PyObject *self, PyObject *arg)
...
@@ -1461,31 +1458,28 @@ UnicodeTranslateError__str__(PyObject *self, PyObject *arg)
if
(
end
==
start
+
1
)
{
if
(
end
==
start
+
1
)
{
int
badchar
=
(
int
)
PyUnicode_AS_UNICODE
(
objectObj
)[
start
];
int
badchar
=
(
int
)
PyUnicode_AS_UNICODE
(
objectObj
)[
start
];
char
*
format
;
char
badchar_str
[
20
];
/* XXX %zd? */
if
(
badchar
<=
0xff
)
if
(
badchar
<=
0xff
)
format
=
"can't translate character u'
\\
x%02x' in position %d: %.400s"
;
PyOS_snprintf
(
badchar_str
,
sizeof
(
badchar_str
),
"x%02x"
,
badchar
)
;
else
if
(
badchar
<=
0xffff
)
else
if
(
badchar
<=
0xffff
)
format
=
"can't translate character u'
\\
u%04x' in position %d: %.400s"
;
PyOS_snprintf
(
badchar_str
,
sizeof
(
badchar_str
),
"u%04x"
,
badchar
)
;
else
else
format
=
"can't translate character u'
\\
U%08x' in position %d: %.400s"
;
PyOS_snprintf
(
badchar_str
,
sizeof
(
badchar_str
),
"U%08x"
,
badchar
)
;
PyOS_snprintf
(
buffer
,
sizeof
(
buffer
),
result
=
PyString_FromFormat
(
format
,
"can't translate character u'
\\
%s' in position %zd: %.400s"
,
badchar
,
badchar
_str
,
(
int
)
start
,
start
,
PyString_AS_STRING
(
reasonObj
)
PyString_AS_STRING
(
reasonObj
)
);
);
}
}
else
{
else
{
/* XXX %zd? */
result
=
PyString_FromFormat
(
PyOS_snprintf
(
buffer
,
sizeof
(
buffer
),
"can't translate characters in position %zd-%zd: %.400s"
,
"can't translate characters in position %d-%d: %.400s"
,
start
,
(
int
)
start
,
(
end
-
1
),
(
int
)(
end
-
1
),
PyString_AS_STRING
(
reasonObj
)
PyString_AS_STRING
(
reasonObj
)
);
);
}
}
result
=
PyString_FromString
(
buffer
);
error:
error:
Py_XDECREF
(
reasonObj
);
Py_XDECREF
(
reasonObj
);
...
...
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