@@ -984,6 +984,8 @@ class Variant(Object):
984984 TYPE_ACCESS := b"@" ,
985985 TYPE_SPREAD := b"S" ,
986986 TYPE_NAMED_SPREAD := b"R" ,
987+ TYPE_TRUE := b"T" ,
988+ TYPE_FALSE := b"F" ,
987989]
988990FLAG_REF = 0x80
989991
@@ -1091,6 +1093,10 @@ def serialize(self, obj: Object) -> None:
10911093 self .serialize (item )
10921094 return
10931095 if isinstance (obj , Variant ):
1096+ if obj .tag == "true" and isinstance (obj .value , Hole ):
1097+ return self .emit (TYPE_TRUE )
1098+ if obj .tag == "false" and isinstance (obj .value , Hole ):
1099+ return self .emit (TYPE_FALSE )
10941100 # TODO(max): Determine if this should be a ref
10951101 self .emit (TYPE_VARIANT )
10961102 # TODO(max): String pool (via refs) for strings longer than some length?
@@ -1329,6 +1335,12 @@ def parse(self) -> Object:
13291335 return Spread ()
13301336 if ty == TYPE_NAMED_SPREAD :
13311337 return Spread (self ._string ())
1338+ if ty == TYPE_TRUE :
1339+ assert not is_ref
1340+ return Variant ("true" , Hole ())
1341+ if ty == TYPE_FALSE :
1342+ assert not is_ref
1343+ return Variant ("false" , Hole ())
13321344 raise NotImplementedError (bytes (ty ))
13331345
13341346
@@ -2531,7 +2543,7 @@ def do_GET(self) -> None:
25312543 if scrap is not None :
25322544 self .send_response (200 )
25332545 self .send_header ("Content-Type" , "application/scrap; charset=binary" )
2534- self .send_header ("Content-Disposition" , f' attachment; filename={ json .dumps (f" { path } .scrap" ) } ' )
2546+ self .send_header ("Content-Disposition" , f" attachment; filename={ json .dumps (f' { path } .scrap' ) } " )
25352547 self .send_header ("Content-Length" , str (len (scrap )))
25362548 self .end_headers ()
25372549 self .wfile .write (scrap )
0 commit comments