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
2c2044e7
Unverified
Kaydet (Commit)
2c2044e7
authored
Eki 21, 2018
tarafından
Serhiy Storchaka
Kaydeden (comit)
GitHub
Eki 21, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-34984: Improve error messages for bytes and bytearray constructors. (GH-9874)
üst
914f9a07
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
6 deletions
+25
-6
test_bytes.py
Lib/test/test_bytes.py
+2
-0
bytearrayobject.c
Objects/bytearrayobject.c
+20
-4
bytesobject.c
Objects/bytesobject.c
+3
-2
No files found.
Lib/test/test_bytes.py
Dosyayı görüntüle @
2c2044e7
...
...
@@ -169,6 +169,8 @@ class BaseBytesTest:
self
.
assertRaises
(
TypeError
,
self
.
type2test
,
[
0.0
])
self
.
assertRaises
(
TypeError
,
self
.
type2test
,
[
None
])
self
.
assertRaises
(
TypeError
,
self
.
type2test
,
[
C
()])
self
.
assertRaises
(
TypeError
,
self
.
type2test
,
encoding
=
'ascii'
)
self
.
assertRaises
(
TypeError
,
self
.
type2test
,
errors
=
'ignore'
)
self
.
assertRaises
(
TypeError
,
self
.
type2test
,
0
,
'ascii'
)
self
.
assertRaises
(
TypeError
,
self
.
type2test
,
b
''
,
'ascii'
)
self
.
assertRaises
(
TypeError
,
self
.
type2test
,
0
,
errors
=
'ignore'
)
...
...
Objects/bytearrayobject.c
Dosyayı görüntüle @
2c2044e7
...
...
@@ -783,7 +783,9 @@ bytearray_init(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
if
(
arg
==
NULL
)
{
if
(
encoding
!=
NULL
||
errors
!=
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
"encoding or errors without sequence argument"
);
encoding
!=
NULL
?
"encoding without a string argument"
:
"errors without a string argument"
);
return
-
1
;
}
return
0
;
...
...
@@ -812,7 +814,9 @@ bytearray_init(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
/* If it's not unicode, there can't be encoding or errors */
if
(
encoding
!=
NULL
||
errors
!=
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
"encoding or errors without a string argument"
);
encoding
!=
NULL
?
"encoding without a string argument"
:
"errors without a string argument"
);
return
-
1
;
}
...
...
@@ -860,8 +864,14 @@ bytearray_init(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
/* Get the iterator */
it
=
PyObject_GetIter
(
arg
);
if
(
it
==
NULL
)
if
(
it
==
NULL
)
{
if
(
PyErr_ExceptionMatches
(
PyExc_TypeError
))
{
PyErr_Format
(
PyExc_TypeError
,
"cannot convert '%.200s' object to bytearray"
,
arg
->
ob_type
->
tp_name
);
}
return
-
1
;
}
iternext
=
*
Py_TYPE
(
it
)
->
tp_iternext
;
/* Run the iterator to exhaustion */
...
...
@@ -1626,8 +1636,14 @@ bytearray_extend(PyByteArrayObject *self, PyObject *iterable_of_ints)
}
it
=
PyObject_GetIter
(
iterable_of_ints
);
if
(
it
==
NULL
)
if
(
it
==
NULL
)
{
if
(
PyErr_ExceptionMatches
(
PyExc_TypeError
))
{
PyErr_Format
(
PyExc_TypeError
,
"can't extend bytearray with %.100s"
,
iterable_of_ints
->
ob_type
->
tp_name
);
}
return
NULL
;
}
/* Try to determine the length of the argument. 32 is arbitrary. */
buf_size
=
PyObject_LengthHint
(
iterable_of_ints
,
32
);
...
...
Objects/bytesobject.c
Dosyayı görüntüle @
2c2044e7
...
...
@@ -2537,8 +2537,9 @@ bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if
(
x
==
NULL
)
{
if
(
encoding
!=
NULL
||
errors
!=
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
"encoding or errors without sequence "
"argument"
);
encoding
!=
NULL
?
"encoding without a string argument"
:
"errors without a string argument"
);
return
NULL
;
}
return
PyBytes_FromStringAndSize
(
NULL
,
0
);
...
...
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