[Piglit] [PATCH 4/4] grouptools.py: Don't allow non-string arguments
Dylan Baker
baker.dylan.c at gmail.com
Wed Dec 31 16:21:58 PST 2014
Since we want to do string operations on the inputs to the various
grouptools modules assert that the inputs are in fact strings not other
things.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
framework/grouptools.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/framework/grouptools.py b/framework/grouptools.py
index 74b75a3..7a7a127 100644
--- a/framework/grouptools.py
+++ b/framework/grouptools.py
@@ -44,6 +44,7 @@ __all__ = [
def _assert_illegal(group):
"""Helper that checks for illegal characters in input."""
+ assert isinstance(group, (str, unicode)), 'Type must be string or unicode'
assert '\\' not in group, \
'Groups are not paths and cannot contain \\. ({})'.format(group)
assert not group.startswith('/'), \
@@ -103,6 +104,8 @@ def join(*args):
"""
for group in args:
+ assert isinstance(group, (str, unicode)), \
+ 'Type must be string or unicode'
assert '\\' not in group, \
'Groups are not paths and cannot contain \\. ({})'.format(group)
assert not args[0].startswith('/'), \
@@ -149,6 +152,7 @@ def from_path(path):
This safely handles both Windows and Unix style paths.
"""
+ assert isinstance(path, (str, unicode)), 'Type must be string or unicode'
assert not path.startswith('/'), \
'Groups cannot start with /. ({})' .format(path)
--
2.2.1
More information about the Piglit
mailing list