Skip to content

Instantly share code, notes, and snippets.

@drdavella
Last active January 25, 2018 22:29
Show Gist options
  • Save drdavella/18aae94198383e6ef4846c5dc7d1390f to your computer and use it in GitHub Desktop.
Save drdavella/18aae94198383e6ef4846c5dc7d1390f to your computer and use it in GitHub Desktop.
Simple reproducer for transient ASDF bug
#!/usr/bin/env python
import asdf
from astropy import units as u
from astropy.coordinates.representation import SphericalRepresentation
tree = {'coord': SphericalRepresentation(10*u.deg, 10*u.deg, 1*u.m)}
print('distance:', tree['coord'].distance)
with asdf.AsdfFile(tree=tree) as ff:
ff.write_to("test.asdf")
with open('test.asdf', 'rb') as ff:
data = ff.read()
try:
print(data.decode('ascii'))
except UnicodeDecodeError:
index = data.find(b'\xd3BLK')
print(data[:index].decode('ascii'))
print(data[index:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment