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

If arguments are re-written before flask is loaded it sees the original arguments on windows python 2.7 #3297

Closed
karthiknadig opened this issue Jul 10, 2019 · 2 comments · Fixed by #3299
Milestone

Comments

@karthiknadig
Copy link

Previously flask (v1.0.3) was passing sys.argv to cli.main:

https://github.com/pallets/flask/blob/1.0.3/flask/cli.py#L889-L906

Now flask (v1.1.1) is not passing argv, to cli.main.

https://github.com/pallets/flask/blob/1.1.1/src/flask/cli.py#L965-L966

This causes it to always get args via get_os_args via click.

https://github.com/pallets/click/blob/7.0/click/core.py#L700-L704

Which is this issue in click pallets/click#536

This basically breaks debugging (on windows with python 2.7), where the debugger re-writes sys.argv before click or flask is loaded. So, attempting to debug flask using ptvsd or pydevd results in the error message below.

Expected

>python -m ptvsd --host localhost --port 5692 -m flask run --no-debugger --no-reload --with-threads --port 5014
 * Serving Flask app "app"
 * Environment: development
 * Debug mode: on
 * Running on http://127.0.0.1:5014/ (Press CTRL+C to quit)

Actual

>python -m ptvsd --host localhost --port 5692 -m flask run --no-debugger --no-reload --with-threads --port 5014
Usage: python -m flask [OPTIONS] COMMAND [ARGS]...
Try "python -m flask --help" for help.

Error: no such option: --host

Environment

  • Python version: 2.7
  • Flask version: 1.1.1
  • Werkzeug version: N/A
  • Platform: Windows
@davidism davidism transferred this issue from pallets/flask Jul 10, 2019
@davidism davidism transferred this issue from pallets/werkzeug Jul 10, 2019
@davidism davidism added this to the 1.1.2 milestone Jul 10, 2019
@davidism
Copy link
Member

We can add args=sys.argv[1:] back in with a note about the Click issue so we can remove it when that's addressed.

@davidism
Copy link
Member

davidism commented Apr 3, 2020

Finally released 1.1.2 with this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants