pexpect / ptyprocess

Run a subprocess in a pseudo terminal
https://ptyprocess.readthedocs.io/en/latest/
Other
222 stars 71 forks source link

Add **kwargs to PtyProcess.spawn #63

Open dong-zeyu opened 3 years ago

dong-zeyu commented 3 years ago

The PtyProcessUnicode class accept keywords argument like encoding and codec_errors. However, it seems not easy to set these argument just using PtyProcess.spawn.

I think we could add a **kwargs to spawn and create the class instance using cls(pid, fd, **kwargs). It will be neat and improve extensibility.

takluyver commented 1 year ago

This seems reasonable to me. Sorry to have left it so long without looking at it. If you're still interested, could you add a test of using the arguments for unicode decoding?

dong-zeyu commented 1 year ago

Thanks for your reply. A test was added. It will try to print some non-utf8 char and check whether the error handling argument is taking effect.

takluyver commented 1 year ago

Hmm, it seems like there's something funny going on with the tests on MacOS :confused:

dong-zeyu commented 1 year ago

I see. Looks like printf in MacOS does not support \xXX format to hex value. I will use octal number instead. This should be unix compatible.