Skip to content

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

@karthiknadig

Description

@karthiknadig

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions