encode record delimiter as ascii bytes when str is passed

This commit is contained in:
Mark Riedesel 2022-02-06 11:06:51 -06:00
parent 042de7ecb0
commit 86f8861da1
2 changed files with 4 additions and 1 deletions

View file

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

View file

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