softyoungha commented on code in PR #40942:
URL: https://github.com/apache/airflow/pull/40942#discussion_r1688164892
##########
airflow/operators/python.py:
##########
@@ -450,6 +451,12 @@ def __init__(
raise ValueError(f"{type(self).__name__} only supports functions
for python_callable arg")
if inspect.isgeneratorfunction(python_callable):
raise ValueError(f"{type(self).__name__} does not support using
'yield' in python_callable")
+ if env_vars:
+ for key, value in env_vars.items():
+ if not isinstance(key, str):
+ raise ValueError(f"env_vars key ${key} must be a string,
but got {type(key)}")
+ if not isinstance(value, str):
+ raise ValueError(f"env_vars value must be a string, but
got {type(value)}")
Review Comment:
@uranusjr
Oh, I forgot the policy!
As you mentioned, errors will be automatically raised when passed to Popen.
```python
execute_in_subprocess_with_kwargs(["bash", "-c", "export"], env={"MY_VARS":
1})
# output:
# File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
# self._execute_child(args, executable, preexec_fn, close_fds,
# File "/usr/lib/python3.10/subprocess.py", line 1783, in _execute_child
# env_list.append(k + b'=' + os.fsencode(v))
# File "/usr/lib/python3.10/os.py", line 811, in fsencode
# filename = fspath(filename) # Does type-checking of `filename`.
# TypeError: expected str, bytes or os.PathLike object, not int
```
I will make the changes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]