encode record delimiter as ascii bytes when str is passed
This commit is contained in:
parent
042de7ecb0
commit
86f8861da1
2 changed files with 4 additions and 1 deletions
|
@ -58,6 +58,8 @@ def loads(s, record_types=get_record_types()):
|
|||
|
||||
|
||||
def dump(fp, records, delim=None):
|
||||
if type(delim) is str:
|
||||
delim = delim.encode('ascii')
|
||||
for r in records:
|
||||
fp.write(r.output())
|
||||
if delim:
|
||||
|
|
|
@ -90,7 +90,8 @@ class TestFileFormats(unittest.TestCase):
|
|||
record_identifier = 'B' # 1 byte
|
||||
zero1 = ZeroField(max_length=32)
|
||||
text1 = TextField(max_length=71)
|
||||
blank2 = BlankField(max_length=24)
|
||||
text2 = TextField(max_length=20)
|
||||
blank2 = BlankField(max_length=4)
|
||||
|
||||
record_types = [TestModelA, TestModelB]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue