Skip to content

Commit 48c2acb

Browse files
committed
Convert ZlibDecompressor.__new__ to AC
1 parent 5292fc0 commit 48c2acb

File tree

2 files changed

+117
-44
lines changed

2 files changed

+117
-44
lines changed

Modules/clinic/zlibmodule.c.h

Lines changed: 89 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/zlibmodule.c

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,9 +1369,9 @@ typedef struct {
13691369
} ZlibDecompressor;
13701370

13711371
/*[clinic input]
1372-
class zlib.ZlibDecompressor "ZlibDecompressor *" "&ZlibDecompressorType"
1372+
class zlib._ZlibDecompressor "ZlibDecompressor *" "&ZlibDecompressorType"
13731373
[clinic start generated code]*/
1374-
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=0658178ab94645df]*/
1374+
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=49151d1d703e6bcc]*/
13751375

13761376
static void
13771377
ZlibDecompressor_dealloc(PyObject *op)
@@ -1670,7 +1670,7 @@ decompress(ZlibDecompressor *self, uint8_t *data,
16701670

16711671
/*[clinic input]
16721672
@permit_long_docstring_body
1673-
zlib.ZlibDecompressor.decompress
1673+
zlib._ZlibDecompressor.decompress
16741674
16751675
data: Py_buffer
16761676
max_length: Py_ssize_t=-1
@@ -1692,9 +1692,10 @@ the unused_data attribute.
16921692
[clinic start generated code]*/
16931693

16941694
static PyObject *
1695-
zlib_ZlibDecompressor_decompress_impl(ZlibDecompressor *self,
1696-
Py_buffer *data, Py_ssize_t max_length)
1697-
/*[clinic end generated code: output=990d32787b775f85 input=fcf9f974de5d02b1]*/
1695+
zlib__ZlibDecompressor_decompress_impl(ZlibDecompressor *self,
1696+
Py_buffer *data,
1697+
Py_ssize_t max_length)
1698+
/*[clinic end generated code: output=ac00dcf73e843e99 input=c9278e791be1152b]*/
16981699

16991700
{
17001701
PyObject *result = NULL;
@@ -1710,37 +1711,28 @@ zlib_ZlibDecompressor_decompress_impl(ZlibDecompressor *self,
17101711
return result;
17111712
}
17121713

1713-
PyDoc_STRVAR(ZlibDecompressor__new____doc__,
1714-
"_ZlibDecompressor(wbits=15, zdict=b\'\')\n"
1715-
"--\n"
1716-
"\n"
1717-
"Create a decompressor object for decompressing data incrementally.\n"
1718-
"\n"
1719-
" wbits = 15\n"
1720-
" zdict\n"
1721-
" The predefined compression dictionary. This is a sequence of bytes\n"
1722-
" (such as a bytes object) containing subsequences that are expected\n"
1723-
" to occur frequently in the data that is to be compressed. Those\n"
1724-
" subsequences that are expected to be most common should come at the\n"
1725-
" end of the dictionary. This must be the same dictionary as used by the\n"
1726-
" compressor that produced the input data.\n"
1727-
"\n");
1714+
/*[clinic input]
1715+
@classmethod
1716+
zlib._ZlibDecompressor.__new__
1717+
1718+
type as cls: self
1719+
wbits: int(c_default='MAX_WBITS') = MAX_WBITS
1720+
zdict: object(c_default='NULL') = b''
1721+
The predefined compression dictionary. This is a sequence of bytes
1722+
(such as a bytes object) containing subsequences that are expected
1723+
to occur frequently in the data that is to be compressed. Those
1724+
subsequences that are expected to be most common should come at the
1725+
end of the dictionary. This must be the same dictionary as used by the
1726+
compressor that produced the input data.
1727+
1728+
Create a decompressor object for decompressing data incrementally.
1729+
[clinic start generated code]*/
17281730

17291731
static PyObject *
1730-
ZlibDecompressor__new__(PyTypeObject *cls,
1731-
PyObject *args,
1732-
PyObject *kwargs)
1732+
zlib__ZlibDecompressor_impl(PyTypeObject *cls, int wbits, PyObject *zdict)
1733+
/*[clinic end generated code: output=9f1bf6d28029c5de input=8bffe63eef8a6d63]*/
17331734
{
1734-
static char *keywords[] = {"wbits", "zdict", NULL};
1735-
static const char * const format = "|iO:_ZlibDecompressor";
1736-
int wbits = MAX_WBITS;
1737-
PyObject *zdict = NULL;
17381735
zlibstate *state = PyType_GetModuleState(cls);
1739-
1740-
if (!PyArg_ParseTupleAndKeywords(
1741-
args, kwargs, format, keywords, &wbits, &zdict)) {
1742-
return NULL;
1743-
}
17441736
ZlibDecompressor *self = PyObject_New(ZlibDecompressor, cls);
17451737
if (self == NULL) {
17461738
return NULL;
@@ -1817,7 +1809,7 @@ static PyMethodDef Decomp_methods[] =
18171809
};
18181810

18191811
static PyMethodDef ZlibDecompressor_methods[] = {
1820-
ZLIB_ZLIBDECOMPRESSOR_DECOMPRESS_METHODDEF
1812+
ZLIB__ZLIBDECOMPRESSOR_DECOMPRESS_METHODDEF
18211813
{NULL}
18221814
};
18231815

@@ -2052,8 +2044,8 @@ static PyType_Spec Decomptype_spec = {
20522044
static PyType_Slot ZlibDecompressor_type_slots[] = {
20532045
{Py_tp_dealloc, ZlibDecompressor_dealloc},
20542046
{Py_tp_members, ZlibDecompressor_members},
2055-
{Py_tp_new, ZlibDecompressor__new__},
2056-
{Py_tp_doc, (char *)ZlibDecompressor__new____doc__},
2047+
{Py_tp_new, zlib__ZlibDecompressor},
2048+
{Py_tp_doc, (char *)zlib__ZlibDecompressor__doc__},
20572049
{Py_tp_methods, ZlibDecompressor_methods},
20582050
{0, 0},
20592051
};

0 commit comments

Comments
 (0)