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
1d108bc7
Kaydet (Commit)
1d108bc7
authored
Mar 19, 2013
tarafından
Kristján Valur Jónsson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #10211 : Buffer object should support the new buffer interface.
üst
acb6e858
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
test_buffer.py
Lib/test/test_buffer.py
+8
-0
bufferobject.c
Objects/bufferobject.c
+14
-2
No files found.
Lib/test/test_buffer.py
Dosyayı görüntüle @
1d108bc7
...
...
@@ -21,6 +21,14 @@ class BufferTests(unittest.TestCase):
self
.
assertEqual
(
b
[
start
:
stop
:
step
],
s
[
start
:
stop
:
step
])
def
test_newbuffer_interface
(
self
):
# Test that the buffer object has the new buffer interface
# as used by the memoryview object
s
=
""
.
join
(
chr
(
c
)
for
c
in
list
(
range
(
255
,
-
1
,
-
1
)))
b
=
buffer
(
s
)
m
=
memoryview
(
b
)
# Should not raise an exception
self
.
assertEqual
(
m
.
tobytes
(),
s
)
def
test_main
():
with
test_support
.
check_py3k_warnings
((
"buffer.. not supported"
,
...
...
Objects/bufferobject.c
Dosyayı görüntüle @
1d108bc7
...
...
@@ -802,6 +802,16 @@ buffer_getcharbuf(PyBufferObject *self, Py_ssize_t idx, const char **pp)
return
size
;
}
static
int
buffer_getbuffer
(
PyBufferObject
*
self
,
Py_buffer
*
buf
,
int
flags
)
{
void
*
ptr
;
Py_ssize_t
size
;
if
(
!
get_buf
(
self
,
&
ptr
,
&
size
,
ANY_BUFFER
))
return
-
1
;
return
PyBuffer_FillInfo
(
buf
,
(
PyObject
*
)
self
,
ptr
,
size
,
self
->
b_readonly
,
flags
);
}
static
PySequenceMethods
buffer_as_sequence
=
{
(
lenfunc
)
buffer_length
,
/*sq_length*/
(
binaryfunc
)
buffer_concat
,
/*sq_concat*/
...
...
@@ -823,6 +833,7 @@ static PyBufferProcs buffer_as_buffer = {
(
writebufferproc
)
buffer_getwritebuf
,
(
segcountproc
)
buffer_getsegcount
,
(
charbufferproc
)
buffer_getcharbuf
,
(
getbufferproc
)
buffer_getbuffer
,
};
PyTypeObject
PyBuffer_Type
=
{
...
...
@@ -845,7 +856,7 @@ PyTypeObject PyBuffer_Type = {
PyObject_GenericGetAttr
,
/* tp_getattro */
0
,
/* tp_setattro */
&
buffer_as_buffer
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GETCHARBUFFER
,
/* tp_flags */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GETCHARBUFFER
|
Py_TPFLAGS_HAVE_NEWBUFFER
,
/* tp_flags */
buffer_doc
,
/* tp_doc */
0
,
/* tp_traverse */
0
,
/* tp_clear */
...
...
@@ -864,4 +875,4 @@ PyTypeObject PyBuffer_Type = {
0
,
/* tp_init */
0
,
/* tp_alloc */
buffer_new
,
/* tp_new */
};
};
\ No newline at end of file
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