125 PyObject* result = NULL; |
112 PyObject* result = NULL; |
126 char* resultBuffer; |
113 char* resultBuffer; |
127 Py_ssize_t resultSize; |
114 Py_ssize_t resultSize; |
128 ZSTD_outBuffer output; |
115 ZSTD_outBuffer output; |
129 size_t zresult; |
116 size_t zresult; |
130 |
|
131 if (!self->entered) { |
|
132 PyErr_SetString(ZstdError, "read() must be called from an active context manager"); |
|
133 return NULL; |
|
134 } |
|
135 |
117 |
136 if (self->closed) { |
118 if (self->closed) { |
137 PyErr_SetString(PyExc_ValueError, "stream is closed"); |
119 PyErr_SetString(PyExc_ValueError, "stream is closed"); |
138 return NULL; |
120 return NULL; |
139 } |
121 } |
382 PyDoc_STR("Enter a compression context") }, |
359 PyDoc_STR("Enter a compression context") }, |
383 { "__exit__", (PyCFunction)reader_exit, METH_VARARGS, |
360 { "__exit__", (PyCFunction)reader_exit, METH_VARARGS, |
384 PyDoc_STR("Exit a compression context") }, |
361 PyDoc_STR("Exit a compression context") }, |
385 { "close", (PyCFunction)reader_close, METH_NOARGS, |
362 { "close", (PyCFunction)reader_close, METH_NOARGS, |
386 PyDoc_STR("Close the stream so it cannot perform any more operations") }, |
363 PyDoc_STR("Close the stream so it cannot perform any more operations") }, |
387 { "closed", (PyCFunction)reader_closed, METH_NOARGS, |
|
388 PyDoc_STR("Whether stream is closed") }, |
|
389 { "flush", (PyCFunction)reader_flush, METH_NOARGS, PyDoc_STR("no-ops") }, |
364 { "flush", (PyCFunction)reader_flush, METH_NOARGS, PyDoc_STR("no-ops") }, |
390 { "isatty", (PyCFunction)reader_isatty, METH_NOARGS, PyDoc_STR("Returns False") }, |
365 { "isatty", (PyCFunction)reader_isatty, METH_NOARGS, PyDoc_STR("Returns False") }, |
391 { "readable", (PyCFunction)reader_readable, METH_NOARGS, |
366 { "readable", (PyCFunction)reader_readable, METH_NOARGS, |
392 PyDoc_STR("Returns True") }, |
367 PyDoc_STR("Returns True") }, |
393 { "read", (PyCFunction)reader_read, METH_VARARGS | METH_KEYWORDS, |
368 { "read", (PyCFunction)reader_read, METH_VARARGS | METH_KEYWORDS, |
403 { "writable", (PyCFunction)reader_writable, METH_NOARGS, |
378 { "writable", (PyCFunction)reader_writable, METH_NOARGS, |
404 PyDoc_STR("Returns False") }, |
379 PyDoc_STR("Returns False") }, |
405 { "write", (PyCFunction)reader_write, METH_VARARGS, PyDoc_STR("unsupported operation") }, |
380 { "write", (PyCFunction)reader_write, METH_VARARGS, PyDoc_STR("unsupported operation") }, |
406 { "writelines", (PyCFunction)reader_writelines, METH_VARARGS, PyDoc_STR("unsupported operation") }, |
381 { "writelines", (PyCFunction)reader_writelines, METH_VARARGS, PyDoc_STR("unsupported operation") }, |
407 { NULL, NULL } |
382 { NULL, NULL } |
|
383 }; |
|
384 |
|
385 static PyMemberDef reader_members[] = { |
|
386 { "closed", T_BOOL, offsetof(ZstdDecompressionReader, closed), |
|
387 READONLY, "whether stream is closed" }, |
|
388 { NULL } |
408 }; |
389 }; |
409 |
390 |
410 PyTypeObject ZstdDecompressionReaderType = { |
391 PyTypeObject ZstdDecompressionReaderType = { |
411 PyVarObject_HEAD_INIT(NULL, 0) |
392 PyVarObject_HEAD_INIT(NULL, 0) |
412 "zstd.ZstdDecompressionReader", /* tp_name */ |
393 "zstd.ZstdDecompressionReader", /* tp_name */ |
434 0, /* tp_richcompare */ |
415 0, /* tp_richcompare */ |
435 0, /* tp_weaklistoffset */ |
416 0, /* tp_weaklistoffset */ |
436 reader_iter, /* tp_iter */ |
417 reader_iter, /* tp_iter */ |
437 reader_iternext, /* tp_iternext */ |
418 reader_iternext, /* tp_iternext */ |
438 reader_methods, /* tp_methods */ |
419 reader_methods, /* tp_methods */ |
439 0, /* tp_members */ |
420 reader_members, /* tp_members */ |
440 0, /* tp_getset */ |
421 0, /* tp_getset */ |
441 0, /* tp_base */ |
422 0, /* tp_base */ |
442 0, /* tp_dict */ |
423 0, /* tp_dict */ |
443 0, /* tp_descr_get */ |
424 0, /* tp_descr_get */ |
444 0, /* tp_descr_set */ |
425 0, /* tp_descr_set */ |