Bug 1258915 - unicode(CoprResponse(...)) causes TypeError: coercing to Unicode: need string or buffer, dict found
Summary: unicode(CoprResponse(...)) causes TypeError: coercing to Unicode: need string...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Copr
Classification: Community
Component: frontend
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Kadlčík
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-09-01 14:06 UTC by Radek Holy
Modified: 2015-10-15 09:45 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-10-15 09:45:53 UTC
Embargoed:


Attachments (Terms of Use)

Description Radek Holy 2015-09-01 14:06:18 UTC
Description of problem:
An attempt to print a string representation of a CoprResponse instance causes a traceback.


Version-Release number of selected component (if applicable):
python-copr-1.58-1.fc21.noarch


How reproducible:
always


Steps to Reproduce:
1. from copr.client import CoprClient
2. cl = CoprClient.create_from_file_config()
3. prj = cl.get_project_details('dnf')
4. unicode(prj)


Actual results:
Traceback (most recent call last):
  File "/tmp/stack/dnfstackci.py", line 974, in <module>
    _start_commandline()
  File "/tmp/stack/dnfstackci.py", line 784, in _start_commandline
    unicode(prj)
TypeError: coercing to Unicode: need string or buffer, dict found


Expected results:
Successful conversion of the instance to a Unicode string.


Additional info:
Originally, I discovered when trying to "print(prj)" which causes:
Traceback (most recent call last):
  File "/tmp/stack/dnfstackci.py", line 974, in <module>
    _start_commandline()
  File "/tmp/stack/dnfstackci.py", line 784, in _start_commandline
    print(str(prj))
  File "/usr/lib/python2.7/site-packages/copr/client/util.py", line 15, in __str__
    return self.__unicode__().encode('utf8')
AttributeError: 'dict' object has no attribute 'encode'

The problem is probably here: https://git.fedorahosted.org/cgit/copr.git/tree/python/copr/client/responses.py#n65
I guess the return value should be converted to a string.

Comment 1 Radek Holy 2015-09-01 15:32:30 UTC
(I miss a python-copr component there)

Comment 2 Jakub Kadlčík 2015-09-02 12:38:08 UTC
Radek, thank you for the feedback.

Modified in: 59288d7

Comment 4 Miroslav Suchý 2015-10-15 09:45:53 UTC
Version with this fix has been just deployed to production.


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