Commit c2e5edbd authored by Jiajun Huang's avatar Jiajun Huang

Fix Python 2 and 3 have diffrent default encoding

parent d02cc4c5
...@@ -138,7 +138,8 @@ def main(path_to_debug_info=None, gdb_argv=None, no_import=False): ...@@ -138,7 +138,8 @@ def main(path_to_debug_info=None, gdb_argv=None, no_import=False):
tempfilename = make_command_file(path_to_debug_info, no_import=no_import) tempfilename = make_command_file(path_to_debug_info, no_import=no_import)
logger.info("Launching %s with command file: %s and gdb_argv: %s", logger.info("Launching %s with command file: %s and gdb_argv: %s",
options.gdb, tempfilename, gdb_argv) options.gdb, tempfilename, gdb_argv)
logger.debug('Command file (%s) contains: """\n%s"""', tempfilename, open(tempfilename).read()) tempfile_fd = open(tempfilename)
logger.debug('Command file (%s) contains: """\n%s"""', tempfilename, tempfile_fd.read())
logger.info("Spawning %s...", options.gdb) logger.info("Spawning %s...", options.gdb)
p = subprocess.Popen([options.gdb, '-command', tempfilename] + gdb_argv) p = subprocess.Popen([options.gdb, '-command', tempfilename] + gdb_argv)
logger.info("Spawned %s (pid %d)", options.gdb, p.pid) logger.info("Spawned %s (pid %d)", options.gdb, p.pid)
...@@ -151,6 +152,8 @@ def main(path_to_debug_info=None, gdb_argv=None, no_import=False): ...@@ -151,6 +152,8 @@ def main(path_to_debug_info=None, gdb_argv=None, no_import=False):
pass pass
else: else:
break break
logger.debug("Closing temp command file with fd: %s", tempfile_fd)
tempfile_fd.close()
logger.debug("Removing temp command file: %s", tempfilename) logger.debug("Removing temp command file: %s", tempfilename)
os.remove(tempfilename) os.remove(tempfilename)
logger.debug("Removed temp command file: %s", tempfilename) logger.debug("Removed temp command file: %s", tempfilename)
...@@ -18,6 +18,13 @@ import collections ...@@ -18,6 +18,13 @@ import collections
import gdb import gdb
try: # py3k
UNICODE = unicode
BYTES = str
except NameError: # py2k
UNICODE = str
BYTES = bytes
try: try:
from lxml import etree from lxml import etree
have_lxml = True have_lxml = True
...@@ -689,7 +696,8 @@ class CyImport(CythonCommand): ...@@ -689,7 +696,8 @@ class CyImport(CythonCommand):
completer_class = gdb.COMPLETE_FILENAME completer_class = gdb.COMPLETE_FILENAME
def invoke(self, args, from_tty): def invoke(self, args, from_tty):
args = args.encode(_filesystemencoding) if isinstance(args, BYTES):
args = args.decode(_filesystemencoding)
for arg in string_to_argv(args): for arg in string_to_argv(args):
try: try:
f = open(arg) f = open(arg)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment