equal
deleted
inserted
replaced
296 uout.flush() |
296 uout.flush() |
297 for f, uif in [(fin, uin), (fout, uout)]: |
297 for f, uif in [(fin, uin), (fout, uout)]: |
298 if f is not uif: |
298 if f is not uif: |
299 os.dup2(f.fileno(), uif.fileno()) |
299 os.dup2(f.fileno(), uif.fileno()) |
300 f.close() |
300 f.close() |
301 |
|
302 @contextlib.contextmanager |
|
303 def protectedstdio(uin, uout): |
|
304 """Run code block with protected standard streams""" |
|
305 fin, fout = protectstdio(uin, uout) |
|
306 try: |
|
307 yield fin, fout |
|
308 finally: |
|
309 restorestdio(uin, uout, fin, fout) |
|
310 |
301 |
311 def shellenviron(environ=None): |
302 def shellenviron(environ=None): |
312 """return environ with optional override, useful for shelling out""" |
303 """return environ with optional override, useful for shelling out""" |
313 def py2shell(val): |
304 def py2shell(val): |
314 'convert python object into string that is useful to shell' |
305 'convert python object into string that is useful to shell' |