Bug 865033 - Non ascii characters cause traceback when setting into the TestCase.notes
Non ascii characters cause traceback when setting into the TestCase.notes
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: python-nitrate (Show other bugs)
rawhide
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Petr Šplíchal
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-10-10 12:32 EDT by Lukas Zachar
Modified: 2016-05-31 21:43 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-01-07 13:53:06 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
partial patch (961 bytes, patch)
2012-10-12 07:27 EDT, Lukas Zachar
no flags Details | Diff

  None (edit)
Description Lukas Zachar 2012-10-10 12:32:47 EDT
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 Lukas Zachar 2012-10-12 07:10:42 EDT
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 Lukas Zachar 2012-10-12 07:27:51 EDT
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 06:59:48 EST
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 07:42:23 EST
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 07:49:16 EST
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 07:49:17 EST
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 07:49:23 EST
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 02:47:48 EST
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 03:01:06 EST
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 Lukas Zachar 2012-12-11 04:01:41 EST
Tried the same and it works now.
Comment 11 Fedora Update System 2012-12-19 03:33:24 EST
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 03:43:53 EST
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 13:53:08 EST
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-11 20:10:26 EST
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.

Note You need to log in before you can comment on or make changes to this bug.