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

Function set_bytes_content

Lib/email/contentmanager.py:219–238  ·  view source on GitHub ↗
(msg, data, maintype, subtype, cte='base64',
                     disposition=None, filename=None, cid=None,
                     params=None, headers=None)

Source from the content-addressed store, hash-verified

217
218
219def set_bytes_content(msg, data, maintype, subtype, cte='base64',
220 disposition=None, filename=None, cid=None,
221 params=None, headers=None):
222 _prepare_set(msg, maintype, subtype, headers)
223 if cte == 'base64':
224 data = binascii.b2a_base64(data, wrapcol=msg.policy.max_line_length)
225 data = data.decode('ascii')
226 elif cte == 'quoted-printable':
227 # XXX: quoprimime.body_encode won't encode newline characters in data,
228 # so we can't use it. This means max_line_length is ignored. Another
229 # bug to fix later. (Note: encoders.quopri is broken on line ends.)
230 data = binascii.b2a_qp(data, istext=False, header=False, quotetabs=True)
231 data = data.decode('ascii')
232 elif cte == '7bit':
233 data = data.decode('ascii')
234 elif cte in ('8bit', 'binary'):
235 data = data.decode('ascii', 'surrogateescape')
236 msg.set_payload(data)
237 msg['Content-Transfer-Encoding'] = cte
238 _finalize_set(msg, disposition, filename, cid, params)
239for typ in (bytes, bytearray, memoryview):
240 raw_data_manager.add_set_handler(typ, set_bytes_content)
241del typ

Callers

nothing calls this directly

Calls 4

_prepare_setFunction · 0.85
_finalize_setFunction · 0.85
set_payloadMethod · 0.80
decodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…