mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-02 21:28:18 +00:00
Add parameter back to EndVector (#7246)
This commit is contained in:
@@ -23,6 +23,8 @@ from .compat import range_func
|
|||||||
from .compat import memoryview_type
|
from .compat import memoryview_type
|
||||||
from .compat import import_numpy, NumpyRequiredForThisFeature
|
from .compat import import_numpy, NumpyRequiredForThisFeature
|
||||||
|
|
||||||
|
import warnings
|
||||||
|
|
||||||
np = import_numpy()
|
np = import_numpy()
|
||||||
## @file
|
## @file
|
||||||
## @addtogroup flatbuffers_python_api
|
## @addtogroup flatbuffers_python_api
|
||||||
@@ -75,6 +77,13 @@ class BuilderNotFinishedError(RuntimeError):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class EndVectorLengthMismatched(RuntimeError):
|
||||||
|
"""
|
||||||
|
The number of elements passed to EndVector does not match the number
|
||||||
|
specified in StartVector.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
# VtableMetadataFields is the count of metadata fields in each vtable.
|
# VtableMetadataFields is the count of metadata fields in each vtable.
|
||||||
VtableMetadataFields = 2
|
VtableMetadataFields = 2
|
||||||
@@ -377,13 +386,20 @@ class Builder(object):
|
|||||||
return self.Offset()
|
return self.Offset()
|
||||||
## @endcond
|
## @endcond
|
||||||
|
|
||||||
def EndVector(self):
|
def EndVector(self, numElems = None):
|
||||||
"""EndVector writes data necessary to finish vector construction."""
|
"""EndVector writes data necessary to finish vector construction."""
|
||||||
|
|
||||||
self.assertNested()
|
self.assertNested()
|
||||||
## @cond FLATBUFFERS_INTERNAL
|
## @cond FLATBUFFERS_INTERNAL
|
||||||
self.nested = False
|
self.nested = False
|
||||||
## @endcond
|
## @endcond
|
||||||
|
|
||||||
|
if numElems:
|
||||||
|
warnings.warn("numElems is deprecated.",
|
||||||
|
DeprecationWarning, stacklevel=2)
|
||||||
|
if numElems != self.vectorNumElems:
|
||||||
|
raise EndVectorLengthMismatched();
|
||||||
|
|
||||||
# we already made space for this, so write without PrependUint32
|
# we already made space for this, so write without PrependUint32
|
||||||
self.PlaceUOffsetT(self.vectorNumElems)
|
self.PlaceUOffsetT(self.vectorNumElems)
|
||||||
self.vectorNumElems = None
|
self.vectorNumElems = None
|
||||||
|
|||||||
Reference in New Issue
Block a user