Fix issues with python3

The introduced way of printing things in python3 would work for byte
arrays but not for simple strings. This patch fixes this issue.

Signed-off-by: Lars Kiesow <lkiesow@uos.de>
This commit is contained in:
Lars Kiesow 2014-05-11 19:53:29 +02:00
parent a787b22b7f
commit d6cbfdb81c
No known key found for this signature in database
GPG key ID: 5DAFE8D9C823CE73
2 changed files with 6 additions and 7 deletions

View file

@ -11,13 +11,11 @@
from feedgen.feed import FeedGenerator from feedgen.feed import FeedGenerator
import sys import sys
def print_enc(string): def print_enc(s):
version = sys.version_info[0] '''Print function compatible with both python2 and python3 accepting strings
and byte arrays.
if version == 2: '''
print(string) print(s.decode('utf-8') if type(s) == type(b'') else s)
elif version == 3:
sys.stdout.buffer.write(string)

View file

@ -27,6 +27,7 @@ setup(
'Operating System :: OS Independent', 'Operating System :: OS Independent',
'Programming Language :: Python', 'Programming Language :: Python',
'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: Communications', 'Topic :: Communications',
'Topic :: Internet', 'Topic :: Internet',
'Topic :: Text Processing', 'Topic :: Text Processing',