Skip to content

Commit

Permalink
rdfpipe: open stdout in buffer mode in Python3 format
Browse files Browse the repository at this point in the history
Due to sys.stdout being string mode in Python 3 and all of the serializing
happening in bytes mode, we need to open sys.stdout.buffer instead to avoid the
exception "TypeError: must be str, not bytes". Closes RDFLib#375.

Signed-off-by: Dan Scott <[email protected]>
  • Loading branch information
dbs committed Apr 2, 2014
1 parent f981fdb commit af87abe
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rdflib/tools/rdfpipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from rdflib.serializer import Serializer

from rdflib.util import guess_format
from rdflib.py3compat import PY3


DEFAULT_INPUT_FORMAT = 'xml'
Expand Down Expand Up @@ -170,6 +171,9 @@ def main():
ns_bindings[pfx] = uri

outfile = sys.stdout
if PY3:
outfile = sys.stdout.buffer

if opts.no_out:
outfile = None

Expand Down

0 comments on commit af87abe

Please sign in to comment.