prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Debugging of modules using -m is broken
  Used to be able to debug Flask & other code using the `-m` flag.
  
  
  </issue>
  <code>
  [start of ptvsd/debugger.py]
  1 # Copyright (c) Microsoft Corporation. All rights reserved.
  2 # Licensed under the MIT License. See LICENSE in the project root
  3 # for license information.
  4 
  5 import sys
  6 
  7 # import the wrapper first, so that it gets a chance
  8 # to detour pydevd socket functionality.
  9 import ptvsd.wrapper
  10 
  11 
  12 __author__ = "Microsoft Corporation <ptvshelp@microsoft.com>"
  13 __version__ = "4.0.0a4"
  14 
  15 DONT_DEBUG = []
  16 
  17 
  18 def debug(filename, port_num, debug_id, debug_options, run_as):
  19     # TODO: docstring
  20     address = (None, port_num)
  21     if run_as == 'module':
  22         _run_module(address, filename)
  23     else:
  24         _run_file(address, filename)
  25 
  26 
  27 def _run_module(address, modname):
  28     filename = modname + ':'
  29     argv = _run_argv(address, filename)
  30     argv.append('--module')
  31     _run(argv)
  32 
  33 
  34 def _run_file(address, filename):
  35     argv = _run_argv(address, filename)
  36     _run(argv)
  37 
  38 
  39 def _run_argv(address, filename):
  40     host, port = address
  41     if host is None:
  42         host = '127.0.0.1'
  43     return [
  44         '--port', str(port),
  45         '--client', host,
  46         '--file', filename,
  47     ]
  48 
  49 
  50 def _run(argv):
  51     import pydevd
  52     sys.argv[1:0] = argv
  53     try:
  54         pydevd.main()
  55     except SystemExit as ex:
  56         ptvsd.wrapper.ptvsd_sys_exit_code = int(ex.code)
  57         raise
  58
  [end of ptvsd/debugger.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/ptvsd/debugger.py b/ptvsd/debugger.py
  --- a/ptvsd/debugger.py
  +++ b/ptvsd/debugger.py
  @@ -27,7 +27,7 @@
   def _run_module(address, modname):
       filename = modname + ':'
       argv = _run_argv(address, filename)
  -    argv.append('--module')
  +    argv.insert(argv.index('--file'), '--module')
       _run(argv)
  
verification_info: {"golden_diff": "diff --git a/ptvsd/debugger.py b/ptvsd/debugger.py\n--- a/ptvsd/debugger.py\n+++ b/ptvsd/debugger.py\n@@ -27,7 +27,7 @@\n def _run_module(address, modname):\n     filename = modname + ':'\n     argv = _run_argv(address, filename)\n-    argv.append('--module')\n+    argv.insert(argv.index('--file'), '--module')\n     _run(argv)\n", "issue": "Debugging of modules using -m is broken\nUsed to be able to debug Flask & other code using the `-m` flag.\r\n\n", "before_files": [{"content": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License. See LICENSE in the project root\n# for license information.\n\nimport sys\n\n# import the wrapper first, so that it gets a chance\n# to detour pydevd socket functionality.\nimport ptvsd.wrapper\n\n\n__author__ = \"Microsoft Corporation <ptvshelp@microsoft.com>\"\n__version__ = \"4.0.0a4\"\n\nDONT_DEBUG = []\n\n\ndef debug(filename, port_num, debug_id, debug_options, run_as):\n    # TODO: docstring\n    address = (None, port_num)\n    if run_as == 'module':\n        _run_module(address, filename)\n    else:\n        _run_file(address, filename)\n\n\ndef _run_module(address, modname):\n    filename = modname + ':'\n    argv = _run_argv(address, filename)\n    argv.append('--module')\n    _run(argv)\n\n\ndef _run_file(address, filename):\n    argv = _run_argv(address, filename)\n    _run(argv)\n\n\ndef _run_argv(address, filename):\n    host, port = address\n    if host is None:\n        host = '127.0.0.1'\n    return [\n        '--port', str(port),\n        '--client', host,\n        '--file', filename,\n    ]\n\n\ndef _run(argv):\n    import pydevd\n    sys.argv[1:0] = argv\n    try:\n        pydevd.main()\n    except SystemExit as ex:\n        ptvsd.wrapper.ptvsd_sys_exit_code = int(ex.code)\n        raise\n", "path": "ptvsd/debugger.py"}]}