moat-lib-codec 0.4.16__tar.gz → 0.4.18__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. {moat_lib_codec-0.4.16/src/moat_lib_codec.egg-info → moat_lib_codec-0.4.18}/PKG-INFO +1 -1
  2. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/debian/changelog +24 -0
  3. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/pyproject.toml +1 -1
  4. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat/lib/codec/_base.py +2 -2
  5. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat/lib/codec/_cbor.py +2 -2
  6. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat/lib/codec/_moat_msgpack.py +4 -4
  7. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat/lib/codec/bool.py +3 -3
  8. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat/lib/codec/cbor.py +1 -1
  9. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat/lib/codec/errors.py +1 -1
  10. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat/lib/codec/json.py +2 -2
  11. moat_lib_codec-0.4.18/src/moat/lib/codec/jsonvalstr.py +28 -0
  12. moat_lib_codec-0.4.18/src/moat/lib/codec/jsonvalue.py +26 -0
  13. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat/lib/codec/moat_cbor.py +4 -3
  14. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat/lib/codec/msgpack.py +8 -8
  15. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat/lib/codec/utf8.py +1 -1
  16. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat/lib/codec/yaml.py +3 -3
  17. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18/src/moat_lib_codec.egg-info}/PKG-INFO +1 -1
  18. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat_lib_codec.egg-info/SOURCES.txt +2 -0
  19. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/LICENSE.txt +0 -0
  20. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/Makefile +0 -0
  21. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/README.md +0 -0
  22. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/debian/.gitignore +0 -0
  23. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/debian/control +0 -0
  24. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/debian/py3dist-overrides +0 -0
  25. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/debian/rules +0 -0
  26. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/setup.cfg +0 -0
  27. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat/lib/codec/__init__.py +0 -0
  28. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat/lib/codec/_moat_cbor.py +0 -0
  29. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat/lib/codec/binary.py +0 -0
  30. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat/lib/codec/moat_kv.py +0 -0
  31. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat/lib/codec/moat_msgpack.py +0 -0
  32. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat/lib/codec/noop.py +0 -0
  33. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat_lib_codec.egg-info/dependency_links.txt +0 -0
  34. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat_lib_codec.egg-info/requires.txt +0 -0
  35. {moat_lib_codec-0.4.16 → moat_lib_codec-0.4.18}/src/moat_lib_codec.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moat-lib-codec
3
- Version: 0.4.16
3
+ Version: 0.4.18
4
4
  Summary: A simple command/stream multiplexer
5
5
  Author-email: Matthias Urlichs <matthias@urlichs.de>
6
6
  Maintainer-email: Matthias Urlichs <matthias@urlichs.de>
@@ -1,3 +1,27 @@
1
+ moat-lib-codec (0.4.18-1) unstable; urgency=medium
2
+
3
+ * New release for 26.1.10
4
+
5
+ -- Matthias Urlichs <matthias@urlichs.de> Thu, 23 Apr 2026 21:11:43 +0200
6
+
7
+ moat-lib-codec (0.4.17-2) unstable; urgency=medium
8
+
9
+ * New release for 26.1.1
10
+
11
+ -- Matthias Urlichs <matthias@urlichs.de> Wed, 08 Apr 2026 20:08:52 +0200
12
+
13
+ moat-lib-codec (0.4.17-1) unstable; urgency=medium
14
+
15
+ * New release for 26.0.20
16
+
17
+ -- Matthias Urlichs <matthias@urlichs.de> Sun, 05 Apr 2026 01:09:43 +0200
18
+
19
+ moat-lib-codec (0.4.16-2) unstable; urgency=medium
20
+
21
+ * New release for 26.0.19
22
+
23
+ -- Matthias Urlichs <matthias@urlichs.de> Sun, 22 Mar 2026 16:05:07 +0100
24
+
1
25
  moat-lib-codec (0.4.16-1) unstable; urgency=medium
2
26
 
3
27
  * New release for 26.0.18
