Ensuring we are serializing real Python objects

Trying to json.dump Vim dictionaries fails.
This commit is contained in:
Strahinja Val Markovic 2013-10-06 18:26:59 -07:00
parent 60aa5581c1
commit f0c9878f87
2 changed files with 5 additions and 2 deletions

View File

@ -41,7 +41,7 @@ def BuildServerConf():
"""Builds a dictionary mapping YCM Vim user options to values. Option names
don't have the 'ycm_' prefix."""
vim_globals = vimsupport.GetReadOnlyVimGlobals()
vim_globals = vimsupport.GetReadOnlyVimGlobals( force_python_objects = True )
server_conf = {}
for key, value in vim_globals.items():
if not key.startswith( YCM_VAR_PREFIX ):

View File

@ -95,7 +95,10 @@ def LoadDictIntoVimGlobals( new_globals, overwrite = True ):
# Changing the returned dict will NOT change the value in Vim.
def GetReadOnlyVimGlobals():
def GetReadOnlyVimGlobals( force_python_objects = False ):
if force_python_objects:
return vim.eval( 'g:' )
try:
# vim.vars is fairly new so it might not exist
return vim.vars