1
0
forked from aniani/vim

updated for version 7.3.1068

Problem:    Python: Script is auto-loaded on function creation.
Solution:   Python patch 27. (ZyX)
This commit is contained in:
Bram Moolenaar
2013-05-30 13:37:28 +02:00
parent 305b2fde13
commit 018acca3bd
7 changed files with 14 additions and 19 deletions

View File

@@ -810,6 +810,7 @@ static int
# endif # endif
prof_self_cmp __ARGS((const void *s1, const void *s2)); prof_self_cmp __ARGS((const void *s1, const void *s2));
#endif #endif
static int script_autoload __ARGS((char_u *name, int reload));
static char_u *autoload_name __ARGS((char_u *name)); static char_u *autoload_name __ARGS((char_u *name));
static void cat_func_name __ARGS((char_u *buf, ufunc_T *fp)); static void cat_func_name __ARGS((char_u *buf, ufunc_T *fp));
static void func_free __ARGS((ufunc_T *fp)); static void func_free __ARGS((ufunc_T *fp));
@@ -829,10 +830,6 @@ static int compare_func_name __ARGS((const void *s1, const void *s2));
static void sortFunctions __ARGS(()); static void sortFunctions __ARGS(());
#endif #endif
/* Character used as separated in autoload function/variable names. */
#define AUTOLOAD_CHAR '#'
/* /*
* Initialize the global and v: variables. * Initialize the global and v: variables.
*/ */
@@ -22190,7 +22187,7 @@ prof_self_cmp(s1, s2)
* If "name" has a package name try autoloading the script for it. * If "name" has a package name try autoloading the script for it.
* Return TRUE if a package was loaded. * Return TRUE if a package was loaded.
*/ */
int static int
script_autoload(name, reload) script_autoload(name, reload)
char_u *name; char_u *name;
int reload; /* load script again when already loaded */ int reload; /* load script again when already loaded */

View File

@@ -2015,19 +2015,13 @@ FunctionNew(PyTypeObject *subtype, char_u *name)
func_ref(self->name); func_ref(self->name);
} }
else else
{ if ((self->name = get_expanded_name(name,
self->name = get_expanded_name(name, TRUE); vim_strchr(name, AUTOLOAD_CHAR) == NULL))
if (self->name == NULL) == NULL)
{ {
if (script_autoload(name, TRUE) && !aborting()) PyErr_SetString(PyExc_ValueError, _("function does not exist"));
self->name = get_expanded_name(name, TRUE); return NULL;
if (self->name == NULL)
{
PyErr_SetString(PyExc_ValueError, _("function does not exist"));
return NULL;
}
} }
}
return (PyObject *)(self); return (PyObject *)(self);
} }

View File

@@ -132,5 +132,4 @@ void last_set_msg __ARGS((scid_T scriptID));
void ex_oldfiles __ARGS((exarg_T *eap)); void ex_oldfiles __ARGS((exarg_T *eap));
int modify_fname __ARGS((char_u *src, int *usedlen, char_u **fnamep, char_u **bufp, int *fnamelen)); int modify_fname __ARGS((char_u *src, int *usedlen, char_u **fnamep, char_u **bufp, int *fnamelen));
char_u *do_string_sub __ARGS((char_u *str, char_u *pat, char_u *sub, char_u *flags)); char_u *do_string_sub __ARGS((char_u *str, char_u *pat, char_u *sub, char_u *flags));
int script_autoload __ARGS((char_u *name, int reload));
/* vim: set ft=c : */ /* vim: set ft=c : */

View File

@@ -889,7 +889,7 @@ l.xxx = True:(<type 'exceptions.AttributeError'>, AttributeError('cannot set thi
>> FunctionConstructor >> FunctionConstructor
vim.Function("123"):(<type 'exceptions.ValueError'>, ValueError('unnamed function does not exist',)) vim.Function("123"):(<type 'exceptions.ValueError'>, ValueError('unnamed function does not exist',))
vim.Function("xxx_non_existent_function_xxx"):(<type 'exceptions.ValueError'>, ValueError('function does not exist',)) vim.Function("xxx_non_existent_function_xxx"):(<type 'exceptions.ValueError'>, ValueError('function does not exist',))
vim.Function("xxx#non#existent#function#xxx"):(<type 'exceptions.ValueError'>, ValueError('function does not exist',)) vim.Function("xxx#non#existent#function#xxx"):NOT FAILED
>> FunctionCall >> FunctionCall
>>> Testing StringToChars using f({%s : 1}) >>> Testing StringToChars using f({%s : 1})
f({1 : 1}):(<type 'exceptions.TypeError'>, TypeError('object must be string',)) f({1 : 1}):(<type 'exceptions.TypeError'>, TypeError('object must be string',))

View File

@@ -878,7 +878,7 @@ l.xxx = True:(<class 'AttributeError'>, AttributeError('cannot set this attribut
>> FunctionConstructor >> FunctionConstructor
vim.Function("123"):(<class 'ValueError'>, ValueError('unnamed function does not exist',)) vim.Function("123"):(<class 'ValueError'>, ValueError('unnamed function does not exist',))
vim.Function("xxx_non_existent_function_xxx"):(<class 'ValueError'>, ValueError('function does not exist',)) vim.Function("xxx_non_existent_function_xxx"):(<class 'ValueError'>, ValueError('function does not exist',))
vim.Function("xxx#non#existent#function#xxx"):(<class 'ValueError'>, ValueError('function does not exist',)) vim.Function("xxx#non#existent#function#xxx"):NOT FAILED
>> FunctionCall >> FunctionCall
>>> Testing StringToChars using f({%s : 1}) >>> Testing StringToChars using f({%s : 1})
f({1 : 1}):(<class 'TypeError'>, TypeError('object must be string',)) f({1 : 1}):(<class 'TypeError'>, TypeError('object must be string',))

View File

@@ -728,6 +728,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1068,
/**/ /**/
1067, 1067,
/**/ /**/

View File

@@ -2243,4 +2243,7 @@ typedef int VimClipboard; /* This is required for the prototypes. */
#define SREQ_WIN 1 /* Request window-local option */ #define SREQ_WIN 1 /* Request window-local option */
#define SREQ_BUF 2 /* Request buffer-local option */ #define SREQ_BUF 2 /* Request buffer-local option */
/* Character used as separated in autoload function/variable names. */
#define AUTOLOAD_CHAR '#'
#endif /* VIM__H */ #endif /* VIM__H */