# Buggy code
def aslist(value):
    """Cast config values to lists of strings"""
    return [item.strip() for item in value.strip().split(",")]


# Traceback (jinja2.exceptions.TemplateSyntaxError)
Traceback (most recent call last):
File "/usr/local/bin/bugwarrior-pull", line 11, in <module>
sys.exit(pull())
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/bugwarrior/command.py", line 73, in pull
synchronize(issue_generator, config, main_section, dry_run)
File "/usr/local/lib/python3.6/site-packages/bugwarrior/db.py", line 330, in synchronize
issue_dict = dict(issue)
File "/usr/local/lib/python3.6/site-packages/bugwarrior/services/__init__.py", line 416, in keys
return list(self.__iter__())
File "/usr/local/lib/python3.6/site-packages/bugwarrior/services/__init__.py", line 411, in __iter__
record = self.get_taskwarrior_record()
File "/usr/local/lib/python3.6/site-packages/bugwarrior/services/__init__.py", line 319, in get_taskwarrior_record
record['tags'].extend(self.get_added_tags())
File "/usr/local/lib/python3.6/site-packages/bugwarrior/services/__init__.py", line 304, in get_added_tags
tag = Template(tag).render(self.get_template_context())
File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 945, in __new__
return env.from_string(source, template_class=cls)
File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 880, in from_string
return cls.from_code(self, self.compile(source), globals, None)
File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 591, in compile
self.handle_exception(exc_info, source_hint=source_hint)
File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "<unknown>", line 1, in template
File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 497, in _parse
return Parser(self, source, name, encode_filename(filename)).parse()
File "/usr/local/lib/python3.6/site-packages/jinja2/parser.py", line 901, in parse
result = nodes.Template(self.subparse(), lineno=1)
File "/usr/local/lib/python3.6/site-packages/jinja2/parser.py", line 874, in subparse
next(self.stream)
File "/usr/local/lib/python3.6/site-packages/jinja2/lexer.py", line 359, in __next__
self.current = next(self._iter)
File "/usr/local/lib/python3.6/site-packages/jinja2/lexer.py", line 562, in wrap
for lineno, token, value in stream:
File "/usr/local/lib/python3.6/site-packages/jinja2/lexer.py", line 739, in tokeniter
name, filename)
jinja2.exceptions.TemplateSyntaxError: unexpected char "'" at 5

# Fixed code
def aslist(value):
    """Cast config values to lists of strings"""
    return [item.strip() for item in re.split(",(?![^{]*})", value.strip())]