-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Be robust against invalid utf-8 byte sequences and surrogateescape th…
…em when en- or decoding This commit also takes the opportunity to remove Python 2 string compatibility code. It will also remove the final left-over Python 2 compatibility in the test cases.
- Loading branch information
Showing
17 changed files
with
134 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from io import BytesIO | ||
|
||
from flow.record import RecordDescriptor | ||
from flow.record.adapter.line import LineWriter | ||
|
||
|
||
def test_line_writer_write(): | ||
output = BytesIO() | ||
|
||
lw = LineWriter( | ||
path=output, | ||
fields="name", | ||
) | ||
|
||
TestRecord = RecordDescriptor( | ||
"test/string", | ||
[ | ||
("string", "name"), | ||
], | ||
) | ||
|
||
# construct from 'bytes' but with invalid unicode bytes | ||
record = TestRecord(b"R\xc3\xa9\xeamy") | ||
lw.write(record) | ||
|
||
output.seek(0) | ||
data = output.read() | ||
|
||
assert data == b"--[ RECORD 1 ]--\nname = R\xc3\xa9\xeamy\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from io import BytesIO | ||
|
||
from flow.record import RecordDescriptor | ||
from flow.record.adapter.text import TextWriter | ||
|
||
|
||
def test_text_writer_write(): | ||
output = BytesIO() | ||
|
||
tw = TextWriter( | ||
path=output, | ||
) | ||
|
||
TestRecord = RecordDescriptor( | ||
"test/string", | ||
[ | ||
("string", "name"), | ||
], | ||
) | ||
|
||
# construct from 'bytes' but with invalid unicode bytes | ||
record = TestRecord(b"R\xc3\xa9\xeamy") | ||
tw.write(record) | ||
|
||
output.seek(0) | ||
data = output.read() | ||
|
||
assert data == b"<test/string name='R\xc3\xa9\\udceamy'>\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.