Skip to content

Commit

Permalink
Fix issues with python3
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
lkiesow committed May 11, 2014
1 parent a787b22 commit d6cbfdb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
12 changes: 5 additions & 7 deletions feedgen/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: Communications',
'Topic :: Internet',
'Topic :: Text Processing',
Expand Down

0 comments on commit d6cbfdb

Please sign in to comment.