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
import sys
def print_enc(string):
version = sys.version_info[0]
if version == 2:
print(string)
elif version == 3:
sys.stdout.buffer.write(string)
def print_enc(s):
'''Print function compatible with both python2 and python3 accepting strings
and byte arrays.
'''
print(s.decode('utf-8') if type(s) == type(b'') else s)

View file

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