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.

classification
Title: pydoc.help samples sys.stdout and sys.stdin at import time
Type: enhancement Stage: test needed
Components: Extension Modules Versions: Python 3.1, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Importing pydoc and overwriting sys.stdout, causes one char to be sent to the console when calling help()
View: 8198
Assigned To: Nosy List: ajaksu2, farialima, georg.brandl, jchl
Priority: low Keywords: easy

Created on 2007-04-13 19:53 by jchl, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg31781 - (view) Author: James Lingard (jchl) Date: 2007-04-13 19:53
pydoc.help (aliased to the builtin help) uses the values of sys.stdout and sys.stdin that were in use when the pydoc module was imported.  This means that if sys.stdout and/or sys.stdin are later modified, subsequent calls to pydoc.help (or help) use the wrong stdout and stdin.

Instead, help should use the current values of sys.stdout and sys.stdin each time it is called.

Reported against Python 2.4.4.
msg101480 - (view) Author: François Granade (farialima) Date: 2010-03-22 05:26
issue8198 is related.

Re. 1700304, it's easy to work around by writing

from pydoc import help
import sys
help.output = sys.stdout
help.input = sys.stdin
msg101982 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2010-03-31 06:14
From #8198:

I see a solution by turning Helper.output into a property, but it smells of over-engineering :) Passing all output to pagers should work too, unless we need Helper.output as a sort of sys.stderr.
msg112188 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-07-31 19:42
Duplicate of #8198.
History
Date User Action Args
2022-04-11 14:56:23adminsetgithub: 44843
2010-07-31 19:42:36georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg112188

superseder: Importing pydoc and overwriting sys.stdout, causes one char to be sent to the console when calling help()
resolution: duplicate
2010-03-31 06:14:41ajaksu2setkeywords: + easy
nosy: + ajaksu2
messages: + msg101982

2010-03-31 06:14:31ajaksu2linkissue8198 dependencies
2010-03-22 05:26:08farialimasetnosy: + farialima
messages: + msg101480
2009-03-30 17:04:15ajaksu2setpriority: normal -> low
stage: test needed
type: enhancement
versions: + Python 3.1, Python 2.7, - Python 2.4
2007-04-13 19:53:14jchlcreate