Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/ui.py @ 5613:2e76e5a23c2b
workaround for raw_input() on Windows
Since change a3fe91b4f6eb, Mercurial has set_binary() on stdin, stdout, and stderr.
On Windows, this had the side effect of causing raw_input() to emit trailing carriage
returns on it's returned strings. This was causing web authentication problems.
author | Steve Borho <steve@borho.org> |
---|---|
date | Mon, 03 Dec 2007 17:28:26 -0600 |
parents | 8c5ef3b87cb1 |
children | 3c80ecdc1bcd |
comparison
equal
deleted
inserted
replaced
5612:7c976bb039af | 5613:2e76e5a23c2b |
---|---|
401 import readline | 401 import readline |
402 # force demandimport to really load the module | 402 # force demandimport to really load the module |
403 readline.read_history_file | 403 readline.read_history_file |
404 except ImportError: | 404 except ImportError: |
405 pass | 405 pass |
406 return raw_input(prompt) | 406 line = raw_input(prompt) |
407 # When stdin is in binary mode on Windows, it can cause | |
408 # raw_input() to emit an extra trailing carriage return | |
409 if os.linesep == '\r\n' and line and line[-1] == '\r': | |
410 line = line[:-1] | |
411 return line | |
407 | 412 |
408 def prompt(self, msg, pat=None, default="y", matchflags=0): | 413 def prompt(self, msg, pat=None, default="y", matchflags=0): |
409 if not self.interactive: return default | 414 if not self.interactive: return default |
410 try: | 415 try: |
411 r = self._readline(msg + ' ') | 416 r = self._readline(msg + ' ') |