# Buggy code
def decode_match(match):
    return codecs.decode(match.group(0), "unicode_escape")


# Traceback (ValueError)
tansell@tansell:~/github/mesonbuild/meson/test cases/common/100 print null$ meson build .
The Meson build system
Version: 0.45.0.dev1
Source dir: XXXX/github/mesonbuild/meson/test cases/common/100 print null
Build dir: XXXX/github/mesonbuild/meson/test cases/common/100 print null/build
Build type: native build
Project name: 100 print null
Build machine cpu family: x86_64
Build machine cpu: x86_64
Program find found: YES (/usr/bin/find)
Traceback (most recent call last):
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line
363, in run
app.generate()
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line
150, in generate
self._generate(env)
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line
197, in _generate
intr.run()
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 2992, in run
super().run()
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 173, in run
self.evaluate_codeblock(self.ast, start=1)
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 195, in evaluate_codeblock
raise e
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 189, in evaluate_codeblock
self.evaluate_statement(cur)
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 230, in evaluate_statement
return self.evaluate_foreach(cur)
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 404, in evaluate_foreach
self.evaluate_codeblock(node.block)
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 195, in evaluate_codeblock
raise e
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 189, in evaluate_codeblock
self.evaluate_statement(cur)
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 232, in evaluate_statement
return self.evaluate_plusassign(cur)
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 409, in evaluate_plusassign
addition = self.evaluate_statement(node.value)
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 216, in evaluate_statement
return self.evaluate_arraystatement(cur)
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 243, in evaluate_arraystatement
(arguments, kwargs) = self.reduce_arguments(cur.args)
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 640, in reduce_arguments
reduced_pos = [self.evaluate_statement(arg) for arg in args.arguments]
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 640, in <listcomp>
reduced_pos = [self.evaluate_statement(arg) for arg in args.arguments]
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 200, in evaluate_statement
return self.function_call(cur)
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 456, in function_call
return self.funcs[func_name](node, self.flatten(posargs), kwargs)
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 55, in wrapped
return f(self, node, args, kwargs)
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 47, in wrapped
return f(self, node, args, kwargs)
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1614, in func_files
return [mesonlib.File.from_source_file(self.environment.source_dir, self.subdir, fname) for fname in
args]
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1614, in <listcomp>
return [mesonlib.File.from_source_file(self.environment.source_dir, self.subdir, fname) for fname in
args]
File "XXXX/.local/lib/python3.5/site-packages/mesonbuild/mesonlib.py", line 230, in from_source_file
if not os.path.isfile(os.path.join(source_root, subdir, fname)):
File "/usr/lib/python3.5/genericpath.py", line 30, in isfile
st = os.stat(path)
ValueError: embedded null byte

# Fixed code
def decode_match(match):
    try:
        return codecs.decode(match.group(0), "unicode_escape")
    except UnicodeDecodeError as err:
        raise MesonUnicodeDecodeError(match.group(0))