Skip to content

Raise TypeError if port is not an integer#1088

Merged
untitaker merged 3 commits into
pallets:masterfrom
aaossa:0.12-maintenance
Mar 27, 2017
Merged

Raise TypeError if port is not an integer#1088
untitaker merged 3 commits into
pallets:masterfrom
aaossa:0.12-maintenance

Conversation

@aaossa

@aaossa aaossa commented Mar 25, 2017

Copy link
Copy Markdown
Contributor

As explained in pallets/flask#2220 port should be an integer and in other cases a TypeError exception should be raised. This PR includes a type check to raise said exception and a test to check if the exception is raised (when use_reloader is True and when its False).

Closes pallets/flask#2220

Comment thread tests/test_serving.py Outdated


def test_port_must_be_integer(dev_server):
with pytest.raises(TypeError) as port_type_exception:

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread tests/test_serving.py Outdated

def test_port_must_be_integer(dev_server):
with pytest.raises(TypeError) as port_type_exception_with_reloader:
def app(environ, start_response):

This comment was marked as off-topic.

This comment was marked as off-topic.

@aaossa

aaossa commented Mar 25, 2017

Copy link
Copy Markdown
Contributor Author

Thanks for your review @JordanP and @untitaker . The new test is ready and works 👌

Comment thread tests/test_serving.py Outdated
start_response('200 OK', [('Content-Type', 'text/html')])
return [b'hello']

with pytest.raises(TypeError) as port_type_exception_with_reloader:

This comment was marked as off-topic.

@untitaker untitaker changed the base branch from 0.12-maintenance to master March 27, 2017 20:03
@untitaker

Copy link
Copy Markdown
Contributor

Please rebase and add a changelog to version 0.13.

0.12-maintenance is really just for bugfixes, but this actually changes behavior.

aaossa added 3 commits March 27, 2017 17:20
Ports should be integers, so a type check is explicitly added to raise
an exception when this is ignored. This inappropiate behaviour was
detected when using `debug=True` in a Flask application, because a
string is accepted and works when it should fail.

Closes pallets/flask#2220

Signed-off-by: Antonio Ossa <aaossa@uc.cl>
This testcase tries to use a string as port parameter, which should not
be allowed by `run_simple`. The test uses `run_simple` directly
because the tests configuration raises the error in a different process
without giving a chance to catch the `TypeError` exception.

See pallets/flask#2220

Signed-off-by: Antonio Ossa <aaossa@uc.cl>
Signed-off-by: Antonio Ossa <aaossa@uc.cl>
@aaossa

aaossa commented Mar 27, 2017

Copy link
Copy Markdown
Contributor Author

I think I've done it 👌 Do you have more issues or PRs to read/work on? 😁

@untitaker untitaker merged commit d2b373a into pallets:master Mar 27, 2017
@untitaker

Copy link
Copy Markdown
Contributor

Thanks!

@untitaker

Copy link
Copy Markdown
Contributor

Regarding your question, I think everything labelled with "beginner ready" would work

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

app.run(port='5000', debug=True) error

4 participants