From 3d3473b543d6199a31ed5eaacdf335f4f7c67ddb0fb3358d1f48145b21014c24 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Fri, 15 Nov 2024 16:05:23 +0300 Subject: [PATCH] set encoding support --- pyac/pyac.py | 5 +++++ 1 file changed, 5 insertions(+) mode change 100644 => 100755 pyac/pyac.py diff --git a/pyac/pyac.py b/pyac/pyac.py old mode 100644 new mode 100755 index da93f15..d0789a7 --- a/pyac/pyac.py +++ b/pyac/pyac.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # pyac -- Python YAC implementation # Copyright (C) 2024 Sergey Matveev # @@ -201,6 +202,10 @@ def dumps(v): return b"".join(raws) if isinstance(v, (list, tuple)): return b"".join([_byte(TagList)] + [dumps(i) for i in v] + [_byte(TagEOC)]) + if isinstance(v, set): + if not all(isinstance(i, str) for i in v): + raise ValueError("set can contain only strings") + return dumps({i: None for i in v}) if isinstance(v, dict): raws = [_byte(TagMap)] for k in sorted(v.keys(), key=LenFirstSort): -- 2.50.0