removing \r from streams causes ValueError
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
subunit |
Fix Released
|
Wishlist
|
Martin Pool |
Bug Description
It turns out that this crash occurs if the linefeeds are missing from the multipart section.
File "/home/
self.
File "/home/
residue = self._chunk_
File "/home/
return self.state()
File "/home/
self.
ValueError: invalid literal for int() with base 16: ''
The root cause is that subunits current default stream depends on 8-bit safe, non-cr/lf altering transports. Changing the stream to be more conservative - e.g. not depend on \r\n characters being unaltered, or even on whitespace being unaltered, would avoid this. Some possibilities are uuencoding, json etc. However we need to be able transport 8-bit whitespace and \r, \n containing attachments, and we need to be able to stream things out - a self delimiting format is essential.
Related branches
- Jonathan Lange: Approve
- Martin Pool: Pending requested
-
Diff: 94 lines (+39/-2)2 files modifiedpython/subunit/chunked.py (+15/-2)
python/subunit/tests/test_chunked.py (+24/-0)
Changed in subunit: | |
status: | New → Triaged |
importance: | Undecided → Wishlist |
summary: |
- crashes with "invalid literal for int() with base 16: ''" if linefeeds - are missing from the file + copy and paste or newline mangling can damage streams |
description: | updated |
summary: |
- copy and paste or newline mangling can damage streams + removing \r from streams causes ValueError |
Changed in subunit: | |
status: | Triaged → In Progress |
Changed in subunit: | |
status: | In Progress → Fix Committed |
Changed in subunit: | |
status: | Fix Committed → Fix Released |
The root cause of this is that the subunit protocol and implementation requires the file contain plan carriage returns in some places, and crlf in others. If you lose the linefeeds, you get this error.
In a sense this is user error: I copied the text from a terminal which lost the linefeeds. However requiring this seems to make things unnecessarily difficult for something that's meant to be a human-readable interchange format.