I think here one should add
`assert eval(repr_x) == x`

Given that the `bytes_x` round-trips, it should always be possible to design a `repr` that round-trips as well.

If so, the `if` statement right below here could probably become an `elif` 

(Of course, the same changes could be made further down, for the pretty-print case).