nova console-log throws an error: ERROR (TypeError): write() argument must be str, not bytes

Bug #1823287 reported by Stephen Finucane
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-novaclient
Fix Released
Medium
Stephen Finucane
Queens
In Progress
Medium
Stephen Finucane
Rocky
Fix Committed
Medium
Stephen Finucane

Bug Description

This was originally reported in Bugzilla [1].

nova console-log throws an error: ERROR (TypeError): write() argument must be str, not bytes

  $ nova console-log after_deploy
  ERROR (TypeError): write() argument must be str, not bytes

Looks like this was introduced in the fix [2] for bug #1746534 [3]. Easily reproduced outside of 'python-novaclient' too.

  $ python3
  >>> import codecs
  >>> import sys
  >>> codecs.getwriter('utf-8')(sys.stdout).write(u'test')
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/lib64/python3.7/codecs.py", line 378, in write
      self.stream.write(data)
  TypeError: write() argument must be str, not bytes

Environment:
- python3-novaclient-13.0.0-0.20190312082821.62bf880.el8ost.noarch
- puppet-nova-14.4.0-0.20190323002255.aa4a911.el8ost.noarch

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1693429
[2] https://review.openstack.org/#/c/541610/
[3] https://bugs.launchpad.net/python-novaclient/+bug/1746534

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-novaclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/650235

Changed in python-novaclient:
assignee: nobody → Stephen Finucane (stephenfinucane)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-novaclient (stable/stein)

Fix proposed to branch: stable/stein
Review: https://review.openstack.org/650363

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-novaclient (stable/rocky)

Fix proposed to branch: stable/rocky
Review: https://review.openstack.org/650364

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-novaclient (master)

Reviewed: https://review.openstack.org/650235
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=a9b1125f7ba209887cac36b3c0900cffe2516fa8
Submitter: Zuul
Branch: master

commit a9b1125f7ba209887cac36b3c0900cffe2516fa8
Author: Stephen Finucane <email address hidden>
Date: Fri Apr 5 07:49:38 2019 +0100

    Revert "Fix crashing console-log"

    This reverts commit d272d6f3df2610a62f81e2ca26798ea8a6674b06. This
    worked around a misconfigured environment by forcing stdout to use
    UTF-8. This is kind of a hack and it only works in Python 2, breaking
    Python 3 [1].

    The correct solution to this issue and all Python 2 unicode print issues
    is to correctly configuring LC_ALL to use a UTF-8 locale.

    [1] https://stackoverflow.com/q/4374455

    Change-Id: Iaeec1e74262a35f3de3c81f7013835a6aa6f9029
    Closes-Bug: #1823287

Changed in python-novaclient:
status: In Progress → Fix Released
Matt Riedemann (mriedem)
Changed in python-novaclient:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to python-novaclient (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/651827

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to python-novaclient (master)

Reviewed: https://review.openstack.org/651827
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=e8f7aaf9091330bbb046f2bd42dc9c92f1dcebaa
Submitter: Zuul
Branch: master

commit e8f7aaf9091330bbb046f2bd42dc9c92f1dcebaa
Author: Matt Riedemann <email address hidden>
Date: Thu Apr 11 12:03:30 2019 -0400

    Add test for console-log and docs for bug 1746534

    We had no unit test coverage for the console-log command
    so this adds a simple test. It unfortunately does not
    recreate the original UnicodeEncodeError bug though, but
    it gives us some test coverage anyway.

    This change also adds docs on how to resolve bug 1746534
    by configuring the environment for UTF-8 as noted in
    the revert change Iaeec1e74262a35f3de3c81f7013835a6aa6f9029.

    The documentation added here is shamelessly copied from
    Click [1] which was found via the PEP 538 docs [2].

    [1] https://click.palletsprojects.com/en/5.x/python3/#python-3-surrogate-handling
    [2] https://www.python.org/dev/peps/pep-0538/

    Change-Id: Ic7059260dfc031ea1b08d2b8a7cec684bbe7dfa5
    Related-Bug: #1823287
    Related-Bug: #1746534

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to python-novaclient (stable/stein)

Related fix proposed to branch: stable/stein
Review: https://review.openstack.org/651925

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-novaclient (stable/stein)

Reviewed: https://review.openstack.org/650363
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=2ca1814a2b4d1e887974a71951b7e744273a43b4
Submitter: Zuul
Branch: stable/stein

commit 2ca1814a2b4d1e887974a71951b7e744273a43b4
Author: Stephen Finucane <email address hidden>
Date: Fri Apr 5 07:49:38 2019 +0100

    Revert "Fix crashing console-log"

    This reverts commit d272d6f3df2610a62f81e2ca26798ea8a6674b06. This
    worked around a misconfigured environment by forcing stdout to use
    UTF-8. This is kind of a hack and it only works in Python 2, breaking
    Python 3 [1].

    The correct solution to this issue and all Python 2 unicode print issues
    is to correctly configuring LC_ALL to use a UTF-8 locale.

    [1] https://stackoverflow.com/q/4374455

    Change-Id: Iaeec1e74262a35f3de3c81f7013835a6aa6f9029
    Closes-Bug: #1823287
    (cherry picked from commit a9b1125f7ba209887cac36b3c0900cffe2516fa8)

tags: added: in-stable-stein
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to python-novaclient (stable/rocky)

Related fix proposed to branch: stable/rocky
Review: https://review.openstack.org/652033

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to python-novaclient (stable/stein)

Reviewed: https://review.openstack.org/651925
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=60bf9a236dfbaa98e7d93b4baf0997e645b02bb0
Submitter: Zuul
Branch: stable/stein

commit 60bf9a236dfbaa98e7d93b4baf0997e645b02bb0
Author: Matt Riedemann <email address hidden>
Date: Thu Apr 11 12:03:30 2019 -0400

    Add test for console-log and docs for bug 1746534

    We had no unit test coverage for the console-log command
    so this adds a simple test. It unfortunately does not
    recreate the original UnicodeEncodeError bug though, but
    it gives us some test coverage anyway.

    This change also adds docs on how to resolve bug 1746534
    by configuring the environment for UTF-8 as noted in
    the revert change Iaeec1e74262a35f3de3c81f7013835a6aa6f9029.

    The documentation added here is shamelessly copied from
    Click [1] which was found via the PEP 538 docs [2].

    [1] https://click.palletsprojects.com/en/5.x/python3/#python-3-surrogate-handling
    [2] https://www.python.org/dev/peps/pep-0538/

    Change-Id: Ic7059260dfc031ea1b08d2b8a7cec684bbe7dfa5
    Related-Bug: #1823287
    Related-Bug: #1746534
    (cherry picked from commit e8f7aaf9091330bbb046f2bd42dc9c92f1dcebaa)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-novaclient (stable/rocky)

Reviewed: https://review.openstack.org/650364
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=488dd9940a88c33a5061bde5636e6338602a3a57
Submitter: Zuul
Branch: stable/rocky

commit 488dd9940a88c33a5061bde5636e6338602a3a57
Author: Stephen Finucane <email address hidden>
Date: Fri Apr 5 07:49:38 2019 +0100

    Revert "Fix crashing console-log"

    This reverts commit d272d6f3df2610a62f81e2ca26798ea8a6674b06. This
    worked around a misconfigured environment by forcing stdout to use
    UTF-8. This is kind of a hack and it only works in Python 2, breaking
    Python 3 [1].

    The correct solution to this issue and all Python 2 unicode print issues
    is to correctly configuring LC_ALL to use a UTF-8 locale.

    [1] https://stackoverflow.com/q/4374455

    Change-Id: Iaeec1e74262a35f3de3c81f7013835a6aa6f9029
    Closes-Bug: #1823287
    (cherry picked from commit a9b1125f7ba209887cac36b3c0900cffe2516fa8)
    (cherry picked from commit 2ca1814a2b4d1e887974a71951b7e744273a43b4)

tags: added: in-stable-rocky
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to python-novaclient (stable/rocky)

Reviewed: https://review.openstack.org/652033
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=efdbac35b0c00ca39b986b7fb58515e2b5059384
Submitter: Zuul
Branch: stable/rocky

commit efdbac35b0c00ca39b986b7fb58515e2b5059384
Author: Matt Riedemann <email address hidden>
Date: Thu Apr 11 12:03:30 2019 -0400

    Add test for console-log and docs for bug 1746534

    We had no unit test coverage for the console-log command
    so this adds a simple test. It unfortunately does not
    recreate the original UnicodeEncodeError bug though, but
    it gives us some test coverage anyway.

    This change also adds docs on how to resolve bug 1746534
    by configuring the environment for UTF-8 as noted in
    the revert change Iaeec1e74262a35f3de3c81f7013835a6aa6f9029.

    The documentation added here is shamelessly copied from
    Click [1] which was found via the PEP 538 docs [2].

    [1] https://click.palletsprojects.com/en/5.x/python3/#python-3-surrogate-handling
    [2] https://www.python.org/dev/peps/pep-0538/

    Change-Id: Ic7059260dfc031ea1b08d2b8a7cec684bbe7dfa5
    Related-Bug: #1823287
    Related-Bug: #1746534
    (cherry picked from commit e8f7aaf9091330bbb046f2bd42dc9c92f1dcebaa)
    (cherry picked from commit 60bf9a236dfbaa98e7d93b4baf0997e645b02bb0)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-novaclient 14.0.0

This issue was fixed in the openstack/python-novaclient 14.0.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-novaclient 13.0.1

This issue was fixed in the openstack/python-novaclient 13.0.1 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-novaclient 11.0.1

This issue was fixed in the openstack/python-novaclient 11.0.1 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.