diff --git a/eventlet/green/builtin.py b/eventlet/green/builtin.py index 71de1dce5c..8d0603a334 100644 --- a/eventlet/green/builtin.py +++ b/eventlet/green/builtin.py @@ -38,9 +38,9 @@ def __init__(self, *args, **kwargs): __opening = False -def open(*args): +def open(*args, **kwargs): global __opening - result = __original_open(*args) + result = __original_open(*args, **kwargs) if not __opening: # This is incredibly ugly. 'open' is used under the hood by # the import process. So, ensure we don't wind up in an diff --git a/tests/isolated/patcher_open_kwargs.py b/tests/isolated/patcher_open_kwargs.py new file mode 100644 index 0000000000..be88ef9cb9 --- /dev/null +++ b/tests/isolated/patcher_open_kwargs.py @@ -0,0 +1,10 @@ +__test__ = False + +if __name__ == "__main__": + import eventlet + eventlet.monkey_patch(builtins=True, os=True) + + with open(__file__, mode="rt", buffering=16): + pass + + print("pass") diff --git a/tests/patcher_test.py b/tests/patcher_test.py index 6ff6e5a9be..dbf6e1c71f 100644 --- a/tests/patcher_test.py +++ b/tests/patcher_test.py @@ -523,3 +523,7 @@ def test_fork_after_monkey_patch(): def test_builtin(): tests.run_isolated('patcher_builtin.py') + + +def test_open_kwargs(): + tests.run_isolated("patcher_open_kwargs.py")