Skip to content

Commit e92e6bf

Browse files
committed
Avoid using 'std*' C names (can be macros in C)
1 parent 840a654 commit e92e6bf

File tree

2 files changed

+53
-53
lines changed

2 files changed

+53
-53
lines changed

uvloop/handles/process.pxd

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ cdef class UVProcess(UVHandle):
1717

1818
cdef _init(self, Loop loop, list args, dict env, cwd,
1919
start_new_session,
20-
stdin, stdout, stderr, pass_fds,
20+
_stdin, _stdout, _stderr, pass_fds,
2121
debug_flags)
2222

2323
cdef char** __to_cstring_array(self, list arr)
2424
cdef _init_args(self, list args)
2525
cdef _init_env(self, dict env)
26-
cdef _init_files(self, stdin, stdout, stderr)
26+
cdef _init_files(self, _stdin, _stdout, _stderr)
2727
cdef _init_options(self, list args, dict env, cwd, start_new_session,
28-
stdin, stdout, stderr)
28+
_stdin, _stdout, _stderr)
2929

3030
cdef _close_after_spawn(self, int fd)
3131

@@ -42,9 +42,9 @@ cdef class UVProcessTransport(UVProcess):
4242
object _protocol
4343
bint _finished
4444

45-
WriteUnixTransport stdin
46-
ReadUnixTransport stdout
47-
ReadUnixTransport stderr
45+
WriteUnixTransport _stdin
46+
ReadUnixTransport _stdout
47+
ReadUnixTransport _stderr
4848

4949
object stdin_proto
5050
object stdout_proto
@@ -65,6 +65,6 @@ cdef class UVProcessTransport(UVProcess):
6565
@staticmethod
6666
cdef UVProcessTransport new(Loop loop, protocol, args, env, cwd,
6767
start_new_session,
68-
stdin, stdout, stderr, pass_fds,
68+
_stdin, _stdout, _stderr, pass_fds,
6969
waiter,
7070
debug_flags)

uvloop/handles/process.pyx

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ cdef class UVProcess(UVHandle):
1111

1212
cdef _init(self, Loop loop, list args, dict env,
1313
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):
1616

1717
cdef int err
1818

@@ -31,7 +31,7 @@ cdef class UVProcess(UVHandle):
3131

3232
try:
3333
self._init_options(args, env, cwd, start_new_session,
34-
stdin, stdout, stderr)
34+
_stdin, _stdout, _stderr)
3535

3636
restore_inheritable = set()
3737
if pass_fds:
@@ -111,7 +111,7 @@ cdef class UVProcess(UVHandle):
111111
return ret
112112

113113
cdef _init_options(self, list args, dict env, cwd, start_new_session,
114-
stdin, stdout, stderr):
114+
_stdin, _stdout, _stderr):
115115

116116
memset(&self.options, 0, sizeof(uv.uv_process_options_t))
117117

@@ -135,7 +135,7 @@ cdef class UVProcess(UVHandle):
135135

136136
self.options.exit_cb = &__uvprocess_on_exit_callback
137137

138-
self._init_files(stdin, stdout, stderr)
138+
self._init_files(_stdin, _stdout, _stderr)
139139

140140
cdef _init_args(self, list args):
141141
cdef:
@@ -181,7 +181,7 @@ cdef class UVProcess(UVHandle):
181181
else:
182182
self.__env = None
183183

184-
cdef _init_files(self, stdin, stdout, stderr):
184+
cdef _init_files(self, _stdin, _stdout, _stderr):
185185
self.options.stdio_count = 0
186186

187187
cdef _kill(self, int signum):
@@ -219,7 +219,7 @@ cdef class UVProcessTransport(UVProcess):
219219
self._pending_calls = []
220220
self._stdio_ready = 0
221221

222-
self.stdin = self.stdout = self.stderr = None
222+
self._stdin = self._stdout = self._stderr = None
223223
self.stdin_proto = self.stdout_proto = self.stderr_proto = None
224224

225225
self._finished = 0
@@ -280,41 +280,41 @@ cdef class UVProcessTransport(UVProcess):
280280
self._close_after_spawn(r)
281281
return r, w
282282

283-
cdef _init_files(self, stdin, stdout, stderr):
283+
cdef _init_files(self, _stdin, _stdout, _stderr):
284284
cdef uv.uv_stdio_container_t *iocnt
285285

286-
UVProcess._init_files(self, stdin, stdout, stderr)
286+
UVProcess._init_files(self, _stdin, _stdout, _stderr)
287287

288288
io = [None, None, None]
289289

290290
self.options.stdio_count = 3
291291
self.options.stdio = self.iocnt
292292

293-
if stdin is not None:
294-
if stdin == subprocess_PIPE:
293+
if _stdin is not None:
294+
if _stdin == subprocess_PIPE:
295295
r, w = self._file_inpipe()
296296
io[0] = r
297297

298298
self.stdin_proto = WriteSubprocessPipeProto(self, 0)
299299
waiter = self._loop._new_future()
300-
self.stdin = WriteUnixTransport.new(
300+
self._stdin = WriteUnixTransport.new(
301301
self._loop, self.stdin_proto, None, waiter)
302302
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:
306306
io[0] = self._file_devnull()
307-
elif stdout == subprocess_STDOUT:
307+
elif _stdout == subprocess_STDOUT:
308308
raise ValueError(
309309
'subprocess.STDOUT is supported only by stderr parameter')
310310
else:
311311
raise ValueError(
312-
'invalid stdin argument value {!r}'.format(stdin))
312+
'invalid stdin argument value {!r}'.format(_stdin))
313313
else:
314314
io[0] = self._file_redirect_stdio(sys.stdin.fileno())
315315

316-
if stdout is not None:
317-
if stdout == subprocess_PIPE:
316+
if _stdout is not None:
317+
if _stdout == subprocess_PIPE:
318318
# We can't use UV_CREATE_PIPE here, since 'stderr' might be
319319
# set to 'subprocess.STDOUT', and there is no way to
320320
# emulate that functionality with libuv high-level
@@ -326,35 +326,35 @@ cdef class UVProcessTransport(UVProcess):
326326

327327
self.stdout_proto = ReadSubprocessPipeProto(self, 1)
328328
waiter = self._loop._new_future()
329-
self.stdout = ReadUnixTransport.new(
329+
self._stdout = ReadUnixTransport.new(
330330
self._loop, self.stdout_proto, None, waiter)
331331
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:
335335
io[1] = self._file_devnull()
336-
elif stdout == subprocess_STDOUT:
336+
elif _stdout == subprocess_STDOUT:
337337
raise ValueError(
338338
'subprocess.STDOUT is supported only by stderr parameter')
339339
else:
340340
raise ValueError(
341-
'invalid stdout argument value {!r}'.format(stdin))
341+
'invalid stdout argument value {!r}'.format(_stdout))
342342
else:
343343
io[1] = self._file_redirect_stdio(sys.stdout.fileno())
344344

345-
if stderr is not None:
346-
if stderr == subprocess_PIPE:
345+
if _stderr is not None:
346+
if _stderr == subprocess_PIPE:
347347
r, w = self._file_outpipe()
348348
io[2] = w
349349

350350
self.stderr_proto = ReadSubprocessPipeProto(self, 2)
351351
waiter = self._loop._new_future()
352-
self.stderr = ReadUnixTransport.new(
352+
self._stderr = ReadUnixTransport.new(
353353
self._loop, self.stderr_proto, None, waiter)
354354
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:
358358
if io[1] is None:
359359
# shouldn't ever happen
360360
raise RuntimeError('cannot apply subprocess.STDOUT')
@@ -363,11 +363,11 @@ cdef class UVProcessTransport(UVProcess):
363363
os_set_inheritable(newfd, True)
364364
self._close_after_spawn(newfd)
365365
io[2] = newfd
366-
elif stdout == subprocess_DEVNULL:
366+
elif _stderr == subprocess_DEVNULL:
367367
io[2] = self._file_devnull()
368368
else:
369369
raise ValueError(
370-
'invalid stderr argument value {!r}'.format(stdin))
370+
'invalid stderr argument value {!r}'.format(_stderr))
371371
else:
372372
io[2] = self._file_redirect_stdio(sys.stderr.fileno())
373373

@@ -436,17 +436,17 @@ cdef class UVProcessTransport(UVProcess):
436436
@staticmethod
437437
cdef UVProcessTransport new(Loop loop, protocol, args, env,
438438
cwd, start_new_session,
439-
stdin, stdout, stderr, pass_fds,
439+
_stdin, _stdout, _stderr, pass_fds,
440440
waiter,
441441
debug_flags):
442442

443443
cdef UVProcessTransport handle
444444
handle = UVProcessTransport.__new__(UVProcessTransport)
445445
handle._protocol = protocol
446446
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),
450450
pass_fds,
451451
debug_flags)
452452

@@ -473,11 +473,11 @@ cdef class UVProcessTransport(UVProcess):
473473

474474
def get_pipe_transport(self, fd):
475475
if fd == 0:
476-
return self.stdin
476+
return self._stdin
477477
elif fd == 1:
478-
return self.stdout
478+
return self._stdout
479479
elif fd == 2:
480-
return self.stderr
480+
return self._stderr
481481

482482
def terminate(self):
483483
self._check_proc()
@@ -498,12 +498,12 @@ cdef class UVProcessTransport(UVProcess):
498498
if self._returncode is None:
499499
self._kill(uv.SIGKILL)
500500

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()
507507

508508
self._close()
509509

0 commit comments

Comments
 (0)