summaryrefslogtreecommitdiffstats
path: root/Python/marshal.c
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-11-09 22:02:48 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-11-09 22:02:48 (GMT)
commit9f64caaf00340fce95c2980435ef819e385cf5ff (patch)
treeb439eb38dfdf5fe534f0e8b31f72072870fe86e3 /Python/marshal.c
parent89c3a22a2788cb85b89990543e33236cd60ba307 (diff)
downloadcpython-9f64caaf00340fce95c2980435ef819e385cf5ff.zip
cpython-9f64caaf00340fce95c2980435ef819e385cf5ff.tar.gz
cpython-9f64caaf00340fce95c2980435ef819e385cf5ff.tar.bz2
Use PyObject_CheckReadBuffer().
Diffstat (limited to 'Python/marshal.c')
-rw-r--r--Python/marshal.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/Python/marshal.c b/Python/marshal.c
index 806b91c..0d21e84 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -108,7 +108,6 @@ static void
w_object(PyObject *v, WFILE *p)
{
int i, n;
- PyBufferProcs *pb;
p->depth++;
@@ -249,13 +248,10 @@ w_object(PyObject *v, WFILE *p)
w_short(co->co_firstlineno, p);
w_object(co->co_lnotab, p);
}
- else if ((pb = v->ob_type->tp_as_buffer) != NULL &&
- pb->bf_getsegcount != NULL &&
- pb->bf_getreadbuffer != NULL &&
- (*pb->bf_getsegcount)(v, NULL) == 1)
- {
+ else if (PyObject_CheckReadBuffer(v)) {
/* Write unknown buffer-style objects as a string */
char *s;
+ PyBufferProcs *pb = v->ob_type->tp_as_buffer;
w_byte(TYPE_STRING, p);
n = (*pb->bf_getreadbuffer)(v, 0, (void **)&s);
w_long((long)n, p);