New submission from Paul Ganssle <p.gans...@gmail.com>:

Just noticed this (tested on Python 3.7 and 3.8):

    mkdir /tmp/demo
    cd /tmp/demo
    cat << EOF > abc.py
    raise Exception("Hi")
    EOF
    PYTHONPATH=: python -c ""


This will crash the interpreter with:

    Fatal Python error: init_sys_streams: can't initialize sys standard 
streams
    Traceback (most recent call last):
      File ".../lib/python3.7/io.py", line 52, in <module>
      File "/tmp/demo/abc.py", line 1, in <module>
    Exception: Hi
    Aborted (core dumped)


It seems that the problem is that the io module imports the abc module, which 
raises an exception, so io fails to load. Evidently the io module is necessary 
to load the interpreter, so the interpreter crashes.

Here's the backtrace for 3.7.2 on Arch Linux:

(gdb) bt
#0  0x00007f234b3f0d7f in raise () from /usr/lib/libc.so.6
#1  0x00007f234b3db672 in abort () from /usr/lib/libc.so.6
#2  0x00007f234b7db490 in fatal_error (prefix=prefix@entry=0x7f234b9d5fe0 
<__func__.16645> "init_sys_streams", 
    msg=msg@entry=0x7f234ba01f60 "can't initialize sys standard streams", 
status=status@entry=-1)
    at Python/pylifecycle.c:2179
#3  0x00007f234b8460cb in _Py_FatalInitError (err=...) at 
Python/pylifecycle.c:2198
#4  0x00007f234b8495a9 in pymain_init (pymain=0x7fff971cca70) at 
Modules/main.c:3019
#5  0x0000555dfa560050 in ?? ()
#6  0x00007fff971ccbc0 in ?? ()
#7  0x0000000000000000 in ?? ()


I'm not sure if anything can or should be done about this. It's very fair for 
the interpreter to fail to start, though I would guess that it should do that 
without dumping a core.

----------
messages: 335244
nosy: p-ganssle
priority: normal
severity: normal
status: open
title: Interpreter crashes with "can't initialize init_sys_streams" when abc 
fails to import
type: crash
versions: Python 2.7, Python 3.7, Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35969>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to