"write() argument must be str, not bytes" error when saving file to stdout

Bug #1775482 reported by Victor Engmark
4
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-openstackclient
New
Undecided
Unassigned

Bug Description

`openstack object save my_container_name my_file.sql.gz` works fine - it saves my_file.gz to the current directory. However, for efficiency reasons I want to stream the file into a program and not save it locally. As a starting point I've tried to run `openstack object save --file - my_container_name my_file.sql.gz | gunzip` as described by `openstack object save --help`, but it fails with the error message "write() argument must be str, not bytes".

Stack trace from running with `--debug`:

write() argument must be str, not bytes
Traceback (most recent call last):
  File "/vagrant/.venv/lib/python3.6/site-packages/cliff/app.py", line 400, in run_subcommand
    result = cmd.run(parsed_args)
  File "/vagrant/.venv/lib/python3.6/site-packages/osc_lib/command/command.py", line 41, in run
    return super(Command, self).run(parsed_args)
  File "/vagrant/.venv/lib/python3.6/site-packages/cliff/command.py", line 184, in run
    return_code = self.take_action(parsed_args) or 0
  File "/vagrant/.venv/lib/python3.6/site-packages/openstackclient/object/v1/object.py", line 226, in take_action
    file=parsed_args.file,
  File "/vagrant/.venv/lib/python3.6/site-packages/openstackclient/api/object_store_v1.py", line 382, in object_save
    sys.stdout.write(chunk)
TypeError: write() argument must be str, not bytes
clean_up SaveObject: write() argument must be str, not bytes
Traceback (most recent call last):
  File "/vagrant/.venv/lib/python3.6/site-packages/osc_lib/shell.py", line 134, in run
    ret_val = super(OpenStackShell, self).run(argv)
  File "/vagrant/.venv/lib/python3.6/site-packages/cliff/app.py", line 279, in run
    result = self.run_subcommand(remainder)
  File "/vagrant/.venv/lib/python3.6/site-packages/osc_lib/shell.py", line 169, in run_subcommand
    ret_value = super(OpenStackShell, self).run_subcommand(argv)
  File "/vagrant/.venv/lib/python3.6/site-packages/cliff/app.py", line 400, in run_subcommand
    result = cmd.run(parsed_args)
  File "/vagrant/.venv/lib/python3.6/site-packages/osc_lib/command/command.py", line 41, in run
    return super(Command, self).run(parsed_args)
  File "/vagrant/.venv/lib/python3.6/site-packages/cliff/command.py", line 184, in run
    return_code = self.take_action(parsed_args) or 0
  File "/vagrant/.venv/lib/python3.6/site-packages/openstackclient/object/v1/object.py", line 226, in take_action
    file=parsed_args.file,
  File "/vagrant/.venv/lib/python3.6/site-packages/openstackclient/api/object_store_v1.py", line 382, in object_save
    sys.stdout.write(chunk)
TypeError: write() argument must be str, not bytes

Setup:

$ python --version
Python 3.6.5
$ openstack --version
openstack 3.15.0
$ uname --kernel-name --kernel-release --kernel-version --machine --processor --hardware-platform --operating-system
Linux 4.15.0-22-generic #24-Ubuntu SMP Wed May 16 12:15:17 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04 LTS"

Tim Burke (1-tim-z)
affects: swift → python-openstackclient
Revision history for this message
Tim Burke (1-tim-z) wrote :

Submitted https://review.openstack.org/#/c/573465/ to fix it, FWIW, but that was months ago.

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

This issue was fixed in the openstack/python-openstackclient 3.19.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-openstackclient queens-eol

This issue was fixed in the openstack/python-openstackclient queens-eol release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-openstackclient rocky-eol

This issue was fixed in the openstack/python-openstackclient rocky-eol release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-openstackclient stein-eol

This issue was fixed in the openstack/python-openstackclient stein-eol 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.