Skip to content

b1223

@maxjacobson maxjacobson tagged this 12 Jun 20:29
What happens is that we try to cast this business from the AST to JSON,
which does not work. In python 2, it's just treated like a regular
string. But in python 3, we recognize that it is a bytes literal.

This implemention casts the bytes literal to a string, which is a type
that is serialiable to JSON:

```
>>> (b'hello').decode()
'hello'
```

This will default to utf8, and generally works, although it's possible
sometimes it will not work if the source file is encoded differently.

https://docs.python.org/3/library/stdtypes.html#bytes.decode

An alternative is to cast it to an array of integers, which would also
work for structural-comparison purposes:

```
>>> list(b'hello')
[104, 101, 108, 108, 111]
```
Assets 2
Loading