Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(10573)

Delta Between Two Patch Sets: Lib/csv.py

Issue 18829: csv produces confusing error message when passed a non-string delimiter
Left Patch Set: Created 6 years ago
Right Patch Set: Created 6 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | Lib/test/test_csv.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 1
2 """ 2 """
3 csv.py - read/write/investigate CSV files 3 csv.py - read/write/investigate CSV files
4 """ 4 """
5 5
6 import re 6 import re
7 from _csv import Error, __version__, writer, reader, register_dialect, \ 7 from _csv import Error, __version__, writer, reader, register_dialect, \
8 unregister_dialect, get_dialect, list_dialects, \ 8 unregister_dialect, get_dialect, list_dialects, \
9 field_size_limit, \ 9 field_size_limit, \
10 QUOTE_MINIMAL, QUOTE_ALL, QUOTE_NONNUMERIC, QUOTE_NONE, \ 10 QUOTE_MINIMAL, QUOTE_ALL, QUOTE_NONNUMERIC, QUOTE_NONE, \
(...skipping 28 matching lines...) Expand all
39 quoting = None 39 quoting = None
40 40
41 def __init__(self): 41 def __init__(self):
42 if self.__class__ != Dialect: 42 if self.__class__ != Dialect:
43 self._valid = True 43 self._valid = True
44 self._validate() 44 self._validate()
45 45
46 def _validate(self): 46 def _validate(self):
47 try: 47 try:
48 _Dialect(self) 48 _Dialect(self)
49 except TypeError as e: 49 except (TypeError, ValueError) as e:
50 # We do this for compatibility with py2.3 50 # We do this for compatibility with py2.3
51 raise Error(str(e)) 51 raise Error(str(e))
52 52
53 class excel(Dialect): 53 class excel(Dialect):
54 """Describe the usual properties of Excel-generated CSV files.""" 54 """Describe the usual properties of Excel-generated CSV files."""
55 delimiter = ',' 55 delimiter = ','
56 quotechar = '"' 56 quotechar = '"'
57 doublequote = True 57 doublequote = True
58 skipinitialspace = False 58 skipinitialspace = False
59 lineterminator = '\r\n' 59 lineterminator = '\r\n'
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 hasHeader -= 1 440 hasHeader -= 1
441 else: # attempt typecast 441 else: # attempt typecast
442 try: 442 try:
443 colType(header[col]) 443 colType(header[col])
444 except (ValueError, TypeError): 444 except (ValueError, TypeError):
445 hasHeader += 1 445 hasHeader += 1
446 else: 446 else:
447 hasHeader -= 1 447 hasHeader -= 1
448 448
449 return hasHeader > 0 449 return hasHeader > 0
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+