MCPcopy Index your code
hub / github.com/python/cpython / stn

Function stn

Lib/tarfile.py:156–162  ·  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

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

Callers 1

_create_headerMethod · 0.85

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected