MCPcopy
hub / github.com/scrapy/scrapy / _tobytes

Method _tobytes

scrapy/http/headers.py:61–68  ·  view source on GitHub ↗
(self, x: _RawValue)

Source from the content-addressed store, hash-verified

59 return [self._tobytes(x) for x in _value]
60
61 def _tobytes(self, x: _RawValue) -> bytes:
62 if isinstance(x, bytes):
63 return x
64 if isinstance(x, str):
65 return x.encode(self.encoding)
66 if isinstance(x, int):
67 return str(x).encode(self.encoding)
68 raise TypeError(f"Unsupported value type: {type(x)}")
69
70 def __getitem__(self, key: AnyStr) -> bytes | None:
71 try:

Callers 2

normkeyMethod · 0.95
normvalueMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected