Bug 1258915 - unicode(CoprResponse(...)) causes TypeError: coercing to Unicode: need string or buffer, dict found
unicode(CoprResponse(...)) causes TypeError: coercing to Unicode: need string...
Status: CLOSED CURRENTRELEASE
Product: Copr
Classification: Community
Component: frontend (Show other bugs)
unspecified
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Jakub Kadlčík
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-09-01 10:06 EDT by Radek Holy
Modified: 2015-10-15 05:45 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-10-15 05:45:53 EDT
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)

  None (edit)
Description Radek Holy 2015-09-01 10:06:18 EDT
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 11:32:30 EDT
(I miss a python-copr component there)
Comment 2 Jakub Kadlčík 2015-09-02 08:38:08 EDT
Radek, thank you for the feedback.

Modified in: 59288d7
Comment 4 Miroslav Suchý 2015-10-15 05:45:53 EDT
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.