Skip to content

Commit

Permalink
patcher: built-in open() did not accept kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
temoto committed Jan 29, 2021
1 parent 4705f07 commit 4497952
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions eventlet/green/builtin.py
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions 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")
4 changes: 4 additions & 0 deletions tests/patcher_test.py
Expand Up @@ -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")

0 comments on commit 4497952

Please sign in to comment.