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 · 1 comment

Comments

@karthiknadig
Copy link

commented Jul 10, 2019

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 bug cli labels Jul 10, 2019

@davidism davidism added this to the 1.1.2 milestone Jul 10, 2019

@davidism

This comment has been minimized.

Copy link
Member

commented Jul 10, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.