Skip to content

encoding not passed to stream  #35

Closed
@pabloh007

Description

@pabloh007

on line 90 of book.py
file_stream = _convert_content_to_stream(file_content, self._file_type)

does not pass the encoding to use so when decode is used later it throws an decoding exception

it should maybe use the **keywords and pass it to the function like so
file_stream = _convert_content_to_stream(file_content, self._file_type, **keywords)

to maybe something like the below. currently the file_content.decode is set to static 'utf-8'

def _convert_content_to_stream(file_content, file_type, **keywords):
    io = manager.get_io(file_type)
    encoding = keywords.get('encoding', 'utf-8')
    if PY2:
        io.write(file_content)
    else:
        if (isinstance(io, StringIO) and isinstance(file_content, bytes)):
            content = file_content.decode(encoding)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions