summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/cmd.py10
-rw-r--r--Lib/code.py10
-rw-r--r--Lib/distutils/command/register.py5
-rw-r--r--Lib/getpass.py3
-rw-r--r--Lib/idlelib/PyShell.py2
-rwxr-xr-xLib/pdb.py5
-rw-r--r--Lib/plat-mac/aetools.py5
-rwxr-xr-xLib/pydoc.py5
-rw-r--r--Lib/rlcompleter.py6
-rw-r--r--Lib/site.py4
-rw-r--r--Lib/test/test_exceptions.py4
-rw-r--r--Lib/urllib.py7
12 files changed, 43 insertions, 23 deletions
diff --git a/Lib/cmd.py b/Lib/cmd.py
index 3f82b48..23dc5b2 100644
--- a/Lib/cmd.py
+++ b/Lib/cmd.py
@@ -40,18 +40,20 @@ The data members `self.doc_header', `self.misc_header', and
`self.undoc_header' set the headers used for the help function's
listings of documented functions, miscellaneous topics, and undocumented
functions respectively.
-
-These interpreters use raw_input; thus, if the readline module is loaded,
-they automatically support Emacs-like command history and editing features.
"""
-import string
+import string, sys
__all__ = ["Cmd"]
PROMPT = '(Cmd) '
IDENTCHARS = string.ascii_letters + string.digits + '_'
+def raw_input(prompt):
+ sys.stdout.write(prompt)
+ sys.stdout.flush()
+ return sys.stdin.readline()
+
class Cmd:
"""A simple framework for writing line-oriented command interpreters.
diff --git a/Lib/code.py b/Lib/code.py
index 6bdc658..b67009b 100644
--- a/Lib/code.py
+++ b/Lib/code.py
@@ -269,12 +269,14 @@ class InteractiveConsole(InteractiveInterpreter):
The returned line does not include the trailing newline.
When the user enters the EOF key sequence, EOFError is raised.
- The base implementation uses the built-in function
- raw_input(); a subclass may replace this with a different
- implementation.
+ The base implementation uses sys.stdin.readline(); a subclass
+ may replace this with a different implementation.
"""
- return raw_input(prompt)
+ sys.stdout.write(prompt)
+ sys.stdout.flush()
+ return sys.stdin.readline()
+
def interact(banner=None, readfunc=None, local=None):
diff --git a/Lib/distutils/command/register.py b/Lib/distutils/command/register.py
index dec9aa2..f891262 100644
--- a/Lib/distutils/command/register.py
+++ b/Lib/distutils/command/register.py
@@ -13,6 +13,11 @@ import StringIO, ConfigParser
from distutils.core import Command
from distutils.errors import *
+def raw_input(prompt):
+ sys.stdout.write(prompt)
+ sys.stdout.flush()
+ return sys.stdin.readline()
+
class register(Command):
description = ("register the distribution with the Python package index")
diff --git a/Lib/getpass.py b/Lib/getpass.py
index e96491f..a30d3a1 100644
--- a/Lib/getpass.py
+++ b/Lib/getpass.py
@@ -69,8 +69,7 @@ def default_getpass(prompt='Password: '):
def _raw_input(prompt=""):
- # A raw_input() replacement that doesn't save the string in the
- # GNU readline history.
+ # This doesn't save the string in the GNU readline history.
prompt = str(prompt)
if prompt:
sys.stdout.write(prompt)
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index f81091b..b6abe40 100644
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -1122,7 +1122,7 @@ class PyShell(OutputWindow):
self.text.tag_add("stdin", "iomark", "end-1c")
self.text.update_idletasks()
if self.reading:
- self.top.quit() # Break out of recursive mainloop() in raw_input()
+ self.top.quit() # Break out of recursive mainloop()
else:
self.runit()
return "break"
diff --git a/Lib/pdb.py b/Lib/pdb.py
index b00f68b..1aa2eae 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -22,6 +22,11 @@ _saferepr = _repr.repr
__all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace",
"post_mortem", "help"]
+def raw_input(prompt):
+ sys.stdout.write(prompt)
+ sys.stdout.flush()
+ return sys.stdin.readline()
+
def find_function(funcname, filename):
cre = re.compile(r'def\s+%s\s*[(]' % funcname)
try:
diff --git a/Lib/plat-mac/aetools.py b/Lib/plat-mac/aetools.py
index 79f3978..861dd2f 100644
--- a/Lib/plat-mac/aetools.py
+++ b/Lib/plat-mac/aetools.py
@@ -342,6 +342,11 @@ _application_file._elemdict = {
# XXXX Should test more, really...
def test():
+ def raw_input(prompt):
+ sys.stdout.write(prompt)
+ sys.stdout.flush()
+ return sys.stdin.readline()
+
target = AE.AECreateDesc('sign', 'quil')
ae = AE.AECreateAppleEvent('aevt', 'oapp', target, -1, 0)
print unpackevent(ae)
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index ee45643..b6afc7f 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1505,6 +1505,11 @@ def writedocs(dir, pkgpath='', done=None):
done[modname] = 1
writedoc(modname)
+def raw_input(prompt):
+ sys.stdout.write(prompt)
+ sys.stdout.flush()
+ return sys.stdin.readline()
+
class Helper:
keywords = {
'and': 'BOOLEAN',
diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py
index 1d29167..6eb77f9 100644
--- a/Lib/rlcompleter.py
+++ b/Lib/rlcompleter.py
@@ -28,12 +28,6 @@ application (or the user) to enable this feature, I consider this an
acceptable risk. More complicated expressions (e.g. function calls or
indexing operations) are *not* evaluated.
-- GNU readline is also used by the built-in functions input() and
-raw_input(), and thus these also benefit/suffer from the completer
-features. Clearly an interactive application can benefit by
-specifying its own completer function and using raw_input() for all
-its input.
-
- When the original stdin is not a tty device, GNU readline is never
used, and this module (and the readline module) are silently inactive.
diff --git a/Lib/site.py b/Lib/site.py
index 6818e85..5e7ff7b 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -299,7 +299,9 @@ class _Printer(object):
lineno += self.MAXLINES
key = None
while key is None:
- key = raw_input(prompt)
+ sys.stdout.write(prompt)
+ sys.stdout.flush()
+ key = sys.stdin.readline()
if key not in ('', 'q'):
key = None
if key == 'q':
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index fdef876..65f7876 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -44,8 +44,8 @@ fp = open(TESTFN, 'r')
savestdin = sys.stdin
try:
try:
- sys.stdin = fp
- x = raw_input()
+ import marshal
+ marshal.loads('')
except EOFError:
pass
finally:
diff --git a/Lib/urllib.py b/Lib/urllib.py
index aeca3f1..136f42e 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -768,10 +768,11 @@ class FancyURLopener(URLopener):
def prompt_user_passwd(self, host, realm):
"""Override this in a GUI environment!"""
- import getpass
+ import getpass, sys
try:
- user = raw_input("Enter username for %s at %s: " % (realm,
- host))
+ sys.stdout.write("Enter username for %s at %s: " % (realm, host))
+ sys.stdout.flush()
+ user = sys.stdin.readline()
passwd = getpass.getpass("Enter password for %s in %s at %s: " %
(user, realm, host))
return user, passwd