Skip to content

Don't use assert to determine python version #218

@mpyatishev

Description

@mpyatishev

I have faced with a problem with asserts: we are using PYTHONOPTIMIZE=2 on production environment so all asserts are cleaned from the execution (https://docs.python.org/3/using/cmdline.html#cmdoption-O). As the result, we getting the exception:

/opt/venv/lib/python3.9/site-packages/pdfkit/source.py in to_s(self)
     52         # and cant later encode properly, this is a workaround for this.
     53         # See issue #42
---> 54         if isinstance(self.source, unicode):
     55             return self.source
     56         else:

NameError: name 'unicode' is not defined

I would suggest to use something like sys.version to determine python versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions