Skip to content

Commit beb6501

Browse files
author
ajohns
committed
-fix for select.select not supported on windows
-fix for maya/katana replacing stdin with object that does not have fileno attribute
1 parent c8851ff commit beb6501

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

src/rez/cli/env.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,11 @@ def command(opts, parser, extra_arg_groups=None):
229229

230230
# generally shells will behave as though the '-s' flag was not present when
231231
# no stdin is available. So here we replicate this behaviour.
232-
if opts.stdin and not select.select([sys.stdin], [], [], 0.0)[0]:
233-
opts.stdin = False
232+
try:
233+
if opts.stdin and not select.select([sys.stdin], [], [], 0.0)[0]:
234+
opts.stdin = False
235+
except select.error:
236+
pass # because windows
234237

235238
quiet = opts.quiet or bool(command)
236239
returncode, _, _ = context.execute_shell(

src/rez/utils/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

33
# Update this value to version up Rez. Do not place anything else in this file.
4-
_rez_version = "2.22.0"
4+
_rez_version = "2.22.1"
55

66
try:
77
from rez.vendor.version.version import Version

src/rez/utils/system.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,18 @@ def popen(args, **kwargs):
2121
2222
Avoids python bug described here: https://bugs.python.org/issue3905. This
2323
can arise when apps (maya) install a non-standard stdin handler.
24-
"""
2524
26-
# avoid non-standard stdin handler
27-
if "stdin" not in kwargs and sys.stdin.fileno() not in (0, 1, 2):
28-
kwargs["stdin"] = subprocess.PIPE
25+
In newer version of maya and katana, the sys.stdin object can also become
26+
replaced by an object with no 'fileno' attribute, this is also taken into
27+
account.
28+
"""
29+
if "stdin" not in kwargs:
30+
try:
31+
file_no = sys.stdin.fileno()
32+
except AttributeError:
33+
file_no = sys.__stdin__.fileno()
34+
35+
if file_no not in (0, 1, 2):
36+
kwargs["stdin"] = subprocess.PIPE
2937

3038
return subprocess.Popen(args, **kwargs)

src/rez/wrapper.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,12 @@ def _add_argument(*nargs, **kwargs):
173173
# generally shells will behave as though the '-s' flag was not present
174174
# when no stdin is available. So here we replicate this behaviour.
175175
import select
176-
if not select.select([sys.stdin], [], [], 0.0)[0]:
177-
opts.stdin = False
176+
177+
try:
178+
if not select.select([sys.stdin], [], [], 0.0)[0]:
179+
opts.stdin = False
180+
except select.error:
181+
pass # because windows
178182

179183
# construct command
180184
cmd = None

0 commit comments

Comments
 (0)