diff options
author | Dan Scott <dan@coffeecode.net> | 2014-03-31 14:58:49 -0400 |
---|---|---|
committer | Dan Scott <dan@coffeecode.net> | 2014-04-02 11:48:34 -0400 |
commit | af87abed7bace27960de87ef30e85ce30e512c09 (patch) | |
tree | 19c419a4a2ccf2f5f142ea97afbf50040fefc562 /rdflib/tools | |
parent | f981fdb2f55bae8bdcc15173e92a620aba6de2a2 (diff) | |
download | rdflib-af87abed7bace27960de87ef30e85ce30e512c09.tar.gz |
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 <dan@coffeecode.net>
Diffstat (limited to 'rdflib/tools')
-rw-r--r-- | rdflib/tools/rdfpipe.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/rdflib/tools/rdfpipe.py b/rdflib/tools/rdfpipe.py index df15d13e..9fb4b3b9 100644 --- a/rdflib/tools/rdfpipe.py +++ b/rdflib/tools/rdfpipe.py @@ -18,6 +18,7 @@ from rdflib.parser import Parser 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 |