Skip to content

Commit

Permalink
Adds support of empty string field_name. (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheqianh committed Mar 4, 2021
1 parent f8c61fb commit a203255
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion amazon/ion/writer_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def intern_symbol(sym):
def intern_symbols(event):
field_name = event.field_name
annotations = event.annotations
if field_name:
if field_name or field_name == '':
event = event.derive_field_name(intern_symbol(field_name))
if annotations:
event = event.derive_annotations(
Expand Down
12 changes: 12 additions & 0 deletions tests/test_simpleion.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ def bytes_of(*args, **kwargs):
[IonPyDict.from_value(IonType.STRUCT, {}), ],
_Expected(b'\xD0', b'{}')
),
(
[{u'': u''}, ],
_Expected(
bytes_of([
0xDE, # The lower nibble may vary. It does not indicate actual length unless it's 0.
VARUINT_END_BYTE | 2, # Field name 10 and value 0 each fit in 1 byte.
VARUINT_END_BYTE | 10,
0x80 # Empty string
]),
b"{'':\"\"}"
)
),
(
[{u'foo': 0}, ],
_Expected(
Expand Down

0 comments on commit a203255

Please sign in to comment.