Commit be801acb authored by Guido van Rossum's avatar Guido van Rossum

Delete bufferobject.[ch].

This will undoubtedly require Windows build file changes too.
parent bae07c9b
...@@ -76,7 +76,6 @@ ...@@ -76,7 +76,6 @@
#endif #endif
#include "rangeobject.h" #include "rangeobject.h"
#include "stringobject.h" #include "stringobject.h"
#include "bufferobject.h"
#include "memoryobject.h" #include "memoryobject.h"
#include "tupleobject.h" #include "tupleobject.h"
#include "listobject.h" #include "listobject.h"
......
/* Buffer object interface */
/* Note: the object's structure is private */
#ifndef Py_BUFFEROBJECT_H
#define Py_BUFFEROBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
PyAPI_DATA(PyTypeObject) PyBuffer_Type;
#define PyBuffer_Check(op) (Py_Type(op) == &PyBuffer_Type)
#define Py_END_OF_BUFFER (-1)
PyAPI_FUNC(PyObject *) PyBuffer_FromObject(PyObject *base,
Py_ssize_t offset, Py_ssize_t size);
PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteObject(PyObject *base,
Py_ssize_t offset,
Py_ssize_t size);
PyAPI_FUNC(PyObject *) PyBuffer_FromMemory(void *ptr, Py_ssize_t size);
PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size);
PyAPI_FUNC(PyObject *) PyBuffer_New(Py_ssize_t size);
#ifdef __cplusplus
}
#endif
#endif /* !Py_BUFFEROBJECT_H */
...@@ -285,7 +285,6 @@ PYTHON_OBJS= \ ...@@ -285,7 +285,6 @@ PYTHON_OBJS= \
OBJECT_OBJS= \ OBJECT_OBJS= \
Objects/abstract.o \ Objects/abstract.o \
Objects/boolobject.o \ Objects/boolobject.o \
Objects/bufferobject.o \
Objects/bytesobject.o \ Objects/bytesobject.o \
Objects/cellobject.o \ Objects/cellobject.o \
Objects/classobject.o \ Objects/classobject.o \
...@@ -530,7 +529,6 @@ PYTHON_HEADERS= \ ...@@ -530,7 +529,6 @@ PYTHON_HEADERS= \
Include/asdl.h \ Include/asdl.h \
Include/abstract.h \ Include/abstract.h \
Include/boolobject.h \ Include/boolobject.h \
Include/bufferobject.h \
Include/bytesobject.h \ Include/bytesobject.h \
Include/ceval.h \ Include/ceval.h \
Include/classobject.h \ Include/classobject.h \
......
This diff is collapsed.
...@@ -8,6 +8,8 @@ memory_getbuf(PyMemoryViewObject *self, Py_buffer *view, int flags) ...@@ -8,6 +8,8 @@ memory_getbuf(PyMemoryViewObject *self, Py_buffer *view, int flags)
{ {
if (view != NULL) if (view != NULL)
*view = self->view; *view = self->view;
if (self->base == NULL)
return 0;
return self->base->ob_type->tp_as_buffer->bf_getbuffer(self->base, NULL, return self->base->ob_type->tp_as_buffer->bf_getbuffer(self->base, NULL,
PyBUF_FULL); PyBUF_FULL);
} }
...@@ -15,7 +17,8 @@ memory_getbuf(PyMemoryViewObject *self, Py_buffer *view, int flags) ...@@ -15,7 +17,8 @@ memory_getbuf(PyMemoryViewObject *self, Py_buffer *view, int flags)
static void static void
memory_releasebuf(PyMemoryViewObject *self, Py_buffer *view) memory_releasebuf(PyMemoryViewObject *self, Py_buffer *view)
{ {
PyObject_ReleaseBuffer(self->base, NULL); if (self->base != NULL)
PyObject_ReleaseBuffer(self->base, NULL);
} }
PyDoc_STRVAR(memory_doc, PyDoc_STRVAR(memory_doc,
......
...@@ -1051,6 +1051,7 @@ PyObject *PyUnicode_Decode(const char *s, ...@@ -1051,6 +1051,7 @@ PyObject *PyUnicode_Decode(const char *s,
const char *errors) const char *errors)
{ {
PyObject *buffer = NULL, *unicode; PyObject *buffer = NULL, *unicode;
Py_buffer info;
if (encoding == NULL) if (encoding == NULL)
encoding = PyUnicode_GetDefaultEncoding(); encoding = PyUnicode_GetDefaultEncoding();
...@@ -1068,7 +1069,10 @@ PyObject *PyUnicode_Decode(const char *s, ...@@ -1068,7 +1069,10 @@ PyObject *PyUnicode_Decode(const char *s,
return PyUnicode_DecodeASCII(s, size, errors); return PyUnicode_DecodeASCII(s, size, errors);
/* Decode via the codec registry */ /* Decode via the codec registry */
buffer = PyBuffer_FromMemory((void *)s, size); buffer = NULL;
if (PyBuffer_FillInfo(&info, (void *)s, size, 1, PyBUF_SIMPLE) < 0)
goto onError;
buffer = PyMemoryView_FromMemory(&info);
if (buffer == NULL) if (buffer == NULL)
goto onError; goto onError;
unicode = PyCodec_Decode(buffer, encoding, errors); unicode = PyCodec_Decode(buffer, encoding, errors);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment