From 1c9f01a265b3ed6fc8ecdb9e9e01d11ac375d7b3 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jul 11 2016 13:02:20 +0000 Subject: Create the content as an unicode string before converting it to bytes when writing --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 8f45036..4b35412 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -1036,8 +1036,9 @@ def new_project(session, user, name, blacklist, allowed_prefix, author = pygit2.Signature( userobj.fullname.encode('utf-8'), userobj.default_email.encode('utf-8')) - f = open(os.path.join(temp_gitrepo.workdir,"README.md"), 'w') - f.write("# %s\n\n%s" % (name.encode('utf-8'), description.encode('utf-8'))) + content = u"# %s\n\n%s" % (name, description) + f = open(os.path.join(temp_gitrepo.workdir,"README.md"), 'wb') + f.write(content.encode('utf-8')) f.close() temp_gitrepo.index.add_all() temp_gitrepo.index.write()