PdfParser: Don't use list as def in read_prev_trailer
It's not recommended to use the empty list as default value in functions or methods because Python interpreter evaluates during parsing, so it will be the same list for different calls. https://pylint.pycqa.org/en/latest/user_guide/messages/warning/dangerous-default-value.html
This commit is contained in:
parent
9289863c2c
commit
78ee80a6fd
@ -692,7 +692,7 @@ class PdfParser:
|
||||
self.read_prev_trailer(self.trailer_dict[b"Prev"])
|
||||
|
||||
def read_prev_trailer(
|
||||
self, xref_section_offset: int, processed_offsets: list[int] = []
|
||||
self, xref_section_offset: int, processed_offsets: list[int] = None
|
||||
) -> None:
|
||||
assert self.buf is not None
|
||||
trailer_offset = self.read_xref_table(xref_section_offset=xref_section_offset)
|
||||
@ -708,6 +708,8 @@ class PdfParser:
|
||||
)
|
||||
trailer_dict = self.interpret_trailer(trailer_data)
|
||||
if b"Prev" in trailer_dict:
|
||||
if processed_offsets is None:
|
||||
processed_offsets = []
|
||||
processed_offsets.append(xref_section_offset)
|
||||
check_format_condition(
|
||||
trailer_dict[b"Prev"] not in processed_offsets, "trailer loop found"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user