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

Method fold_binary

Lib/email/policy.py:193–209  ·  view source on GitHub ↗

+ The same as fold if cte_type is 7bit, except that the returned value is bytes. If cte_type is 8bit, non-ASCII binary data is converted back into bytes. Headers with binary data are not refolded, regardless of the refold_header setting, since there is no wa

(self, name, value)

Source from the content-addressed store, hash-verified

191 return self._fold(name, value, refold_binary=True)
192
193 def fold_binary(self, name, value):
194 """+
195 The same as fold if cte_type is 7bit, except that the returned value is
196 bytes.
197
198 If cte_type is 8bit, non-ASCII binary data is converted back into
199 bytes. Headers with binary data are not refolded, regardless of the
200 refold_header setting, since there is no way to know whether the binary
201 data consists of single byte characters or multibyte characters.
202
203 If utf8 is true, headers are encoded to utf8, otherwise to ascii with
204 non-ASCII unicode rendered as encoded words.
205
206 """
207 folded = self._fold(name, value, refold_binary=self.cte_type=='7bit')
208 charset = 'utf8' if self.utf8 else 'ascii'
209 return folded.encode(charset, 'surrogateescape')
210
211 def _fold(self, name, value, refold_binary=False):
212 if hasattr(value, 'name'):

Callers 1

_write_headersMethod · 0.45

Calls 2

_foldMethod · 0.95
encodeMethod · 0.45

Tested by

no test coverage detected