# HG changeset patch # User Paul Boddie # Date 1422741682 -3600 # Node ID 6a1962f0e6fd98fccb3b04d6541b6da465905010 # Parent be11a8a23d92e1c086ee45513e885959057b5d80 Actually make proper Unicode readers and writers for plain files instead of just returning the file object for use. diff -r be11a8a23d92 -r 6a1962f0e6fd vContent.py --- a/vContent.py Sat Jan 31 23:00:27 2015 +0100 +++ b/vContent.py Sat Jan 31 23:01:22 2015 +0100 @@ -4,7 +4,7 @@ Parsing of vCard, vCalendar and iCalendar files. Copyright (C) 2005, 2006, 2007, 2008, 2009, 2011, 2013, - 2014 Paul Boddie + 2014, 2015 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -613,13 +613,19 @@ def get_input_stream(stream_or_string, encoding=None): if is_input_stream(stream_or_string): - return stream_or_string + if isinstance(stream_or_string, codecs.StreamReader): + return stream_or_string + else: + return codecs.getreader(encoding or default_encoding)(stream_or_string) else: return codecs.open(stream_or_string, encoding=(encoding or default_encoding)) def get_output_stream(stream_or_string, encoding=None): if hasattr(stream_or_string, "write"): - return stream_or_string + if isinstance(stream_or_string, codecs.StreamWriter): + return stream_or_string + else: + return codecs.getwriter(encoding or default_encoding)(stream_or_string) else: return codecs.open(stream_or_string, "w", encoding=(encoding or default_encoding))