From d6cbfdb81cd39a142a6377c803790fa659caf046 Mon Sep 17 00:00:00 2001 From: Lars Kiesow Date: Sun, 11 May 2014 19:53:29 +0200 Subject: [PATCH] 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 --- feedgen/__main__.py | 12 +++++------- setup.py | 1 + 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/feedgen/__main__.py b/feedgen/__main__.py index bc34a55..1ff4d0a 100644 --- a/feedgen/__main__.py +++ b/feedgen/__main__.py @@ -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) diff --git a/setup.py b/setup.py index 92ba3c2..059dcb7 100755 --- a/setup.py +++ b/setup.py @@ -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',