Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

basestring erroneously ignores unicode in Python2.7 #432

Open
@imankulov

Description

@imankulov

Documenting it for those poor souls who are still stuck with hyper under Python2.7.

Passing a Unicode object (not an "str") in Python2.7 to a hyper.tls.init_context as a cert argument raises an exception IOError: [Errno 21] Is a directory.

This happens because "basestring" is erroneously set to (str, str) here:

hyper/hyper/tls.py

Lines 123 to 127 in 18b629b

if cert is not None:
try:
basestring
except NameError:
basestring = (str, bytes)

Note that because of the assignment to the basestring on line 127, an attempt to dereference the object before will always raise NameError, because the interpreter will consider basestring as a local variable. The behavior is explained in the Python FAQ, and the solution is to declare basestring as global explicitly.

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