Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flask_apscheduler.auth on python 3.9 #165

Closed
conal-mediro opened this issue May 12, 2021 · 2 comments
Closed

flask_apscheduler.auth on python 3.9 #165

conal-mediro opened this issue May 12, 2021 · 2 comments

Comments

@conal-mediro
Copy link

I have some code that imports a module from flask_apscheduler.auth
It used to work on an old set of packages for python 3.7
On a fresh install in python 3.9 I get this error:

    from flask_apscheduler.auth import HTTPAuth
  File "...\AppData\Local\Programs\Python\Python39\lib\site-packages\flask_apscheduler\auth.py", line 20, in <module>
    from werkzeug.http import bytes_to_wsgi, wsgi_to_bytes
ImportError: cannot import name 'bytes_to_wsgi' from 'werkzeug.http' (...\AppData\Local\Programs\Python\Python39\lib\site-packages\werkzeug\http.py)

Is there a way to work around this on newer versions of flask / werkzeug?

@christopherpickering
Copy link
Collaborator

It looks like they (werkzeug) are put the code inside function where is was used and got rid of those functions.

def wsgi_to_bytes(data):
    """coerce wsgi unicode represented bytes to real ones"""
    if isinstance(data, bytes):
        return data
    return data.encode("latin1")  # XXX: utf8 fallback?


def bytes_to_wsgi(data):
    assert isinstance(data, bytes), "data must be bytes"
    if isinstance(data, str):
        return data
    else:
        return data.decode("latin1")

You can probably remove the import from flask_apscheduler\auth.py and add these functions in?

@viniciuschiele
Copy link
Owner

I released a new version 1.12.3, thank you all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants