From af87abed7bace27960de87ef30e85ce30e512c09 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Mon, 31 Mar 2014 14:58:49 -0400 Subject: [PATCH] rdfpipe: open stdout in buffer mode in Python3 format 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 #375. Signed-off-by: Dan Scott --- rdflib/tools/rdfpipe.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rdflib/tools/rdfpipe.py b/rdflib/tools/rdfpipe.py index df15d13e8..9fb4b3b94 100644 --- a/rdflib/tools/rdfpipe.py +++ b/rdflib/tools/rdfpipe.py @@ -18,6 +18,7 @@ from rdflib.serializer import Serializer from rdflib.util import guess_format +from rdflib.py3compat import PY3 DEFAULT_INPUT_FORMAT = 'xml' @@ -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