Permalink
Browse files

Further Python 3 fixes in core.

  • Loading branch information...
1 parent a7e8c70 commit cf41e1413f7514c544be4f93f6dc9b1d9eccd8fa @takluyver committed Aug 1, 2011
Showing with 7 additions and 4 deletions.
  1. +3 −1 IPython/core/interactiveshell.py
  2. +3 −2 IPython/core/macro.py
  3. +1 −1 IPython/core/magic.py
@@ -1677,7 +1677,9 @@ def init_readline(self):
# Remove some chars from the delimiters list. If we encounter
# unicode chars, discard them.
- delims = readline.get_completer_delims().encode("ascii", "ignore")
+ delims = readline.get_completer_delims()
+ if not py3compat.PY3:
+ delims = delims.encode("ascii", "ignore")
for d in self.readline_remove_delims:
delims = delims.replace(d, "")
delims = delims.replace(ESC_MAGIC, '')
View
@@ -10,6 +10,8 @@
import re
import sys
+from IPython.utils import py3compat
+
coding_declaration = re.compile(r"#\s*coding[:=]\s*([-\w.]+)")
class Macro(object):
@@ -37,8 +39,7 @@ def __init__(self,code):
self.value = code + '\n'
def __str__(self):
- enc = sys.stdin.encoding or sys.getdefaultencoding()
- return self.value.encode(enc, "replace")
+ return py3compat.unicode_to_str(self.value)
def __unicode__(self):
return self.value
View
@@ -676,7 +676,7 @@ def magic_psearch(self, parameter_s=''):
%psearch -a _* list objects beginning with a single underscore"""
try:
- parameter_s = parameter_s.encode('ascii')
+ parameter_s.encode('ascii')
except UnicodeEncodeError:
print 'Python identifiers can only contain ascii characters.'
return

0 comments on commit cf41e14

Please sign in to comment.