@@ -11,8 +11,8 @@ cdef class UVProcess(UVHandle):
11
11
12
12
cdef _init(self , Loop loop, list args, dict env,
13
13
cwd, start_new_session,
14
- stdin, stdout, stderr, pass_fds,
15
- debug_flags):
14
+ _stdin, _stdout, _stderr, # std* can be defined as macros in C
15
+ pass_fds, debug_flags):
16
16
17
17
cdef int err
18
18
@@ -31,7 +31,7 @@ cdef class UVProcess(UVHandle):
31
31
32
32
try :
33
33
self ._init_options(args, env, cwd, start_new_session,
34
- stdin, stdout, stderr )
34
+ _stdin, _stdout, _stderr )
35
35
36
36
restore_inheritable = set ()
37
37
if pass_fds:
@@ -111,7 +111,7 @@ cdef class UVProcess(UVHandle):
111
111
return ret
112
112
113
113
cdef _init_options(self , list args, dict env, cwd, start_new_session,
114
- stdin, stdout, stderr ):
114
+ _stdin, _stdout, _stderr ):
115
115
116
116
memset(& self .options, 0 , sizeof(uv.uv_process_options_t))
117
117
@@ -135,7 +135,7 @@ cdef class UVProcess(UVHandle):
135
135
136
136
self .options.exit_cb = & __uvprocess_on_exit_callback
137
137
138
- self ._init_files(stdin, stdout, stderr )
138
+ self ._init_files(_stdin, _stdout, _stderr )
139
139
140
140
cdef _init_args(self , list args):
141
141
cdef:
@@ -181,7 +181,7 @@ cdef class UVProcess(UVHandle):
181
181
else :
182
182
self .__env = None
183
183
184
- cdef _init_files(self , stdin, stdout, stderr ):
184
+ cdef _init_files(self , _stdin, _stdout, _stderr ):
185
185
self .options.stdio_count = 0
186
186
187
187
cdef _kill(self , int signum):
@@ -219,7 +219,7 @@ cdef class UVProcessTransport(UVProcess):
219
219
self ._pending_calls = []
220
220
self ._stdio_ready = 0
221
221
222
- self .stdin = self .stdout = self .stderr = None
222
+ self ._stdin = self ._stdout = self ._stderr = None
223
223
self .stdin_proto = self .stdout_proto = self .stderr_proto = None
224
224
225
225
self ._finished = 0
@@ -280,41 +280,41 @@ cdef class UVProcessTransport(UVProcess):
280
280
self ._close_after_spawn(r)
281
281
return r, w
282
282
283
- cdef _init_files(self , stdin, stdout, stderr ):
283
+ cdef _init_files(self , _stdin, _stdout, _stderr ):
284
284
cdef uv.uv_stdio_container_t * iocnt
285
285
286
- UVProcess._init_files(self , stdin, stdout, stderr )
286
+ UVProcess._init_files(self , _stdin, _stdout, _stderr )
287
287
288
288
io = [None , None , None ]
289
289
290
290
self .options.stdio_count = 3
291
291
self .options.stdio = self .iocnt
292
292
293
- if stdin is not None :
294
- if stdin == subprocess_PIPE:
293
+ if _stdin is not None :
294
+ if _stdin == subprocess_PIPE:
295
295
r, w = self ._file_inpipe()
296
296
io[0 ] = r
297
297
298
298
self .stdin_proto = WriteSubprocessPipeProto(self , 0 )
299
299
waiter = self ._loop._new_future()
300
- self .stdin = WriteUnixTransport.new(
300
+ self ._stdin = WriteUnixTransport.new(
301
301
self ._loop, self .stdin_proto, None , waiter)
302
302
self ._init_futs.append(waiter)
303
- self .stdin .open(w)
304
- self .stdin ._init_protocol()
305
- elif stdin == subprocess_DEVNULL:
303
+ self ._stdin .open(w)
304
+ self ._stdin ._init_protocol()
305
+ elif _stdin == subprocess_DEVNULL:
306
306
io[0 ] = self ._file_devnull()
307
- elif stdout == subprocess_STDOUT:
307
+ elif _stdout == subprocess_STDOUT:
308
308
raise ValueError (
309
309
' subprocess.STDOUT is supported only by stderr parameter' )
310
310
else :
311
311
raise ValueError (
312
- ' invalid stdin argument value {!r}' .format(stdin ))
312
+ ' invalid stdin argument value {!r}' .format(_stdin ))
313
313
else :
314
314
io[0 ] = self ._file_redirect_stdio(sys.stdin.fileno())
315
315
316
- if stdout is not None :
317
- if stdout == subprocess_PIPE:
316
+ if _stdout is not None :
317
+ if _stdout == subprocess_PIPE:
318
318
# We can't use UV_CREATE_PIPE here, since 'stderr' might be
319
319
# set to 'subprocess.STDOUT', and there is no way to
320
320
# emulate that functionality with libuv high-level
@@ -326,35 +326,35 @@ cdef class UVProcessTransport(UVProcess):
326
326
327
327
self .stdout_proto = ReadSubprocessPipeProto(self , 1 )
328
328
waiter = self ._loop._new_future()
329
- self .stdout = ReadUnixTransport.new(
329
+ self ._stdout = ReadUnixTransport.new(
330
330
self ._loop, self .stdout_proto, None , waiter)
331
331
self ._init_futs.append(waiter)
332
- self .stdout .open(r)
333
- self .stdout ._init_protocol()
334
- elif stdout == subprocess_DEVNULL:
332
+ self ._stdout .open(r)
333
+ self ._stdout ._init_protocol()
334
+ elif _stdout == subprocess_DEVNULL:
335
335
io[1 ] = self ._file_devnull()
336
- elif stdout == subprocess_STDOUT:
336
+ elif _stdout == subprocess_STDOUT:
337
337
raise ValueError (
338
338
' subprocess.STDOUT is supported only by stderr parameter' )
339
339
else :
340
340
raise ValueError (
341
- ' invalid stdout argument value {!r}' .format(stdin ))
341
+ ' invalid stdout argument value {!r}' .format(_stdout ))
342
342
else :
343
343
io[1 ] = self ._file_redirect_stdio(sys.stdout.fileno())
344
344
345
- if stderr is not None :
346
- if stderr == subprocess_PIPE:
345
+ if _stderr is not None :
346
+ if _stderr == subprocess_PIPE:
347
347
r, w = self ._file_outpipe()
348
348
io[2 ] = w
349
349
350
350
self .stderr_proto = ReadSubprocessPipeProto(self , 2 )
351
351
waiter = self ._loop._new_future()
352
- self .stderr = ReadUnixTransport.new(
352
+ self ._stderr = ReadUnixTransport.new(
353
353
self ._loop, self .stderr_proto, None , waiter)
354
354
self ._init_futs.append(waiter)
355
- self .stderr .open(r)
356
- self .stderr ._init_protocol()
357
- elif stderr == subprocess_STDOUT:
355
+ self ._stderr .open(r)
356
+ self ._stderr ._init_protocol()
357
+ elif _stderr == subprocess_STDOUT:
358
358
if io[1 ] is None :
359
359
# shouldn't ever happen
360
360
raise RuntimeError (' cannot apply subprocess.STDOUT' )
@@ -363,11 +363,11 @@ cdef class UVProcessTransport(UVProcess):
363
363
os_set_inheritable(newfd, True )
364
364
self ._close_after_spawn(newfd)
365
365
io[2 ] = newfd
366
- elif stdout == subprocess_DEVNULL:
366
+ elif _stderr == subprocess_DEVNULL:
367
367
io[2 ] = self ._file_devnull()
368
368
else :
369
369
raise ValueError (
370
- ' invalid stderr argument value {!r}' .format(stdin ))
370
+ ' invalid stderr argument value {!r}' .format(_stderr ))
371
371
else :
372
372
io[2 ] = self ._file_redirect_stdio(sys.stderr.fileno())
373
373
@@ -436,17 +436,17 @@ cdef class UVProcessTransport(UVProcess):
436
436
@staticmethod
437
437
cdef UVProcessTransport new(Loop loop, protocol, args, env,
438
438
cwd, start_new_session,
439
- stdin, stdout, stderr , pass_fds,
439
+ _stdin, _stdout, _stderr , pass_fds,
440
440
waiter,
441
441
debug_flags):
442
442
443
443
cdef UVProcessTransport handle
444
444
handle = UVProcessTransport.__new__ (UVProcessTransport)
445
445
handle._protocol = protocol
446
446
handle._init(loop, args, env, cwd, start_new_session,
447
- __process_convert_fileno(stdin ),
448
- __process_convert_fileno(stdout ),
449
- __process_convert_fileno(stderr ),
447
+ __process_convert_fileno(_stdin ),
448
+ __process_convert_fileno(_stdout ),
449
+ __process_convert_fileno(_stderr ),
450
450
pass_fds,
451
451
debug_flags)
452
452
@@ -473,11 +473,11 @@ cdef class UVProcessTransport(UVProcess):
473
473
474
474
def get_pipe_transport (self , fd ):
475
475
if fd == 0 :
476
- return self .stdin
476
+ return self ._stdin
477
477
elif fd == 1 :
478
- return self .stdout
478
+ return self ._stdout
479
479
elif fd == 2 :
480
- return self .stderr
480
+ return self ._stderr
481
481
482
482
def terminate (self ):
483
483
self ._check_proc()
@@ -498,12 +498,12 @@ cdef class UVProcessTransport(UVProcess):
498
498
if self ._returncode is None :
499
499
self ._kill(uv.SIGKILL)
500
500
501
- if self .stdin is not None :
502
- self .stdin .close()
503
- if self .stdout is not None :
504
- self .stdout .close()
505
- if self .stderr is not None :
506
- self .stderr .close()
501
+ if self ._stdin is not None :
502
+ self ._stdin .close()
503
+ if self ._stdout is not None :
504
+ self ._stdout .close()
505
+ if self ._stderr is not None :
506
+ self ._stderr .close()
507
507
508
508
self ._close()
509
509
0 commit comments