8000 bpo-40077: Convert _bz2 module to use PyType_FromSpec by corona10 · Pull Request #20960 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
8000

bpo-40077: Convert _bz2 module to use PyType_FromSpec #20960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 19, 2020
Merged
Diff view
Diff view
Prev Previous commit
bpo-40077: Apply Victor's review
  • Loading branch information
corona10 committed Jun 19, 2020
commit 89ecd25b3b88a78f01bea72bc573621d6f7bd322
11 changes: 7 additions & 4 deletions Modules/_bz2module.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ BZ2_Free(void* ctx, void *ptr)
PyMem_RawFree(ptr);
}

// TODO: Convert it to clinic

/* Argument Clinic is not used since the Argument Clinic always want to
check the type which would be wrong here */
static int
_bz2_BZ2Compressor___init___impl(BZ2Compressor *self, int compresslevel)
{
Expand Down Expand Up @@ -415,7 +417,7 @@ static PyType_Spec bz2_compressor_type_spec = {
.name = "_bz2.BZ2Compressor",
.basicsize = sizeof(BZ2Compressor),
// Calling PyType_GetModuleState() on a subclass is not safe.
// dbmtype_spec does not have Py_TPFLAGS_BASETYPE flag
// bz2_compressor_type_spec does not have Py_TPFLAGS_BASETYPE flag
// which prevents to create a subclass.
// So calling PyType_GetModuleState() in this file is always safe.
.flags = Py_TPFLAGS_DEFAULT,
Expand Down Expand Up @@ -655,7 +657,8 @@ _bz2_BZ2Decompressor___reduce___impl(BZ2Decompressor *self)
return NULL;
}

// TODO: Convert it to clinic
/* Argument Clinic is not used since the Argument Clinic always want to
check the type which would be wrong here */
static int
_bz2_BZ2Decompressor___init___impl(BZ2Decompressor *self)
{
Expand Down Expand Up @@ -781,7 +784,7 @@ static PyType_Spec bz2_decompressor_type_spec = {
.name = "_bz2.BZ2Decompressor",
.basicsize = sizeof(BZ2Decompressor),
// Calling PyType_GetModuleState() on a subclass is not safe.
// dbmtype_spec does not have Py_TPFLAGS_BASETYPE flag
// bz2_decompressor_type_spec does not have Py_TPFLAGS_BASETYPE flag
// which prevents to create a subclass.
// So calling PyType_GetModuleState() in this file is always safe.
.flags = Py_TPFLAGS_DEFAULT,
Expand Down
0