ion-python icon indicating copy to clipboard operation
ion-python copied to clipboard

Raw Binary Writer Should Support VERSION_MARKER Events

Open almann opened this issue 8 years ago • 0 comments

Writing a core.ION_VERSION_MARKER_EVENT fails on the raw writer:

>>> from amazon.ion import *
>>> import io
>>> w = writer.blocking_writer(writer_binary_raw._raw_binary_writer(writer_buffer.BufferTree()), io.BytesIO())
>>> w.send(core.ION_VERSION_MARKER_EVENT)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    w.send(core.ION_VERSION_MARKER_EVENT)
  File "/usr/local/lib/python3.6/site-packages/amazon/ion/writer.py", line 150, in blocking_writer
    for result_event in _drain(writer, ion_event):
  File "/usr/local/lib/python3.6/site-packages/amazon/ion/writer.py", line 129, in _drain
    result_event = writer.send(ion_event)
  File "/usr/local/lib/python3.6/site-packages/amazon/ion/writer.py", line 111, in writer_trampoline
    trans = trans.delegate.send(Transition(ion_event, trans.delegate))
  File "/usr/local/lib/python3.6/site-packages/amazon/ion/writer_binary_raw.py", line 393, in _raw_writer_coroutine
    fail()
  File "/usr/local/lib/python3.6/site-packages/amazon/ion/writer_binary_raw.py", line 351, in fail
    raise TypeError('Invalid event: %s at depth %d' % (ion_event, depth))
TypeError: Invalid event: IonEvent(event_type=<IonEventType.VERSION_MARKER: 0>, ion_type=None, value=(1, 0), field_name=None, annotations=(), depth=0) at depth 
0

Looking more closely, it appears that the managed writer explicitly writes the IVM which is in correct, the managed writer should propagate the IVM event to the raw writer, and that should emit the byte sequence.

almann avatar Nov 16 '17 22:11 almann