Skip to content

1.0.0b1 crashes with unicode encode error when displaying help #1427

@ucamhal

Description

@ucamhal
  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Ubuntu 18.04
  • Poetry version: 1.0.0b1
  • Link of a Gist with the contents of your pyproject.toml file: Issue is not related to a pyproject.toml file

Issue

The current 1.0.0 beta release crashes when running poetry with --help or without arguments:

$ poetry
Poetry version 1.0.0b1

USAGE

[UnicodeEncodeError]
'ascii' codec can't encode character '\xa0' in position 30: ordinal not in range(128)

I've only seen this in a Docker container, it works correctly on my desktop.

This Dockerfile reproduces it:

FROM ubuntu:bionic-20190912.1

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        python3.6 python3-pip python3-venv && \
    pip3 install setuptools wheel && \
    pip3 install poetry==1.0.0b1

Steps:

  1. Create ./Dockerfile in a directory containing the above
  2. From the dir, run $ sudo docker build -t poetry-unicode-issue .
  3. Execute poetry in the image as follows:
$ sudo docker run poetry-unicode-issue poetry --help -vvv
Poetry version 1.0.0b1

USAGE

[UnicodeEncodeError]
'ascii' codec can't encode character '\xa0' in position 22: ordinal not in range(128)

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/clikit/console_application.py", line 132, in run
    status_code = command.handle(parsed_args, io)
  File "/usr/local/lib/python3.6/dist-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/usr/local/lib/python3.6/dist-packages/clikit/api/command/command.py", line 173, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/usr/local/lib/python3.6/dist-packages/clikit/handler/help/help_text_handler.py", line 29, in handle
    usage.render(io)
  File "/usr/local/lib/python3.6/dist-packages/clikit/ui/help/abstract_help.py", line 31, in render
    layout.render(io, indentation)
  File "/usr/local/lib/python3.6/dist-packages/clikit/ui/layout/block_layout.py", line 42, in render
    element.render(io, self._indentations[i] + indentation)
  File "/usr/local/lib/python3.6/dist-packages/clikit/ui/components/labeled_paragraph.py", line 70, in render
    + '
'"
  File "/usr/local/lib/python3.6/dist-packages/cleo/io/io_mixin.py", line 55, in write
    super(IOMixin, self).write(string, flags)
  File "/usr/local/lib/python3.6/dist-packages/clikit/api/io/io.py", line 58, in write
    self._output.write(string, flags=flags)
  File "/usr/local/lib/python3.6/dist-packages/clikit/api/io/output.py", line 61, in write
    self._stream.write(to_str(formatted))
  File "/usr/local/lib/python3.6/dist-packages/clikit/io/output_stream/stream_output_stream.py", line 24, in write
    self._stream.write(string)

The default encoding seems to be detected correctly:

$ python3 -c 'import sys; print(sys.getdefaultencoding())'
utf-8

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions