FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-40077: Convert _csv module to use PyType_FromSpec by corona10 · Pull Request #20974 · python/cpython · GitHub

/ cpython Public

bpo-40077: Convert _csv module to use PyType_FromSpec - #20974

Closed
corona10 wants to merge 7 commits into
python:masterfrom
corona10:bpo-40077-csv
Closed

bpo-40077: Convert _csv module to use PyType_FromSpec #20974
corona10 wants to merge 7 commits into
python:masterfrom
corona10:bpo-40077-csv

Conversation

corona10 commented Jun 19, 2020
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

corona10 requested a review from vstinner June 19, 2020 06:14

corona10 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@vstinner
Please take a look

I locally tested with _csv module on subinterpreter and module test
And there was no leak.
(But import csv with subinterpreter still has leaks but not related to this PR)

Copy link
Copy Markdown
Member Author

FYI, macOS CI issue is not related to this PR

Comment thread Modules/_csv.c Outdated
Comment thread Modules/_csv.c Outdated
Comment thread Modules/_csv.c
Comment thread Modules/_csv.c Outdated
corona10 requested a review from vstinner June 19, 2020 10:39

corona10 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@vstinner

Thanks all of your reviews are applied and no memory leak was found!

vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm not sure that it's possible to convert static types to heap types if they have Py_TPFLAGS_BASETYPE, since currently there is no way to retrieve the module from such type.

Comment thread Modules/_csv.c
Comment thread Modules/_csv.c
&strict))
return NULL;

_csvstate *state = PyType_GetModuleState(type);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

PyType_GetModuleState() is not safe if the type has Py_TPFLAGS_BASETYPE flag, which is the case here.

Is there a way to get the defining type in tp_new?

Comment thread Modules/_csv.c
PyErr_Format(_csvstate_global->error_obj, "field larger than field limit (%ld)",
_csvstate_global->field_limit);
PyTypeObject *reader_type = Py_TYPE(self);
_csvstate *state = PyType_GetModuleState(reader_type);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The Reader type has Py_TPFLAGS_BASETYPE: PyType_GetModuleState() is unsafe here.

Comment thread Modules/_csv.c
return NULL;
}
self->dialect = (DialectObj *)_call_dialect(dialect, keyword_args);
_csvstate *state = get_csv_state(module);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

state can be moved at the beginning of the function, to avoid calling get_csv_state() twice.

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

Copy link
Copy Markdown
Member

I understand that this PR (if merged) would fix https://bugs.python.org/issue14935

encukou commented Dec 15, 2020

Copy link
Copy Markdown
Member

The issue is now closed via #23224.
Thank you for working on it, though!

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL