Unverified Commit c57e97df by Victor M. Alvarez Committed by GitHub

Fix issue #136 for Python 2.7 too. (#140)

parent bc4e0cdb
......@@ -695,13 +695,13 @@ class TestYara(unittest.TestCase):
def testMeta(self):
r = yara.compile(source=r'rule test { meta: a = "foo\x80bar" condition: true }')
self.assertTrue(list(r)[0].meta['a'] == 'foobar')
self.assertTrue((list(r)[0].meta['a']) == 'foobar')
# This test ensures that anything after the NULL character is stripped.
def testMetaNull(self):
r = yara.compile(source=r'rule test { meta: a = "foo\x00bar\x80" condition: true }')
self.assertTrue(list(r)[0].meta['a'] == 'foo')
self.assertTrue((list(r)[0].meta['a']) == 'foo')
# This test is similar to testMeta but it tests the meta data generated
# when a Match object is created.
......@@ -709,7 +709,7 @@ class TestYara(unittest.TestCase):
r = yara.compile(source=r'rule test { meta: a = "foo\x80bar" condition: true }')
m = r.match(data='dummy')
self.assertTrue(list(m)[0].meta['a'] == 'foobar')
self.assertTrue((list(m)[0].meta['a']) == 'foobar')
def testFilesize(self):
......
yara @ b15d6bb0
Subproject commit 60034b7e1929695c86a541a224e579ff8b79f75c
Subproject commit b15d6bb0568fc77923e6149322e6d63a8b2007b6
......@@ -50,7 +50,7 @@ typedef long Py_hash_t;
#define PY_STRING_TO_C(x) PyUnicode_AsUTF8(x)
#define PY_STRING_CHECK(x) PyUnicode_Check(x)
#else
#define PY_STRING(x) PyString_FromString(x)
#define PY_STRING(x) PyString_Decode(x, strlen(x), "utf-8", "ignore")
#define PY_STRING_TO_C(x) PyString_AsString(x)
#define PY_STRING_CHECK(x) (PyString_Check(x) || PyUnicode_Check(x))
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment