diff options
author | Kurt B. Kaiser <kbk@shore.net> | 2002-09-18 02:29:59 (GMT) |
---|---|---|
committer | Kurt B. Kaiser <kbk@shore.net> | 2002-09-18 02:29:59 (GMT) |
commit | 837d15c5b5deee769079faa94117d8a83adb53ec (patch) | |
tree | 931696fe3b8574ffa29062a11465ca7cdc11abc6 | |
parent | 923e4ef049af4e750b1d3dda8d9dc08957101abf (diff) | |
download | cpython-837d15c5b5deee769079faa94117d8a83adb53ec.zip cpython-837d15c5b5deee769079faa94117d8a83adb53ec.tar.gz cpython-837d15c5b5deee769079faa94117d8a83adb53ec.tar.bz2 |
Merge Py Idle changes:
Rev 1.35 fdrake
Use string.ascii_letters instead of string.letters (SF bug #226706).
Move computation of sets of characters out of the body of the function
that uses them.
Rev 1.36 tim_one
Convert a pile of obvious "yes/no" functions to return bool
Rev 1.37
(skip, done differently in Idlefork)
Rev 1.38 loewis
Patch #590913: PEP 263 support.
Rev 1.39 loewis
Convert characters from the locale's encoding on output.
Reject characters outside the locale's encoding on input.
Rev 1.40 doerwalter
(string methods)
Rev 1.41
(skipped, done by GvR in rpc)
-rw-r--r-- | Lib/idlelib/PyShell.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py index 9c3aa50..7ce5244 100644 --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -289,6 +289,14 @@ class ModifiedInterpreter(InteractiveInterpreter): self.more = 0 self.save_warnings_filters = warnings.filters[:] warnings.filterwarnings(action="error", category=SyntaxWarning) + if isinstance(source, types.UnicodeType): + import IOBinding + try: + source = source.encode(IOBinding.encoding) + except UnicodeError: + self.tkconsole.resetoutput() + self.write("Unsupported characters in input") + return try: return InteractiveInterpreter.runsource(self, source, filename) finally: @@ -300,10 +308,12 @@ class ModifiedInterpreter(InteractiveInterpreter): "Stuff source in the filename cache" filename = "<pyshell#%d>" % self.gid self.gid = self.gid + 1 - lines = string.split(source, "\n") + lines = source.split("\n") linecache.cache[filename] = len(source)+1, 0, lines, filename return filename - + + IDENTCHARS = string.ascii_letters + string.digits + "_" + def showsyntaxerror(self, filename=None): """Extend base class method: Add Colorizing @@ -326,7 +336,7 @@ class ModifiedInterpreter(InteractiveInterpreter): text.tag_add("ERROR", pos) text.see(pos) char = text.get(pos) - if char and char in string.letters + string.digits + "_": + if char and char in IDENTCHARS: text.tag_add("ERROR", pos + " wordstart", pos) self.tkconsole.resetoutput() self.write("SyntaxError: %s\n" % str(msg)) @@ -598,7 +608,7 @@ class PyShell(OutputWindow): def ispythonsource(self, filename): "Override EditorWindow method: never remove the colorizer" - return 1 + return True def short_title(self): return self.shell_title @@ -641,7 +651,7 @@ class PyShell(OutputWindow): return line def isatty(self): - return 1 + return True def cancel_callback(self, event): try: @@ -735,7 +745,7 @@ class PyShell(OutputWindow): # If we're in the current input and there's only whitespace # beyond the cursor, erase that whitespace first s = self.text.get("insert", "end-1c") - if s and not string.strip(s): + if s and not s.strip(): self.text.delete("insert", "end-1c") # If we're in the current input before its last line, # insert a newline right at the insert point @@ -852,7 +862,7 @@ class PseudoFile: pass def isatty(self): - return 1 + return True usage_msg = """\ |