8000 bpo-29614: Rename and reimplement csv.DictReader. by foxfluff · Pull Request #223 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-29614: Rename and reimplement csv.DictReader. #223

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

Closed
wants to merge 4 commits into from

Conversation

foxfluff
Copy link

Rename and modify current implementation of DictReader to TableReader that offers non-destructive behavior for csv documents with duplicate fieldname values.

Create new class DictReader as a child to TableReader, allowing for backwards compatibility.

…at offers non-destructive behavior for csv documents with duplicate fieldname values.
@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow these steps to rectify the issue:

  1. Sign the PSF contributor agreement
  2. Wait at least one US business day and then check "Your Details" on bugs.python.org to see if your account has been marked as having signed the CLA (the delay is due to a person having to manually check your signed CLA)
  3. Reply here saying you have completed the above steps

Thanks again to your contribution and we look forward to looking at it!

@@ -128,6 +128,11 @@ def __next__(self):
return d


class DictReader(TableReader):
Copy link
Member

Choose a reason for hiding this comment

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

There would need to be a DeprecationWarning raised at some point here.

Copy link
Author

Choose a reason for hiding this comment

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

Would a DeprecationWarning be appropriate here? as this ideally would not affect the behavior of DictReader, and would instead just add the "new" functionality of TableReader.

Lib/csv.py Outdated
@@ -117,7 +117,7 @@ def __next__(self):
# values
while row == []:
row = next(self.reader)
d = OrderedDict(zip(self.fieldnames, row))
d = tuple(zip(self.fieldnames, row))
Copy link
Author

Choose a reason for hiding this comment

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

Tests failed due to using tuple instead of list (as line 127 will attempt to write to what is now non-mutable)
Needs to be changed to list(zip...)

Copy link
Member
@methane methane left a comment

Choose a reason for hiding this comment

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

No doc and test for TableReader.

But agreement about adding TableReader is required in bugs.python.org before it.

Copy link
Member
@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

You just cannot remove a public class: https://docs.python.org/dev/library/csv.html#csv.DictReader

@vstinner vstinner changed the title bpo-29614: Rename and reimplement DictReader. bpo-29614: Rename and reimplement csv.DictReader. Feb 22, 2017
@foxfluff
Copy link
Author

Closing as rejected.

@foxfluff foxfluff closed this Feb 23, 2017
@foxfluff foxfluff deleted the fix-issue-29614 branch February 23, 2017 02:48
jaraco pushed a commit that referenced this pull request Dec 2, 2022
jaraco pushed a commit to jaraco/cpython that referenced this pull request Feb 17, 2023
Fixes python#223

Signed-off-by: Filipe Laíns <lains@riseup.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0