w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Python: help(numpy) causes segfault on exit

From the Python side, I managed to track it down to this function in pydoc.py...

def pipepager(text, cmd):
    """Page through text by feeding it to another program."""
    pipe = os.popen(cmd, 'w')
    try:
        pipe.write(text)
        pipe.close()
    except IOError:
        pass # Ignore broken pipes caused by quitting the pager program.

...specifically the line pipe.write(text).

The problem goes away if you change that function to...

def pipepager(text, cmd):
    """Page through text by feeding it to another program."""
    import subprocess
    pipe = subprocess.Popen(cmd, stdin=subprocess.PIPE, shell=True).stdin
    try:
        pipe.write(text)
        pipe.close()
    except IOError:
        pass # Ignore broken pipes caused by quitting the pager program.

...which might be a reasonable workaround, although I'm still investigating why that fixes the problem - there's very little difference between the strace(1) output for the two cases.


Update

Leeward has filed a bug report for this.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.