Skip to content

Commit 13dc0ba

Browse files
committed
add failing tests for dumppdf crash
1 parent 6b509c5 commit 13dc0ba

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

tests/test_tools_dumppdf.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import warnings
2-
2+
from nose.tools import raises
33
from helpers import absolute_sample_path
44
from tempfilepath import TemporaryFilePath
55
from pdfminer.pdfdocument import PDFNoValidXRefWarning
@@ -51,3 +51,13 @@ def test_5(self):
5151

5252
def test_6(self):
5353
run('nonfree/naacl06-shinyama.pdf', '-t -a')
54+
55+
@raises(TypeError)
56+
def test_simple1_raw(self):
57+
"""Known issue: crash in dumpxml writing binary to text stream."""
58+
run('simple1.pdf', '-r -a')
59+
60+
@raises(TypeError)
61+
def test_simple1_binary(self):
62+
"""Known issue: crash in dumpxml writing binary to text stream."""
63+
run('simple1.pdf', '-b -a')

tools/dumppdf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ def dumpxml(out: TextIO, obj: object, codec: Optional[str] = None) -> None:
6161

6262
if isinstance(obj, PDFStream):
6363
if codec == 'raw':
64-
# Likely bug: writing bytes to text I/O.
64+
# Bug: writing bytes to text I/O. This will raise TypeError.
6565
out.write(obj.get_rawdata()) # type: ignore [arg-type]
6666
elif codec == 'binary':
67-
# Likely bug: writing bytes to text I/O.
67+
# Bug: writing bytes to text I/O. This will raise TypeError.
6868
out.write(obj.get_data()) # type: ignore [arg-type]
6969
else:
7070
out.write('<stream>\n<props>\n')

0 commit comments

Comments
 (0)