Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode Error if title is encoded as unicode string #112

Boldie opened this issue Oct 22, 2015 · 3 comments

Encode Error if title is encoded as unicode string #112

Boldie opened this issue Oct 22, 2015 · 3 comments


Copy link

@Boldie Boldie commented Oct 22, 2015

I have version 1.4.0 installed and I still have a similar bug when doing the following line (the string was loaded from another redmine installation via get before):

rmTo.wiki_page.create(text= 'h1. test', project_id= 'project', title=u'Kompatibilit\xe4t')

I got this error:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/redmine/", line 172, in create
    url = '{0}{1}'.format(self.redmine.url, formatter.format(self.resource_class.query_create, **fields))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 31: ordinal not in range(128)

After further investigations, I found a workaround to convert the title to utf-8 before passing it to create. I am not sure if this is a good way and maybe the conversion should be made dependent on the data coming in.

@maxtepkeev maxtepkeev added the bug label Oct 25, 2015
@maxtepkeev maxtepkeev self-assigned this Oct 25, 2015
Copy link

@maxtepkeev maxtepkeev commented Oct 25, 2015

Thanks for the report. After some testing I can confirm that this is a bug in Python-Redmine. I know how to properly fix it once and for all, but this will require some internal library redesign and I don't have time to do this right now. Your workaround is perfectly fine, so please keep using it until this problem won't be fixed in Python-Redmine internally.

Copy link

@Digenis Digenis commented Mar 8, 2016

I encountered the same problem while iterating wiki pages
with their names as returned by project.wiki_pages.
I fixed it as follows:

diff --git a/redmine/ b/redmine/
index 81061ab..76e14ad 100644
--- a/redmine/
+++ b/redmine/
@@ -4,6 +4,7 @@ from distutils.version import LooseVersion

 from .resultsets import ResourceSet
 from .utilities import MemorizeFormatter
+from .utilities import to_string, is_string
 from .exceptions import (
@@ -118,7 +119,9 @@ class ResourceManager(object):
         """Returns a Resource object directly by resource id (can be either integer id or string identifier)"""
         if self.resource_class.query_one is None or self.resource_class.container_one is None:
             raise ResourceBadMethodError

+        if is_string(resource_id):
+            resource_id = to_string(resource_id)
             self.url = '{0}{1}'.format(self.redmine.url, self.resource_class.query_one.format(resource_id, **params))
         except KeyError as exception:

I understand that you care about code quality want to avoid this kind of patching
but is there any chance to get some b u f i x i n g in the current, stable version?
A r e d e s i g n, even after being released, will remain some time in beta status.

maxtepkeev added a commit that referenced this issue Mar 26, 2016
Copy link

@maxtepkeev maxtepkeev commented Mar 27, 2016

All unicode issues should now be fixed in v1.5.1

@Digenis BTW, in your current case with wiki_pages you could use wiki_page.refresh() which returns new wiki_page object from Redmine with all possible information available. This is a convenient shortcut to redmine.wiki_page.get('Foo', project_id='bar'). refresh() is also available for all other resources as well.

@maxtepkeev maxtepkeev closed this Mar 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.