diff --git a/gramps/gen/display/name.py b/gramps/gen/display/name.py index 506c97b8b79..95c541aa771 100644 --- a/gramps/gen/display/name.py +++ b/gramps/gen/display/name.py @@ -756,7 +756,7 @@ def _gen_cooked_func(self, format_str): The new function is of the form:: - def fn(first, raw_surname_list, suffix, title, call,): + def fn(first, raw_surname_list, suffix, title, call, nick, famnick): return "%s %s" % (first,suffix) Specific symbols for parts of a name are defined (keywords given): @@ -1179,8 +1179,7 @@ def name_grouping_data(self, db, pn): def _make_fn(self, format_str, d, args): """ - Create the name display function and handles dependent - punctuation. + Create the name display function and handles dependent punctuation. """ # d is a dict: dict[code] = (expr, word, translated word) @@ -1288,18 +1287,17 @@ def ifNotEmpty(str,p,s): ",".join(param), ) try: - exec(s) in globals(), locals() - return locals()["fn"] - except: + result = {} + exec(s, globals(), result) + return result["fn"] + except SyntaxError: LOG.error( - "\n" - + "Wrong name format string %s" % new_fmt - + "\n" - + ("ERROR, Edit Name format in Preferences->Display to correct") - + "\n" - + _("Wrong name format string %s") % new_fmt - + "\n" - + ("ERROR, Edit Name format in Preferences->Display to correct") + "Wrong name format string %s\n" + "ERROR, Edit Name format in Preferences->Display to correct\n" + + _("Wrong name format string %s") + + "\nERROR, Edit Name format in Preferences->Display to correct", + new_fmt, + new_fmt, ) def errfn(*arg):