Skip to content

Commit

Permalink
Merge pull request jordansissel#575 from brutasse/fix/unicode
Browse files Browse the repository at this point in the history
Fix get_metadata to handle unicode strings
  • Loading branch information
jordansissel committed Oct 29, 2013
2 parents 57fd049 + 0c8a957 commit eb0068c
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/fpm/package/pyfpm/get_metadata.py
@@ -1,11 +1,23 @@
from distutils.core import Command
import os
import sys
import pkg_resources
try:
import json
except ImportError:
import simplejson as json

PY3 = sys.version_info[0] == 3

if PY3:
def u(s):
return s
else:
def u(s):
if isinstance(u, unicode):
return u
return s.decode('utf-8')


# Note, the last time I coded python daily was at Google, so it's entirely
# possible some of my techniques below are outdated or bad.
Expand Down Expand Up @@ -48,9 +60,9 @@ def run(self):
data = {
"name": self.distribution.get_name(),
"version": self.distribution.get_version(),
"author": "%s <%s>" % (
self.distribution.get_author(),
self.distribution.get_author_email(),
"author": u("%s <%s>") % (
u(self.distribution.get_author()),
u(self.distribution.get_author_email()),
),
"description": self.distribution.get_description(),
"license": self.distribution.get_license(),
Expand Down

0 comments on commit eb0068c

Please sign in to comment.