This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Patch for bug 1088077
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: donut, loewis, mwm
Priority: normal Keywords: patch

Created on 2004-12-19 21:27 by mwm, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
td mwm, 2004-12-19 21:27 Patch for bug 1088077
Messages (3)
msg47394 - (view) Author: Mike Meyer (mwm) Date: 2004-12-19 21:27
This patches adds a setsane function to the tty module.
msg47395 - (view) Author: Matthew Mueller (donut) Date: 2005-02-07 08:29
Logged In: YES 

Hi, I'm not a Python developer, but I've looked at your patch.

The following two problems jump out at me:

1) The mode is being saved in a single global variable,
which would be overwritten if the functions are called on
different fds.

2) If setraw and/or setcbreak are called multiple times, the
initial value of _mode is lost.

The obvious fix would just be to use a dict and not set the
value if it is already set.  

Also, I think think setsane is a somewhat misleading name,
perhaps something along the lines of setinitial or
restoremode would be more accurate.

Aside from all that, I don't know if keeping hidden state in
the module is really the best solution to the problem.  
Requiring the users to save and restore the value from
tcgetattr is not significantly harder and makes it more
obvious what is going on.  If some fix is required, adding a
note to the tty docs about how to save and restore the mode
using termios may be enough, or perhaps adding some (really)
thin savemode/restoremode wrappers to the tty module.
msg47396 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-03-03 23:49
Logged In: YES 

I agree with all these observations. In addition,
documentation is missing for the new function. 

Given all these issues (in particular the questionable value
of the new function in the first place), I'm rejecting the
patch. If you think a functionality like this should still
be added to Python, please submit a new patch, and give a
rationale for why this new function is needed.
Date User Action Args
2022-04-11 14:56:08adminsetgithub: 41346
2004-12-19 21:27:08mwmcreate