Merge branch '1.1.x'

This commit is contained in:
David Lord 2019-07-08 11:04:16 -07:00
commit 901661c1a4
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
6 changed files with 57 additions and 4 deletions

View file

@ -1,5 +1,15 @@
.. currentmodule:: flask
Version 1.1.1
-------------
Released 2019-07-08
- The ``flask.json_available`` flag was added back for compatibility
with some extensions. It will raise a deprecation warning when used,
and will be removed in version 2.0.0. :issue:`3288`
Version 1.1.0
-------------

View file

@ -66,8 +66,8 @@ donate today`_.
Links
-----
* Website: https://www.palletsprojects.com/p/flask/
* Documentation: http://flask.pocoo.org/docs/
* Website: https://palletsprojects.com/p/flask/
* Documentation: https://flask.palletsprojects.com/
* Releases: https://pypi.org/project/Flask/
* Code: https://github.com/pallets/flask
* Issue tracker: https://github.com/pallets/flask/issues

View file

@ -15,7 +15,7 @@ setup(
version=version,
url="https://palletsprojects.com/p/flask/",
project_urls={
"Documentation": "http://flask.palletsprojects.com/",
"Documentation": "https://flask.palletsprojects.com/",
"Code": "https://github.com/pallets/flask",
"Issue tracker": "https://github.com/pallets/flask/issues",
},

View file

@ -17,6 +17,7 @@ from werkzeug.exceptions import abort
from werkzeug.utils import redirect
from . import json
from ._compat import json_available
from .app import Flask
from .app import Request
from .app import Response
@ -56,4 +57,4 @@ from .signals import template_rendered
from .templating import render_template
from .templating import render_template_string
__version__ = "1.1.0"
__version__ = "1.1.1"

View file

@ -113,3 +113,33 @@ except ImportError:
# https://www.python.org/dev/peps/pep-0519/#backwards-compatibility
def fspath(path):
return path.__fspath__() if hasattr(path, "__fspath__") else path
class _DeprecatedBool(object):
def __init__(self, name, version, value):
self.message = "'{}' is deprecated and will be removed in version {}.".format(
name, version
)
self.value = value
def _warn(self):
import warnings
warnings.warn(self.message, DeprecationWarning, stacklevel=2)
def __eq__(self, other):
self._warn()
return other == self.value
def __ne__(self, other):
self._warn()
return other != self.value
def __bool__(self):
self._warn()
return self.value
__nonzero__ = __bool__
json_available = _DeprecatedBool("flask.json_available", "2.0.0", True)

View file

@ -0,0 +1,12 @@
import pytest
from flask import json_available
def test_json_available():
with pytest.deprecated_call() as rec:
assert json_available
assert json_available == True # noqa E712
assert json_available != False # noqa E712
assert len(rec.list) == 3