mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-29 11:03:13 +00:00
fix #1432
This commit is contained in:
parent
38b43cc9f9
commit
705d042629
@ -13,6 +13,7 @@ import tempfile
|
||||
import traceback
|
||||
import weakref
|
||||
|
||||
import six
|
||||
import urwid
|
||||
from typing import Optional # noqa
|
||||
|
||||
@ -392,8 +393,13 @@ class ConsoleMaster(flow.FlowMaster):
|
||||
def spawn_editor(self, data):
|
||||
text = not isinstance(data, bytes)
|
||||
fd, name = tempfile.mkstemp('', "mproxy", text=text)
|
||||
os.write(fd, data)
|
||||
if six.PY2:
|
||||
os.close(fd)
|
||||
with open(name, "w" if text else "wb") as f:
|
||||
f.write(data)
|
||||
else:
|
||||
with open(fd, "w" if text else "wb") as f:
|
||||
f.write(data)
|
||||
# if no EDITOR is set, assume 'vi'
|
||||
c = os.environ.get("EDITOR") or "vi"
|
||||
cmd = shlex.split(c)
|
||||
|
Loading…
Reference in New Issue
Block a user