-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
Conversation
…at offers non-destructive behavior for csv documents with duplicate fieldname values.
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:
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): |
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.
There would need to be a DeprecationWarning raised at some point here.
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.
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)) |
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.
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...)
…e wrong behavior if data and headers did not match up in length.
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.
No doc and test for TableReader.
But agreement about adding TableReader is required in bugs.python.org before it.
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.
You just cannot remove a public class: https://docs.python.org/dev/library/csv.html#csv.DictReader
Closing as rejected. |
Fixes python#223 Signed-off-by: Filipe Laíns <lains@riseup.net>
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.