Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#27657 closed Bug (needsinfo)

Getting crash when using the runserver command on Windows 10 in PowerShell following update to Python 3.6

Reported by: horatius83 Owned by: nobody
Component: Utilities Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Any time I run the command python .\ runserver Python crashes. This behavior only seems to occur in PowerShell (even in Admin mode) but it runs fine in the regular command line.

PS C:\Users\Tyler Durden\Documents\GitHub\debt_calculator> python -u -m trace -t .\ runserver >> ./python_error.log
Traceback (most recent call last):
  File "C:\Users\Tyler Durden\AppData\Local\Programs\Python\Python36-32\lib\", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\Tyler Durden\AppData\Local\Programs\Python\Python36-32\lib\", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Tyler Durden\AppData\Local\Programs\Python\Python36-32\lib\", line 742, in <module>
  File "C:\Users\Tyler Durden\AppData\Local\Programs\Python\Python36-32\lib\", line 730, in main
    t.runctx(code, globs, globs)
  File "C:\Users\Tyler Durden\AppData\Local\Programs\Python\Python36-32\lib\", line 469, in runctx
    exec(cmd, globals, locals)
  File ".\", line 22, in <module>
  File "C:\Users\Tyler Durden\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\", line 367, in execute_from_command_line
  File "C:\Users\Tyler Durden\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\", line 330, in execute
  File "C:\Users\Tyler Durden\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\Tyler Durden\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\", line 58, in execute
    super(Command, self).execute(*args, **options)
  File "C:\Users\Tyler Durden\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\", line 345, in execute
    output = self.handle(*args, **options)
  File "C:\Users\Tyler Durden\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\", line 97, in handle**options)
  File "C:\Users\Tyler Durden\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\", line 106, in run
    autoreload.main(self.inner_run, None, options)
  File "C:\Users\Tyler Durden\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\", line 333, in main
    reloader(wrapped_main_func, args, kwargs)
  File "C:\Users\Tyler Durden\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\", line 304, in python_reloader
    exit_code = restart_with_reloader()
  File "C:\Users\Tyler Durden\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\", line 285, in restart_with_reloader
    args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions] + sys.argv
TypeError: can only concatenate list (not "tuple") to list

Change History (4)

comment:1 by Tim Graham, 8 years ago

So sys.argv is the tuple, I guess? It doesn't seem that Django is necessarily at fault. Could you investigate the issue a bit more to determine what's causing it to be a tuple rather than a list?

comment:2 by horatius83, 8 years ago

I have established that PowerShell is not passing in the arguments as tuples by running just args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions] + sys.argv in a small script.

I have no experience in debugging large Python programs. My naive approach would be to run up the stack trace, setting breakpoints and trying to establish if sys.argv is getting mutated somewhere. Ideally I'd like to set a breakpoint in a setter of some kind, if that's even possible. Is there a more elegant approach to this? (Laziness is a virtue, at least that's what the Haskellers tell me)

comment:3 by Tim Graham, 8 years ago

Resolution: needsinfo
Status: newclosed

I'm not sure, this probably isn't the best channel to get help since Windows and changes in Python aren't our expertise. By the way, I just tried this and I can't reproduce it (printing sys.argv right above the place that crashed for you shows ['.\\', 'runserver'] (tested with Windows 10, Python 3.6, Windows PowerShell). Feel free to reopen the ticket if you investigation concludes that Django must adapt in some way.

comment:4 by Walter Doekes, 7 years ago

Found this particular problem, I think:

$ python3.5 -m trace --trace <(echo 'import sys; print(repr(sys.argv))')
 --- modulename: 63, funcname: <module>
63(1): ['/dev/fd/63']
 --- modulename: trace, funcname: _unsettrace         sys.settrace(None)


$ python3.6 -m trace --trace <(echo 'import sys; print(repr(sys.argv))')
 --- modulename: 63, funcname: <module>
63(1): ('/dev/fd/63',)
 --- modulename: trace, funcname: _unsettrace         sys.settrace(None)

It's the trace module in py3.6 that turns the argv into a tuple.

Not a Django bug.

$ python3.6 -V
Python 3.6.1
Note: See TracTickets for help on using tickets.
Back to Top