@@ -25,7 +25,7 @@ maintainers = [{email = "matthias@urlichs.de",name = "Matthias Urlichs"}]
25
25
  description='A simple command/stream multiplexer'
26
26
  readme = "README.rst"
27
27
  authors = [{email = "matthias@urlichs.de",name = "Matthias Urlichs"}]
28
- version = "0.4.16"
28
+ version = "0.4.18"
29
29
 
30
30
  [project.urls]
31
31
  homepage = "https://m-o-a-t.org"
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, overload
3
+ from typing import TYPE_CHECKING, cast, overload
4
4
 
5
5
  if TYPE_CHECKING:
6
6
  from collections.abc import Callable
@@ -142,7 +142,7 @@ class Extension:
142
142
  self, key: int | None, fn: DecoderFunc | None = None
143
143
  ) -> DecoderFunc | Callable[[DecoderFunc], DecoderFunc]:
144
144
  def _dec(fn: DecoderFunc) -> DecoderFunc:
145
- self.dec[key] = fn # type: ignore[index] # key can be None for catch-all
145
+ self.dec[cast(int, key)] = fn # ty:ignore[index] # key can be None for catch-all
146
146
  return fn
147
147
 
148
148
  if fn is None:
@@ -17,7 +17,7 @@ from ._base import NoCodecError
17
17
  from typing import TYPE_CHECKING, cast # isort:skip
18
18
 
19
19
  try:
20
- from micropython import const # type: ignore[import-not-found] # MicroPython only
20
+ from micropython import const # ty:ignore[unresolved-import] # MicroPython only
21
21
  except ImportError:
22
22
 
23
23
  def const(x: int) -> int:
@@ -247,7 +247,7 @@ class Codec(_Codec):
247
247
 
248
248
  def _enc_string(self, val):
249
249
  if isinstance(val, str):
250
- val = val.encode("utf8")
250
+ val = val.encode("utf8", "surrogateescape")
251
251
  self._enc_type_num(CBOR_TEXT, len(val))
252
252
  else:
253
253
  self._enc_type_num(CBOR_BYTES, len(val))
@@ -56,7 +56,7 @@ def _enc_path(codec, obj):
56
56
  @std_ext.encoder(4, Proxy)
57
57
  def _enc_proxy(codec, obj):
58
58
  codec # noqa:B018
59
- return obj.name.encode("utf-8")
59
+ return obj.name.encode("utf-8", "surrogateescape")
60
60
 
61
61
 
62
62
  @std_ext.encoder(None, object)
@@ -66,7 +66,7 @@ def _enc_any(codec, obj):
66
66
  except KeyError:
67
67
  pass
68
68
  else:
69
- return 4, name.encode("utf-8")
69
+ return 4, name.encode("utf-8", "surrogateescape")
70
70
 
71
71
  try:
72
72
  name = obj2name(type(obj))
@@ -82,7 +82,7 @@ def _enc_any(codec, obj):
82
82
  codec.encode(x) for x in obj.args
83
83
  )
84
84
 
85
- return 4, get_proxy(obj).encode("utf-8")
85
+ return 4, get_proxy(obj).encode("utf-8", "surrogateescape")
86
86
 
87
87
 
88
88
  @std_ext.decoder(3)
@@ -99,7 +99,7 @@ def _dec_proxy(codec, data):
99
99
  if isinstance(data, memoryview):
100
100
  data = bytearray(data)
101
101
  try:
102
- n = data.decode("utf-8")
102
+ n = data.decode("utf-8", "surrogateescape")
103
103
  except UnicodeError:
104
104
  n = str(data)
105
105
  try:
@@ -17,11 +17,11 @@ class Codec(_Codec):
17
17
  def __init__(self, on="on", off="off", null=None, **kw):
18
18
  super().__init__(**kw)
19
19
  if on is not None:
20
- self.on = on.encode("utf-8")
20
+ self.on = on.encode("utf-8", "surrogateescape")
21
21
  if off is not None:
