MCPcopy Index your code
hub / github.com/RustPython/RustPython / stn

Function stn

Lib/tarfile.py:157–163  ·  view source on GitHub ↗

Convert a string to a null-terminated bytes object.

(s, length, encoding, errors)

Source from the content-addressed store, hash-verified

155#---------------------------------------------------------
156
157def stn(s, length, encoding, errors):
158 """Convert a string to a null-terminated bytes object.
159 """
160 if s is None:
161 raise ValueError("metadata cannot contain None")
162 s = s.encode(encoding, errors)
163 return s[:length] + (length - len(s)) * NUL
164
165def nts(s, encoding, errors):
166 """Convert a null-terminated bytes object to a string.

Callers 1

_create_headerMethod · 0.85

Calls 2

lenFunction · 0.85
encodeMethod · 0.45

Tested by

no test coverage detected