MCPcopy Index your code
hub / github.com/secdev/scapy / bytes_encode

Function bytes_encode

scapy/compat.py:126–134  ·  view source on GitHub ↗

Ensure that the given object is bytes. If the parameter is a packet, raw() should be preferred.

(x)

Source from the content-addressed store, hash-verified

124
125
126def 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
137def plain_str(x):

Callers 15

inet_ntopFunction · 0.90
__bytes__Method · 0.90
__bytes__Method · 0.90
__init__Method · 0.90
__bytes__Method · 0.90
hexdumpFunction · 0.90
chexdumpFunction · 0.90
hexstrFunction · 0.90
hexdiffFunction · 0.90
do_graphFunction · 0.90
__bytes__Method · 0.90
corrupt_bytesFunction · 0.90

Calls 1

encodeMethod · 0.80

Tested by

no test coverage detected