Skip to content

Commit

Permalink
Fix gevent#302: "python -m gevent.monkey" sets __file__
Browse files Browse the repository at this point in the history
Thanks to frostedcheerios.
  • Loading branch information
denik committed Sep 14, 2013
1 parent 0809635 commit aadb525
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions gevent/monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ def patch_all(socket=True, dns=True, time=True, select=True, thread=True, os=Tru
if argv:
sys.argv = argv
__package__ = None
globals()['__file__'] = sys.argv[0] # issue #302
execfile(sys.argv[0])
else:
print (script_help)
14 changes: 14 additions & 0 deletions greentest/test__issue302monkey.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import sys


if 'gevent' not in sys.modules:
from subprocess import Popen, PIPE
args = [sys.executable, '-m', 'gevent.monkey', __file__]
p = Popen(args)
code = p.wait()
assert code == 0, code

else:
import socket
assert 'gevent' in repr(socket.socket), repr(socket.socket)
assert __file__ == 'test__issue302monkey.py', repr(__file__)

0 comments on commit aadb525

Please sign in to comment.