@@ -428,10 +428,16 @@ def packets(self) -> List[bytes]:
|
428 | 428 | first_time = True |
429 | 429 | debug_enable = LOGGING_IS_ENABLED_FOR(LOGGING_DEBUG) |
430 | 430 | |
431 | | -while first_time or self._has_more_to_add( |
432 | | -questions_offset, answer_offset, authority_offset, additional_offset |
| 431 | +while ( |
| 432 | +first_time is True |
| 433 | +or self._has_more_to_add(questions_offset, answer_offset, authority_offset, additional_offset) |
| 434 | +is True |
433 | 435 | ): |
434 | | -first_time = False |
| 436 | +if first_time: |
| 437 | +first_time = False |
| 438 | +else: |
| 439 | +self._reset_for_next_packet() |
| 440 | + |
435 | 441 | if debug_enable: |
436 | 442 | log.debug( |
437 | 443 | "offsets = questions=%d, answers=%d, authorities=%d, additionals=%d", |
@@ -471,8 +477,12 @@ def packets(self) -> List[bytes]:
|
471 | 477 | additional_offset, |
472 | 478 | ) |
473 | 479 | |
474 | | -if self.is_query() and self._has_more_to_add( |
475 | | -questions_offset, answer_offset, authority_offset, additional_offset |
| 480 | +if ( |
| 481 | +self.is_query() is True |
| 482 | +and self._has_more_to_add( |
| 483 | +questions_offset, answer_offset, authority_offset, additional_offset |
| 484 | + ) |
| 485 | +is True |
476 | 486 | ): |
477 | 487 | # https://datatracker.ietf.org/doc/html/rfc6762#section-7.2 |
478 | 488 | if debug_enable: # pragma: no branch |
@@ -487,7 +497,6 @@ def packets(self) -> List[bytes]:
|
487 | 497 | self._insert_short_at_start(self.id) |
488 | 498 | |
489 | 499 | self.packets_data.append(b''.join(self.data)) |
490 | | -self._reset_for_next_packet() |
491 | 500 | |
492 | 501 | if ( |
493 | 502 | not questions_written |
|