summarylogtreecommitdiffstats
path: root/py3fixes.patch
blob: 09949454404277f6a625b7608ff9be9054fe2cfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
Various fixes for py3 and tox.
Submitted at: https://bitbucket.org/pypy/pyrepl/issues/20/fixes-for-py3-and-tox

changeset:   267:76a9e56001f9
tag:         tip
user:        Daniel Hahler <hg@thequod.de>
date:        Sat Sep 03 23:12:35 2016 +0200
summary:     readline: monkeypatch builtins.input for py3

diff -r 086437c10aa1 -r 76a9e56001f9 pyrepl/readline.py
--- a/pyrepl/readline.py	Sat Sep 03 23:04:24 2016 +0200
+++ b/pyrepl/readline.py	Sat Sep 03 23:12:35 2016 +0200
@@ -423,9 +423,14 @@
 
     else:
         # this is not really what readline.c does.  Better than nothing I guess
-        import __builtin__
-        _old_raw_input = __builtin__.raw_input
-        __builtin__.raw_input = _wrapper.raw_input
+        try:
+            import __builtin__
+            _old_raw_input = __builtin__.raw_input
+            __builtin__.raw_input = _wrapper.raw_input
+        except ImportError:
+            import builtins
+            _old_raw_input = builtins.input
+            builtins.input = _wrapper.raw_input
 
 _old_raw_input = None
 _setup()

changeset:   266:086437c10aa1
user:        Daniel Hahler <hg@thequod.de>
date:        Sat Sep 03 23:04:24 2016 +0200
summary:     pyrepl/unix_eventqueue.py: fix byte issues for py3

diff -r 255ceeba2f03 -r 086437c10aa1 pyrepl/unix_eventqueue.py
--- a/pyrepl/unix_eventqueue.py	Sat Sep 03 23:00:45 2016 +0200
+++ b/pyrepl/unix_eventqueue.py	Sat Sep 03 23:04:24 2016 +0200
@@ -65,11 +65,11 @@
 #
 CTRL_ARROW_KEYCODE = {
     # for xterm, gnome-terminal, xfce terminal, etc.
-    '\033[1;5D': 'ctrl left',
-    '\033[1;5C': 'ctrl right',
+    b'\033[1;5D': 'ctrl left',
+    b'\033[1;5C': 'ctrl right',
     # for rxvt
-    '\033Od': 'ctrl left',
-    '\033Oc': 'ctrl right',
+    b'\033Od': 'ctrl left',
+    b'\033Oc': 'ctrl right',
 }
 
 def general_keycodes():
@@ -120,6 +120,7 @@
 
     def push(self, char):
         ord_char = char if isinstance(char, int) else ord(char)
+        char = bytes(bytearray((ord_char,)))
         self.buf.append(ord_char)
         if char in self.k:
             if self.k is self.ck:
@@ -133,13 +134,13 @@
                 self.insert(Event('key', k, self.flush_buf()))
                 self.k = self.ck
 
-        elif self.buf and self.buf[0] == 033: # 033 == escape
+        elif self.buf and self.buf[0] == 27:  # escape
             # escape sequence not recognized by our keymap: propagate it
             # outside so that i can be recognized as an M-... key (see also
             # the docstring in keymap.py, in particular the line \\E.
             trace('unrecognized escape sequence, propagating...')
             self.k = self.ck
-            self.insert(Event('key', '\033', '\033'))
+            self.insert(Event('key', '\033', bytearray(b'\033')))
             for c in self.flush_buf()[1:]:
                 self.push(chr(c))
 

changeset:   265:255ceeba2f03
user:        Daniel Hahler <hg@thequod.de>
date:        Sat Sep 03 23:00:45 2016 +0200
summary:     Use relative import for trace

diff -r ea8bd2b71671 -r 255ceeba2f03 pyrepl/input.py
--- a/pyrepl/input.py	Sat Sep 03 23:00:00 2016 +0200
+++ b/pyrepl/input.py	Sat Sep 03 23:00:45 2016 +0200
@@ -36,7 +36,7 @@
 import unicodedata
 from collections import deque
 import pprint
-from trace import trace
+from .trace import trace
 
 
 class InputTranslator(object):

changeset:   264:ea8bd2b71671
user:        Daniel Hahler <hg@thequod.de>
date:        Sat Sep 03 23:00:00 2016 +0200
summary:     tox.ini: passenv: TERM

diff -r 9401662c4e6c -r ea8bd2b71671 tox.ini
--- a/tox.ini	Fri Dec 04 13:10:13 2015 +0000
+++ b/tox.ini	Sat Sep 03 23:00:00 2016 +0200
@@ -4,6 +4,7 @@
 
 
 [testenv]
+passenv = TERM
 deps=
     pytest
     pexpect

diff -r 9401662c4e6c pyrepl/completing_reader.py
--- a/pyrepl/completing_reader.py	Fri Dec 04 13:10:13 2015 +0000
+++ b/pyrepl/completing_reader.py	Sun Sep 04 00:43:37 2016 +0200
@@ -65,8 +65,8 @@
         item = "%s  "
         padding = 2
     maxlen = min(max(map(real_len, wordlist)), cons.width - padding)
-    cols = cons.width / (maxlen + padding)
-    rows = (len(wordlist) - 1)/cols + 1
+    cols = int(cons.width / (maxlen + padding))
+    rows = int((len(wordlist) - 1)/cols + 1)
 
     if sort_in_column:
         # sort_in_column=False (default)     sort_in_column=True

diff -r 9401662c4e6c pyrepl/simple_interact.py
--- a/pyrepl/simple_interact.py	Fri Dec 04 13:10:13 2015 +0000
+++ b/pyrepl/simple_interact.py	Sun Sep 04 00:43:58 2016 +0200
@@ -42,8 +42,11 @@
     console = code.InteractiveConsole(mainmodule.__dict__, filename='<stdin>')
 
     def more_lines(unicodetext):
-        # ooh, look at the hack:
-        src = "#coding:utf-8\n"+unicodetext.encode('utf-8')
+        if sys.version_info < (3, ):
+            # ooh, look at the hack:
+            src = "#coding:utf-8\n"+unicodetext.encode('utf-8')
+        else:
+            src = unicodetext
         try:
             code = console.compile(src, '<stdin>', 'single')
         except (OverflowError, SyntaxError, ValueError):

diff -r 9401662c4e6c pyrepl/readline.py
--- a/pyrepl/readline.py	Fri Dec 04 13:10:13 2015 +0000
+++ b/pyrepl/readline.py	Sun Sep 04 00:44:30 2016 +0200
@@ -32,6 +32,12 @@
 from pyrepl.historical_reader import HistoricalReader
 from pyrepl.completing_reader import CompletingReader
 from pyrepl.unix_console import UnixConsole, _error
+try:
+    unicode
+except NameError:
+    unicode = str
+    unichr = chr
+    basestring = bytes, str
 
 
 ENCODING = sys.getfilesystemencoding() or 'latin1'     # XXX review
@@ -235,7 +235,7 @@
         self.config.completer_delims = dict.fromkeys(string)
 
     def get_completer_delims(self):
-        chars = self.config.completer_delims.keys()
+        chars = list(self.config.completer_delims.keys())
         chars.sort()
         return ''.join(chars)
 

Fix crash after readline input.

  File "/usr/lib/python3.5/pdb.py", line 259, in user_line
    self.interaction(frame, None)
  File "/usr/lib/python3.5/site-packages/pdb.py", line 250, in interaction
    self.cmdloop()
  File "/usr/lib/python3.5/cmd.py", line 137, in cmdloop
    line = self.precmd(line)
  File "/usr/lib/python3.5/pdb.py", line 396, in precmd
    marker = line.find(';;')
TypeError: a bytes-like object is required, not 'str'

diff -r 9401662c4e6c pyrepl/readline.py
--- a/pyrepl/readline.py        Fri Dec 04 13:10:13 2015 +0000
+++ b/pyrepl/readline.py        Fri Sep 16 00:41:57 2016 +0200
@@ -199,7 +205,9 @@
         except _error:
             return _old_raw_input(prompt)
         reader.ps1 = prompt            
-        return reader.readline(startup_hook=self.startup_hook)
+        # Unicode/str is required for Python 3 (3.5.2).
+        return unicode(reader.readline(startup_hook=self.startup_hook),
+                       ENCODING)
 
     def multiline_input(self, more_lines, ps1, ps2, returns_unicode=False):
         """Read an input on possibly multiple lines, asking for more