22
- self.off = off.encode("utf-8")
22
+ self.off = off.encode("utf-8", "surrogateescape")
23
23
  if null is not None:
24
- self.null = null.encode("utf-8")
24
+ self.null = null.encode("utf-8", "surrogateescape")
25
25
 
26
26
  def encode(self, obj):
27
27
  "bool > some text"
@@ -9,7 +9,7 @@ import struct
9
9
  try:
10
10
  from ruyaml import representer
11
11
  except ImportError:
12
- from ruamel.yaml import representer # fallback if ruyaml unavailable
12
+ from ruamel.yaml import representer
13
13
 
14
14
  from ._cbor import CBOR_TAG_CBOR_FILEHEADER, CBOR_TAG_CBOR_LEADER, Codec, Tag # noqa:F401
15
15
 
@@ -16,7 +16,7 @@ except ImportError:
16
16
 
17
17
 
18
18
  @as_proxy("_rErrS")
19
- class SilentRemoteError(RemoteError): # type: ignore[misc] # RemoteError may be from two different sources
19
+ class SilentRemoteError(RemoteError): # ty:ignore[unsupported-base] # RemoteError may be from two different sources
20
20
  """
21
21
  Forwarded error from a remote system.
22
22
 
@@ -9,7 +9,7 @@ from ._base import Codec as _Codec
9
9
  try:
10
10
  from json import dumps, loads
11
11
  except ImportError:
12
- from simplejson import dumps, loads # type: ignore[import-not-found] # optional fallback
12
+ from simplejson import dumps, loads
13
13
 
14
14
 
15
15
  class Codec(_Codec):
@@ -22,7 +22,7 @@ class Codec(_Codec):
22
22
 
23
23
  def encode(self, obj):
24
24
  "basic encoder"
25
- return dumps(obj).encode("utf-8")
25
+ return dumps(obj).encode("utf-8", "surrogateescape")
26
26
 
27
27
  def decode(self, data):
28
28
  "basic decoder"
@@ -0,0 +1,28 @@
1
+ "A JSON+Value codec that uses a stringified element"
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+
7
+ from .jsonvalue import Codec as _Codec
8
+
9
+
10
+ class Codec(_Codec):
11
+ "JSON+Value using a stringified element"
12
+
13
+ def __init__(self, ext=None):
14
+ if ext is not None:
15
+ raise ValueError("You can't extend the JSON codec")
16
+ super().__init__()
17
+
18
+ def encode(self, obj):
19
+ "basic encoder"
20
+ return super().encode(json.dumps(obj))
21
+
22
+ def decode(self, data):
23
+ "basic decoder"
24
+ return json.loads(super().decode(data))
25
+
26
+ # 'feed' is not implemented:
27
+ # there is no reasonable incremental JSON codec out there
28
+ # bring your own framing …
@@ -0,0 +1,26 @@
1
+ "A JSON codec that encapsulates its data in a ``value`` element"
2
+
3
+ from __future__ import annotations
4
+
5
+ from .json import Codec as _Codec
6
+
7
+
8
+ class Codec(_Codec):
9
+ "JSON codec with 'value' element"
10
+
11
+ def __init__(self, ext=None):
12
+ if ext is not None:
13
+ raise ValueError("You can't extend the JSON codec")
14
+ super().__init__()
15
+
16
+ def encode(self, obj):
17
+ "basic encoder"
18
+ return super().encode({"value": obj})
19
+
20
+ def decode(self, data):
21
+ "basic decoder"
22
+ return super().decode(data)["value"]
23
+
24
+ # 'feed' is not implemented:
25
+ # there is no reasonable incremental JSON codec out there
26
+ # bring your own framing …
@@ -22,9 +22,10 @@ from ipaddress import (
22
22
  )
23
23
 
24
24
  from ._moat_cbor import Codec, std_ext
25
+ from .cbor import CBOR_TAG_CBOR_FILEHEADER, CBOR_TAG_CBOR_LEADER, Tag
25
26
 
26
27
  # Typing
27
- from .cbor import CBOR_TAG_CBOR_FILEHEADER, CBOR_TAG_CBOR_LEADER, Tag
28
+ from typing import cast
28
29
 
29
30
  __all__ = [
30
31
  "CBOR_TAG_MOAT_CHANGE",
@@ -233,9 +234,9 @@ def _dec_old_ipnetwork(codec, buf) -> IPv4Network | IPv6Network:
233
234
  codec # noqa:B018
234
235
  if isinstance(buf, dict) and len(buf) == 1:
235
236
  mask, buf = next(iter(buf.items()))
236
- if len(buf) == 4:
237
+ if len(cast(bytes, buf)) == 4:
237
238
  return IPv4Network((bytes(buf), mask))
238
- elif len(buf) == 16:
239
+ elif len(cast(bytes, buf)) == 16:
239
240
  return IPv6Network((bytes(buf), mask))
240
241
 
241
242
  raise ValueError(f"invalid ipnetwork value {buf!r}")
@@ -273,7 +273,7 @@ class Unpacker:
273
273
  elif b == 0xC3:
274
274
  obj = True
275
275
  elif b <= 0xC6:
276
- size, fmt, typ = _MSGPACK_HEADERS[b] # type: ignore[misc] # always 3-tuple for these keys
276
+ size, fmt, typ = _MSGPACK_HEADERS[b] # ty:ignore[invalid-assignment] # always 3-tuple for these keys
277
277
  self._reserve(size)
278
278
  if len(fmt) > 0:
279
279
  n = struct.unpack_from(fmt, self._buffer, self._buf_pos)[0]
@@ -282,13 +282,13 @@ class Unpacker:
282
282
  self._buf_pos += size
283
283
  obj = self._read(n)
284
284
  elif b <= 0xC9:
285
- size, fmt, typ = _MSGPACK_HEADERS[b] # type: ignore[misc] # always 3-tuple for these keys
285
+ size, fmt, typ = _MSGPACK_HEADERS[b] # ty:ignore[invalid-assignment] # always 3-tuple for these keys
286
286
  self._reserve(size)
287
287
  L, n = struct.unpack_from(fmt, self._buffer, self._buf_pos)
288
288
  self._buf_pos += size
289
289
  obj = self._read(L)
290
290
  elif b <= 0xD3:
291
- size, fmt = _MSGPACK_HEADERS[b] # type: ignore[misc] # always 2-tuple for these keys
291
+ size, fmt = _MSGPACK_HEADERS[b] # ty:ignore[invalid-assignment] # always 2-tuple for these keys
292
292
  self._reserve(size)
293
293
  if len(fmt) > 0:
294
294
  obj = struct.unpack_from(fmt, self._buffer, self._buf_pos)[0]
@@ -296,12 +296,12 @@ class Unpacker:
296
296
  obj = self._buffer[self._buf_pos]
297
297
  self._buf_pos += size
298
298
  elif b <= 0xD8:
299
- size, fmt, typ = _MSGPACK_HEADERS[b] # type: ignore[misc] # always 3-tuple for these keys
299
+ size, fmt, typ = _MSGPACK_HEADERS[b] # ty:ignore[invalid-assignment] # always 3-tuple for these keys
300
300
  self._reserve(size + 1)
301
301
  n, obj = struct.unpack_from(fmt, self._buffer, self._buf_pos)
302
302
  self._buf_pos += size + 1
303
303
  elif b <= 0xDB:
304
- size, fmt, typ = _MSGPACK_HEADERS[b] # type: ignore[misc] # always 3-tuple for these keys
304
+ size, fmt, typ = _MSGPACK_HEADERS[b] # ty:ignore[invalid-assignment] # always 3-tuple for these keys
305
305
  self._reserve(size)
306
306
  if len(fmt) > 0:
307
307
  (n,) = struct.unpack_from(fmt, self._buffer, self._buf_pos)
@@ -310,12 +310,12 @@ class Unpacker:
310
310
  self._buf_pos += size
311
311
  obj = self._read(n)
312
312
  elif b <= 0xDD:
313
- size, fmt, typ = _MSGPACK_HEADERS[b] # type: ignore[misc] # always 3-tuple for these keys
313
+ size, fmt, typ = _MSGPACK_HEADERS[b] # ty:ignore[invalid-assignment] # always 3-tuple for these keys
314
314
  self._reserve(size)
315
315
  (n,) = struct.unpack_from(fmt, self._buffer, self._buf_pos)
316
316
  self._buf_pos += size
317
317
  else: # if b <= 0xDF: # can't be anything else
318
- size, fmt, typ = _MSGPACK_HEADERS[b] # type: ignore[misc] # always 3-tuple for these keys
318
+ size, fmt, typ = _MSGPACK_HEADERS[b] # ty:ignore[invalid-assignment] # always 3-tuple for these keys
319
319
  self._reserve(size)
320
320
  (n,) = struct.unpack_from(fmt, self._buffer, self._buf_pos)
321
321
  self._buf_pos += size
@@ -471,7 +471,7 @@ class Packer:
471
471
  wb(obj)
472
472
  continue
473
473
  if is_(obj, str):
474
- obj = obj.encode("utf-8") # , self._unicode_errors)
474
+ obj = obj.encode("utf-8", "surrogateescape") # , self._unicode_errors)
475
475
  n = len(obj)
476
476
  if n <= 0x1F:
477
477
  wb(struct.pack("B", 0xA0 + n))
@@ -36,7 +36,7 @@ class Codec(_Codec):
36
36
  "Encode UTF-8 to bytestring"
37
37
  if not isinstance(obj, str):
38
38
  raise ValueError(self, obj) # noqa:TRY004
39
- return obj.encode("utf-8")
39
+ return obj.encode("utf-8", "surrogateescape")
40
40
 
41
41
  def decode(self, data: ByteType) -> str:
42
42
  "Decode a bytestring to UTF-8"
@@ -23,11 +23,11 @@ class Codec(_Codec):
23
23
 
24
24
  def encode(self, obj):
25
25
  "basic encoder"
26
- return yprint(obj).encode("utf-8")
26
+ return yprint(obj).encode("utf-8", "surrogateescape")
27
27
 
28
28
  def decode(self, data):
29
29
  "basic decoder"
30
- return yload(data.decode("utf-8"))
30
+ return yload(data.decode("utf-8", "surrogateescape"))
31
31
 
32
32
  def feed(self, data: ByteType) -> None: # noqa: D102
33
33
  self._buf.extend(data)
@@ -36,6 +36,6 @@ class Codec(_Codec):
36
36
  i = self._buf.find(b"\n---\n")
37
37
  if i < 0:
38
38
  raise StopIteration
39
- res = yload(self._buf[0 : i + 1].decode("utf-8"))
39
+ res = yload(self._buf[0 : i + 1].decode("utf-8", "surrogateescape"))
40
40
  self._buf[0 : i + 5] = b""
41
41
  return res
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moat-lib-codec
3
- Version: 0.4.16
3
+ Version: 0.4.18
4
4
  Summary: A simple command/stream multiplexer
5
5
  Author-email: Matthias Urlichs <matthias@urlichs.de>
6
6
  Maintainer-email: Matthias Urlichs <matthias@urlichs.de>
@@ -17,6 +17,8 @@ src/moat/lib/codec/bool.py
17
17
  src/moat/lib/codec/cbor.py
18
18
  src/moat/lib/codec/errors.py
19
19
  src/moat/lib/codec/json.py
20
+ src/moat/lib/codec/jsonvalstr.py
21
+ src/moat/lib/codec/jsonvalue.py
20
22
  src/moat/lib/codec/moat_cbor.py
21
23
  src/moat/lib/codec/moat_kv.py
22
24
  src/moat/lib/codec/moat_msgpack.py