Skip to content

PEP 461 format of bytes string returns basestring (python 3.5.1+) #2153

@djvernon68

Description

@djvernon68

Issue:
PEP 461 style bytes formatting (b'%b' % variable) returns basestring. So the following code results in a cythonize error:

cpdef bytes cy_foo():
    cdef:
        bytes bytes_1, bytes_2

    bytes_1 = b'bytes 1'
    bytes_2 = b'bytes 2'

    return b'%(bytes_1)b %(bytes_2)b' % {
                    b'bytes_1': bytes_1,
                    b'bytes_2': bytes_2} 

Result:
Cannot convert 'basestring' object to bytes implicitly. This is not portable.

This same basic code in python 3.5.1+ returns a bytes object.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions