@@ -362,23 +362,20 @@ def valueDecoder(self, substrate, asn1Spec,
362362 if LOG :
363363 LOG ('assembling constructed serialization' )
364364
365- # All inner fragments are of the same type, treat them as octet string
366- substrateFun = self .substrateCollector
367-
368- header = b''
365+ # Assemble the logical value of each fragment, including nested ones.
366+ fragments = []
369367
370368 original_position = substrate .tell ()
371369 # head = popSubstream(substrate, length)
372370 while substrate .tell () - original_position < length :
373371 for component in decodeFun (
374- substrate , self .protoComponent , substrateFun = substrateFun ,
375- ** options ):
372+ substrate , self .protoComponent , ** options ):
376373 if isinstance (component , SubstrateUnderrunError ):
377374 yield component
378375
379- header += component
376+ fragments . append ( bytes ( component ))
380377
381- yield self ._createComponent (asn1Spec , tagSet , header , ** options )
378+ yield self ._createComponent (asn1Spec , tagSet , b'' . join ( fragments ) , ** options )
382379
383380 def indefLenValueDecoder (self , substrate , asn1Spec ,
384381 tagSet = None , length = None , state = None ,
@@ -392,16 +389,13 @@ def indefLenValueDecoder(self, substrate, asn1Spec,
392389
393390 return
394391
395- # All inner fragments are of the same type, treat them as octet string
396- substrateFun = self .substrateCollector
397-
398- header = b''
392+ # Assemble the logical value of each fragment, including nested ones.
393+ fragments = []
399394
400395 while True : # loop over fragments
401396
402397 for component in decodeFun (
403- substrate , self .protoComponent , substrateFun = substrateFun ,
404- allowEoo = True , ** options ):
398+ substrate , self .protoComponent , allowEoo = True , ** options ):
405399
406400 if isinstance (component , SubstrateUnderrunError ):
407401 yield component
@@ -412,9 +406,9 @@ def indefLenValueDecoder(self, substrate, asn1Spec,
412406 if component is eoo .endOfOctets :
413407 break
414408
415- header += component
409+ fragments . append ( bytes ( component ))
416410
417- yield self ._createComponent (asn1Spec , tagSet , header , ** options )
411+ yield self ._createComponent (asn1Spec , tagSet , b'' . join ( fragments ) , ** options )
418412
419413
420414class NullPayloadDecoder (AbstractSimplePayloadDecoder ):
@@ -1431,6 +1425,8 @@ def indefLenValueDecoder(self, substrate, asn1Spec,
14311425 # All inner fragments are of the same type, treat them as octet string
14321426 substrateFun = self .substrateCollector
14331427
1428+ fragments = [chunk ]
1429+
14341430 while True : # loop over fragments
14351431
14361432 for component in decodeFun (
@@ -1446,7 +1442,9 @@ def indefLenValueDecoder(self, substrate, asn1Spec,
14461442 if component is eoo .endOfOctets :
14471443 break
14481444
1449- chunk += component
1445+ fragments .append (component )
1446+
1447+ chunk = b'' .join (fragments )
14501448
14511449 if substrateFun :
14521450 yield chunk # TODO: Weird
0 commit comments