KeyError (macro does not exist)

Issue #20 resolved
Reynold Xin created an issue

I have the following bibtex entry without aij defined as a macro string.

@​Article{Boutilier:AIJ98 , url = {belchange.pdf}, author = "Craig Boutilier", title = "A Unified Model of Qualitative Belief Change: A Dynamical Systems Perspective", journal = aij, volume = "98", number = "1--2", pages = "281--316", year = "1998"}

When Pybtex is used to parse the bibtex file, Python error occurs: KeyError 'aij'

The fix is to check whether a macro exists before substituting it:

def substitute_macro(self, s, loc, toks): if toks[0].lower() in self.macros: return self.macros[toks[0].lower()] else: return toks[0]

Comments (2)

  1. Andrey Golovizin

    Thanks, fixed in trunk. A proper error message is now displayed in case of an undefined macro.

  2. Log in to comment