Ensure that the given object is bytes. If the parameter is a packet, raw() should be preferred.
(x)
| 124 | |
| 125 | |
| 126 | def bytes_encode(x): |
| 127 | # type: (Any) -> bytes |
| 128 | """Ensure that the given object is bytes. If the parameter is a |
| 129 | packet, raw() should be preferred. |
| 130 | |
| 131 | """ |
| 132 | if isinstance(x, str): |
| 133 | return x.encode() |
| 134 | return bytes(x) |
| 135 | |
| 136 | |
| 137 | def plain_str(x): |
no test coverage detected