Skip to content

Crash when using stdio options due to undefined std streams #190

@joaoe

Description

@joaoe

Hi.

I was experimenting with child_process.spawn(stdio=...) (https://nodejs.org/api/child_process.html#child_process_options_stdio) while invoking PythonShell.run() and I got the following crash:

TypeError: Cannot read property 'setEncoding' of null
    at ...\node_modules\python-shell\index.js:63:35

How I called PythonShell

PythonShell.run(scriptPath, {
      pythonPath: ...,
      pythonOptions: ['-u'],
      mode: 'text',
      stdio: ['ignore', process.stdout, process.stderr],
      args: ...
    }

So, I just wanted to stream all stdout/stderr to my terminal, bypassing any parsing by PythonShell or whatever.
The stdio options are passed to child_process and cause the stdout and stderr streams never to be set on the childProcess object. Therefore all placesin python-shell/index.js that access this.stdout/stderr need a null check.

Thank you.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions