Skip to content

Commit

Permalink
Don't use universal newlines with tsdb.open()
Browse files Browse the repository at this point in the history
Fixes #285
  • Loading branch information
goodmami committed May 12, 2020
1 parent 22be16c commit 58457ba
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ these changes are prefixed with "**BREAKING**"

## [Unreleased][unreleased]

(no unreleased changes)
### Fixed

* `delphin.tsdb.open()` does not use universal newlines ([#285])


## [v1.2.3]
Expand Down Expand Up @@ -1358,3 +1360,4 @@ information about changes, except for
[#281]: https://github.com/delph-in/pydelphin/issues/281
[#282]: https://github.com/delph-in/pydelphin/issues/282
[#283]: https://github.com/delph-in/pydelphin/issues/283
[#285]: https://github.com/delph-in/pydelphin/issues/285
4 changes: 2 additions & 2 deletions delphin/tsdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,9 +766,9 @@ def open(dir: util.PathLike,
"""
path = get_path(dir, name)
if path.suffix.lower() == '.gz':
return gzopen(path, mode='rt', encoding=encoding)
return gzopen(path, mode='rt', encoding=encoding, newline='\n')
else:
return path.open(encoding=encoding)
return path.open(encoding=encoding, newline='\n')


def write(dir: util.PathLike,
Expand Down
10 changes: 10 additions & 0 deletions tests/tsdb_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,16 @@ def test_write(single_item_skeleton):
assert path.with_suffix('').exists()


def test_issue_285(empty_testsuite):
fields = tsdb.read_schema(empty_testsuite)['item']
tsdb.write(empty_testsuite, 'item', [(0, 'The cat meows.\r')], fields)
fh = tsdb.open(empty_testsuite, 'item')
assert not fh.closed
with fh:
assert list(fh) == ['0@The cat meows.\r\n']
assert fh.closed


def test_write_database(tmp_path, mini_testsuite, empty_alt_testsuite):
tmp_ts = tmp_path.joinpath('test_write_database')
db = tsdb.Database(mini_testsuite)
Expand Down

0 comments on commit 58457ba

Please sign in to comment.