mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-26 12:02:40 +00:00
Merge pull request #286 from tguo-aa/fix-278
Add self.assertNotNested() in CreateString
This commit is contained in:
@@ -350,6 +350,8 @@ class Builder(object):
|
|||||||
def CreateString(self, s):
|
def CreateString(self, s):
|
||||||
"""CreateString writes a null-terminated byte string as a vector."""
|
"""CreateString writes a null-terminated byte string as a vector."""
|
||||||
|
|
||||||
|
self.assertNotNested()
|
||||||
|
|
||||||
if isinstance(s, compat.string_types):
|
if isinstance(s, compat.string_types):
|
||||||
x = s.encode()
|
x = s.encode()
|
||||||
elif isinstance(s, compat.binary_type):
|
elif isinstance(s, compat.binary_type):
|
||||||
|
|||||||
@@ -1130,6 +1130,13 @@ class TestExceptions(unittest.TestCase):
|
|||||||
assertRaises(self, lambda: b.PrependUOffsetTRelative(1),
|
assertRaises(self, lambda: b.PrependUOffsetTRelative(1),
|
||||||
flatbuffers.builder.OffsetArithmeticError)
|
flatbuffers.builder.OffsetArithmeticError)
|
||||||
|
|
||||||
|
def test_create_string_is_nested_error(self):
|
||||||
|
b = flatbuffers.Builder(0)
|
||||||
|
b.StartObject(0)
|
||||||
|
s = 'test1'
|
||||||
|
assertRaises(self, lambda: b.CreateString(s),
|
||||||
|
flatbuffers.builder.ObjectIsNestedError)
|
||||||
|
|
||||||
|
|
||||||
def CheckAgainstGoldDataGo():
|
def CheckAgainstGoldDataGo():
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user