@@ -161,7 +161,7 @@ async def task(g=None, prompt="--> "):
161
161
cmd = cmd [:- 1 ]
162
162
sys .stdout .write ("\x08 \x08 " )
163
163
elif c == CHAR_CTRL_A :
164
- await raw_repl (s , g )
164
+ await raw_repl (g )
165
165
break
166
166
elif c == CHAR_CTRL_B :
167
167
continue
@@ -239,7 +239,7 @@ async def task(g=None, prompt="--> "):
239
239
micropython .kbd_intr (3 )
240
240
241
241
242
- async def raw_paste (s , g , window = 512 ):
242
+ def raw_paste (window = 512 ):
243
243
sys .stdout .write ("R\x01 " ) # supported
244
244
sys .stdout .write (bytearray ([window & 0xFF , window >> 8 , 0x01 ]).decode ())
245
245
eof = False
@@ -248,7 +248,7 @@ async def raw_paste(s, g, window=512):
248
248
file = b""
249
249
while not eof :
250
250
for idx in range (window ):
251
- b = await s .read (1 )
251
+ b = sys . stdin .read (1 )
252
252
c = ord (b )
253
253
if c == CHAR_CTRL_C or c == CHAR_CTRL_D :
254
254
# end of file
@@ -267,7 +267,12 @@ async def raw_paste(s, g, window=512):
267
267
return file
268
268
269
269
270
- async def raw_repl (s : asyncio .StreamReader , g : dict ):
270
+ async def raw_repl (g : dict ):
271
+ """
272
+ This function is blocking to prevent other
273
+ async tasks from writing to the stdio stream and
274
+ breaking the raw repl session.
275
+ """
271
276
heading = "raw REPL; CTRL-B to exit\n "
272
277
line = ""
273
278
sys .stdout .write (heading )
@@ -276,15 +281,15 @@ async def raw_repl(s: asyncio.StreamReader, g: dict):
276
281
line = ""
277
282
sys .stdout .write (">" )
278
283
while True :
279
- b = await s .read (1 )
284
+ b = sys . stdin .read (1 )
280
285
c = ord (b )
281
286
if c == CHAR_CTRL_A :
282
287
rline = line
283
288
line = ""
284
289
285
290
if len (rline ) == 2 and ord (rline [0 ]) == CHAR_CTRL_E :
286
291
if rline [1 ] == "A" :
287
- line = await raw_paste (s , g )
292
+ line = raw_paste ()
288
293
break
289
294
else :
290
295
# reset raw REPL
0 commit comments