Bug 1293534: Fix .ycm_extra_conf after bug 1195748. r?gps draft
authorEmilio Cobos Álvarez <ecoal95@gmail.com>
Mon, 08 Aug 2016 21:00:20 -0700
changeset 398422 e97b7384303c0d3671e3b0e78df6d58c4cda08db
parent 397963 23ae272255ec2ef495f06c95c7fff29c36a65d33
child 527656 7cb19a3eda98124ddd500f7559a3d2245ca97430
push id25525
push userbmo:ealvarez@mozilla.com
push dateTue, 09 Aug 2016 04:40:42 +0000
reviewersgps
bugs1293534, 1195748
milestone51.0a1
Bug 1293534: Fix .ycm_extra_conf after bug 1195748. r?gps MozReview-Commit-ID: HwNnOUThxev
.ycm_extra_conf.py
--- a/.ycm_extra_conf.py
+++ b/.ycm_extra_conf.py
@@ -22,16 +22,20 @@ if not os.path.exists(path):
     path = os.path.join(config.topsrcdir, 'mach')
 mach_module = imp.load_module('_mach', open(path), path, ('', 'r', imp.PY_SOURCE))
 
 sys.dont_write_bytecode = old_bytecode
 
 def FlagsForFile(filename):
     mach = mach_module.get_mach()
     out = StringIO()
+
+    # Mach calls sys.stdout.fileno(), so we need to fake it when capturing it.
+    # Returning an invalid file descriptor does the trick.
+    out.fileno = lambda: -1
     out.encoding = None
     mach.run(['compileflags', filename], stdout=out, stderr=out)
 
     flag_list = shlex.split(out.getvalue())
 
     # This flag is added by Fennec for android build and causes ycmd to fail to parse the file.
     # Removing this flag is a workaround until ycmd starts to handle this flag properly.
     # https://github.com/Valloric/YouCompleteMe/issues/1490