GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-40077: Convert _csv module to use PyType_FromSpec by corona10 · Pull Request #20974 · python/cpython

Conversation

@corona10

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

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

https://bugs.python.org/issue40077

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
corona10 added 2 commits June 19, 2020 12:09
@corona10
bpo-40077: Convert _csv module to use PyType_FromSpec
f80d4c6
@corona10
bpo-40077: Add NEWS.d
53df5eb
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Jun 19, 2020
@bedevere-bot bedevere-bot added the awaiting core review label Jun 19, 2020
@corona10 corona10 added the DO-NOT-MERGE label Jun 19, 2020
corona10 added 2 commits June 19, 2020 15:02
@corona10
bpo-40077: Update
dbc4d32
@corona10
bpo-40077: PEP7
9f1266b
@corona10 corona10 removed the DO-NOT-MERGE label Jun 19, 2020
@corona10
corona10 requested a review from vstinner June 19, 2020 06:14
corona10
corona10 commented Jun 19, 2020
View reviewed changes

@corona10 corona10 left a comment

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

@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)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@corona10

corona10 commented Jun 19, 2020

Copy link
Copy Markdown
Member Author

FYI, macOS CI issue is not related to this PR

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner
vstinner reviewed Jun 19, 2020
View reviewed changes
Comment thread Modules/_csv.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_csv.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_csv.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_csv.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

corona10 added 3 commits June 19, 2020 19:26
@corona10
bpo-40077: Update
85d36e9
@corona10
bpo-40077: Update
10114f0
@corona10
bpo-40077: Apply Victor's suggestion
14c6de7
@corona10
corona10 requested a review from vstinner June 19, 2020 10:39
corona10
corona10 commented Jun 19, 2020
View reviewed changes

@corona10 corona10 left a comment

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

@vstinner

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
vstinner
vstinner requested changes Jun 19, 2020
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Modules/_csv.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

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

_csvstate *state = PyType_GetModuleState(type);

@vstinner vstinner Jun 19, 2020

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
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);

@vstinner vstinner Jun 19, 2020

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

@vstinner vstinner Jun 19, 2020

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting changes and removed awaiting core review labels Jun 19, 2020
@bedevere-bot

bedevere-bot commented Jun 19, 2020

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Jun 22, 2020

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@corona10 corona10 mentioned this pull request Sep 27, 2020
bpo-41861: Convert sqlite3 cache and node types to heap types #22417
Merged
@encukou encukou mentioned this pull request Nov 10, 2020
bpo-14935: Remove static state from the _csv module #23224
Merged
@encukou

encukou commented Dec 15, 2020

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@encukou encukou closed this Dec 15, 2020
@corona10 corona10 mentioned this pull request Jun 27, 2022
Convert static types to heap types: use PyType_FromSpec() #84258
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner requested changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting changes

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@corona10 @bedevere-bot @vstinner @encukou @the-knights-who-say-ni
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.