Add additional asserts to utils.read_file

See #4576
This commit is contained in:
Florian Bruhin 2019-02-16 00:23:52 +01:00
parent ac1e8a4efe
commit 6ca6271170

View File

@ -30,6 +30,7 @@ import datetime
import traceback import traceback
import functools import functools
import contextlib import contextlib
import posixpath
import socket import socket
import shlex import shlex
import glob import glob
@ -165,6 +166,9 @@ def read_file(filename, binary=False):
Return: Return:
The file contents as string. The file contents as string.
""" """
assert not posixpath.isabs(filename), filename
assert os.path.pardir not in filename.split(posixpath.sep), filename
if not binary and filename in _resource_cache: if not binary and filename in _resource_cache:
return _resource_cache[filename] return _resource_cache[filename]