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
7bf36dac
Kaydet (Commit)
7bf36dac
authored
May 16, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #27039: Fixed bytearray.remove() for values greater than 127.
Patch by Joe Jevnik.
üst
dc953a50
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
7 deletions
+14
-7
test_bytes.py
Lib/test/test_bytes.py
+7
-0
NEWS
Misc/NEWS
+3
-0
bytearrayobject.c
Objects/bytearrayobject.c
+4
-7
No files found.
Lib/test/test_bytes.py
Dosyayı görüntüle @
7bf36dac
...
...
@@ -1082,6 +1082,13 @@ class ByteArrayTest(BaseBytesTest, unittest.TestCase):
b
.
remove
(
Indexable
(
ord
(
'e'
)))
self
.
assertEqual
(
b
,
b
''
)
# test values outside of the ascii range: (0, 127)
c
=
bytearray
([
126
,
127
,
128
,
129
])
c
.
remove
(
127
)
self
.
assertEqual
(
c
,
bytes
([
126
,
128
,
129
]))
c
.
remove
(
129
)
self
.
assertEqual
(
c
,
bytes
([
126
,
128
]))
def
test_pop
(
self
):
b
=
bytearray
(
b
'world'
)
self
.
assertEqual
(
b
.
pop
(),
ord
(
'd'
))
...
...
Misc/NEWS
Dosyayı görüntüle @
7bf36dac
...
...
@@ -10,6 +10,9 @@ Release date: tba
Core and Builtins
-----------------
- Issue #27039: Fixed bytearray.remove() for values greater than 127. Patch by
Joe Jevnik.
- Issue #23640: int.from_bytes() no longer bypasses constructors for subclasses.
- Issue #26811: gc.get_objects() no longer contains a broken tuple with NULL
...
...
Objects/bytearrayobject.c
Dosyayı görüntüle @
7bf36dac
...
...
@@ -2565,21 +2565,18 @@ static PyObject *
bytearray_remove_impl
(
PyByteArrayObject
*
self
,
int
value
)
/*[clinic end generated code: output=d659e37866709c13 input=47560b11fd856c24]*/
{
Py_ssize_t
where
,
n
=
Py_SIZE
(
self
);
Py_ssize_t
n
=
Py_SIZE
(
self
);
char
*
buf
=
PyByteArray_AS_STRING
(
self
);
char
*
where
=
memchr
(
buf
,
value
,
n
);
for
(
where
=
0
;
where
<
n
;
where
++
)
{
if
(
buf
[
where
]
==
value
)
break
;
}
if
(
where
==
n
)
{
if
(
!
where
)
{
PyErr_SetString
(
PyExc_ValueError
,
"value not found in bytearray"
);
return
NULL
;
}
if
(
!
_canresize
(
self
))
return
NULL
;
memmove
(
buf
+
where
,
buf
+
where
+
1
,
n
-
where
);
memmove
(
where
,
where
+
1
,
buf
+
n
-
where
);
if
(
PyByteArray_Resize
((
PyObject
*
)
self
,
n
-
1
)
<
0
)
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