Browse Source

Fix 0 port value being overriden by default

By explicitly comparing port value with None,
instead of using its bool() value.
pull/2928/head
vorelq 6 years ago
parent
commit
cefba5be40
  1. 3
      CHANGES.rst
  2. 2
      flask/app.py
  3. 1
      tests/test_basic.py

3
CHANGES.rst

@ -28,9 +28,12 @@ Released on May 2nd 2018
a blueprint prefix and route. (`#2748`_)
- Fix error with ``flask routes`` command when there are no routes.
(`#2751`_)
- Fix issue with port set to 0 being overriden by the default value.
(`#2928`_)
.. _#2748: https://github.com/pallets/flask/pull/2748
.. _#2751: https://github.com/pallets/flask/issues/2751
.. _#2928: https://github.com/pallets/flask/pull/2928
Version 1.0.1

2
flask/app.py

@ -929,7 +929,7 @@ class Flask(_PackageBoundObject):
sn_host, _, sn_port = server_name.partition(':')
host = host or sn_host or _host
port = int(port or sn_port or _port)
port = int(next((p for p in (port, sn_port) if p is not None), _port))
options.setdefault('use_reloader', self.debug)
options.setdefault('use_debugger', self.debug)

1
tests/test_basic.py

@ -1921,6 +1921,7 @@ def test_run_server_port(monkeypatch, app):
('localhost', None, 'localhost', 8080),
(None, 80, 'pocoo.org', 80),
('localhost', 80, 'localhost', 80),
('localhost', 0, 'localhost', 0),
))
def test_run_from_config(monkeypatch, host, port, expect_host, expect_port, app):
def run_simple_mock(hostname, port, *args, **kwargs):

Loading…
Cancel
Save