Skip to content

Commit

Permalink
fix: compat for flask-oauthlib
Browse files Browse the repository at this point in the history
  • Loading branch information
utnapischtim committed Nov 15, 2024
1 parent ae61b1e commit a3dcc29
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions invenio_oauthclient/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
#
# This file is part of Invenio.
# Copyright (C) 2015-2018 CERN.
# Copyright (C) 2024 Graz University of Technology.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Compat."""

import urllib

import werkzeug

try:
Expand All @@ -23,6 +26,14 @@ def monkey_patch_werkzeug():
except ImportError:
werkzeug.cached_property = werkzeug.utils.cached_property
werkzeug.parse_options_header = werkzeug.http.parse_options_header
werkzeug.url_quote = werkzeug.urls.url_quote
werkzeug.url_decode = werkzeug.urls.url_decode
werkzeug.url_encode = werkzeug.urls.url_encode
werkzeug.url_quote = urllib.parse.quote
werkzeug.url_decode = urllib.parse.parse_qs
werkzeug.url_encode = urllib.parse.urlencode

try:
# werkzeug >= 3.0 has removed following functions from werkzeug.urls
from werkzeug.urls import url_quote
except ImportError:
werkzeug.urls.url_quote = urllib.parse.quote
werkzeug.urls.url_decode = urllib.parse.parse_qs
werkzeug.urls.url_encode = urllib.parse.urlencode

0 comments on commit a3dcc29

Please sign in to comment.