Skip to content

Instantly share code, notes, and snippets.

@strazzere
Created August 20, 2015 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save strazzere/063b03c0378788e23420 to your computer and use it in GitHub Desktop.
Save strazzere/063b03c0378788e23420 to your computer and use it in GitHub Desktop.
diff --git a/pfp/fields.py b/pfp/fields.py
index cf4ee31..77da4eb 100644
--- a/pfp/fields.py
+++ b/pfp/fields.py
@@ -1720,7 +1720,7 @@ class String(Field):
:returns: TODO
"""
- if isinstance(other, String):
+ if isinstance(other, str):
self._pfp__value += other._pfp__value
else:
self._pfp__value += PYSTR(other)
diff --git a/tests/test_fields.py b/tests/test_fields.py
index 0d5ca77..74b5726 100644
--- a/tests/test_fields.py
+++ b/tests/test_fields.py
@@ -80,6 +80,26 @@ class TestNumericFields(unittest.TestCase, utils.UtilsMixin):
""",
stdout="9894494448401390090"
)
+
+ # temp_char ends up being of class Bytes in python 3 - but not on python 2
+ # This test ensures we can handle adding both a String and byte together
+ def test_add_strings(self):
+ dom = self._test_parse_build(
+ "\x01\x02\x03\x04\x05",
+ """
+ local string temp_expected, temp_char;
+ local int i;
+ for(i = 0; i < 5; i++) {
+ SPrintf(temp_char, "%.2X", ReadUByte(FTell()+i));
+ temp_expected += temp_char;
+ }
+ Printf("%s", temp_expected);
+ """,
+ "0102030405",
+ False,
+ False,
+ False
+ )
if __name__ == "__main__":
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment