Bug 865033

Summary: Non ascii characters cause traceback when setting into the TestCase.notes
Product: [Fedora] Fedora Reporter: Lukáš Zachar <lzachar>
Component: python-nitrateAssignee: Petr Šplíchal <psplicha>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: ohudlick, psplicha
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-01-07 18:53:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
partial patch none

Description Lukáš Zachar 2012-10-10 16:32:47 UTC
Description of problem:

Let's have a string I'd like to set as notes containing Unicode character, e.g. "\u2026".

When I set such string to tc.notes (nitrate.TestCase object) I got:

  File "/home/lzachar/work-gits/lzachar/jungle/massUpdate", line 236, in doGitLink
    tc.notes = new_notes
  File "/home/lzachar/work-gits/python-nitrate/source/api.py", line 215, in setter
    self.identifier, field, value))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 

When I commented out the code where in api.py (it is just a log output), everything run correctly. 

I suspect there can be other log outputs, where can trace back too (but for other inputs/program flow). 

Version-Release number of selected component (if applicable):
git HEAD = a62ebb5 New TestCase reference link field [BZ#843382]

How reproducible:
always

Steps to Reproduce:
1. make string containing Unicode
2. create a TC and set its notes to the string above
  
Actual results:
traceback

Expected results:
no traceback

Additional info:

Comment 1 Lukáš Zachar 2012-10-12 11:10:42 UTC
It seems to be the problem of the format string. 

See:
In [13]: print "Updating {0}'s {1} to '{2}'".format(1, 'foo', u'\u2026')
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 0: ordinal not in range(128)

But:
In [15]: u"Updating {0}'s {1} to '{2}'".format(1, 'foo', u'\u2026')
Out[15]: u"Updating 1's foo to '\u2026'"

I am not sure if this is the best way how to fix is, though.

Comment 2 Lukáš Zachar 2012-10-12 11:27:51 UTC
Created attachment 625914 [details]
partial patch

This patch fixes only the error in the situation when I run into it. 
It might be necessary to fix other/all "".format() calls.

Comment 3 Petr Šplíchal 2012-12-06 11:59:48 UTC
Thanks for the patch, I've pushed it to the git repo
https://github.com/psss/python-nitrate/commit/2d19ffa

and also applied the same fix for other necessary places:
https://github.com/psss/python-nitrate/commit/24d5841

Comment 4 Fedora Update System 2012-12-10 12:42:23 UTC
python-nitrate-0.9-0.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/python-nitrate-0.9-0.el6

Comment 5 Fedora Update System 2012-12-10 12:49:16 UTC
python-nitrate-0.9-0.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/python-nitrate-0.9-0.fc18

Comment 6 Fedora Update System 2012-12-10 12:49:17 UTC
python-nitrate-0.9-0.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/python-nitrate-0.9-0.fc16

Comment 7 Fedora Update System 2012-12-10 12:49:23 UTC
python-nitrate-0.9-0.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/python-nitrate-0.9-0.fc17

Comment 8 Fedora Update System 2012-12-11 07:47:48 UTC
python-nitrate-0.9-0.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/FEDORA-EPEL-2012-13721/python-nitrate-0.9-0.el6

Comment 9 Petr Šplíchal 2012-12-11 08:01:06 UTC
Package python-nitrate-0.9-0.el6:
* should fix your issue,
* was pushed to the Fedora EPEL 6 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=epel-testing python-nitrate-0.9-0.el6'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-EPEL-2012-13721/python-nitrate-0.9-0.el6
then log in and leave karma (feedback).

Comment 10 Lukáš Zachar 2012-12-11 09:01:41 UTC
Tried the same and it works now.

Comment 11 Fedora Update System 2012-12-19 08:33:24 UTC
python-nitrate-0.9-0.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 12 Fedora Update System 2012-12-19 08:43:53 UTC
python-nitrate-0.9-0.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 13 Fedora Update System 2013-01-07 18:53:08 UTC
python-nitrate-0.9-0.el6 has been pushed to the Fedora EPEL 6 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 14 Fedora Update System 2013-01-12 01:10:26 UTC
python-nitrate-0.9-0.fc18 has been pushed to the Fedora 18 stable repository.  If problems still persist, please make note of it in this bug report.