Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve dictionary key override #4051

Merged
merged 1 commit into from
Nov 15, 2024
Merged

Resolve dictionary key override #4051

merged 1 commit into from
Nov 15, 2024

Conversation

JorjMcKie
Copy link
Collaborator

Key "dictkey_desc" was defined twice, such that places expecting a "description" instead received "descender". Added a different key, "dictkey_descr" with a string value of "description".

Addresses issue #4050.

@julian-smith-artifex-com
Copy link
Collaborator

Test failure is:

2024-11-14T11:24:38.8227594Z ________________________________ test_file_info ________________________________
2024-11-14T11:24:38.8228177Z 
2024-11-14T11:24:38.8228363Z     def test_file_info():
2024-11-14T11:24:38.8229496Z         path = os.path.abspath(f'{__file__}/../../tests/resources/test_annot_file_info.pdf')
2024-11-14T11:24:38.8232659Z         document = pymupdf.open(path)
2024-11-14T11:24:38.8233236Z         results = list()
2024-11-14T11:24:38.8233733Z         for i, page in enumerate(document):
2024-11-14T11:24:38.8234419Z             print(f'{i=}')
2024-11-14T11:24:38.8234890Z             annotations = page.annots()
2024-11-14T11:24:38.8235526Z             for j, annotation in enumerate(annotations):
2024-11-14T11:24:38.8236271Z                 print(f'{j=} {annotation=}')
2024-11-14T11:24:38.8236871Z                 t = annotation.type
2024-11-14T11:24:38.8237857Z                 print(f'{t=}')
2024-11-14T11:24:38.8238567Z                 if t[0] == pymupdf.PDF_ANNOT_FILE_ATTACHMENT:
2024-11-14T11:24:38.8239352Z                     file_info = annotation.file_info
2024-11-14T11:24:38.8240127Z                     print(f'{file_info=}')
2024-11-14T11:24:38.8240767Z                     results.append(file_info)
2024-11-14T11:24:38.8241402Z >       assert results == [
2024-11-14T11:24:38.8242267Z                 {'filename': 'example.pdf', 'descender': '', 'length': 8416, 'size': 8992},
2024-11-14T11:24:38.8243512Z                 {'filename': 'photo1.jpeg', 'descender': '', 'length': 10154, 'size': 8012},
2024-11-14T11:24:38.8244347Z                 ]
2024-11-14T11:24:38.8245208Z E       AssertionError: assert [{'descriptio...'size': 8012}] == [{'descender'...'size': 8012}]
2024-11-14T11:24:38.8246123Z E         
2024-11-14T11:24:38.8247509Z E         At index 0 diff: {'filename': 'example.pdf', 'description': '', 'length': 8416, 'size': 8992} != {'filename': 'example.pdf', 'descender': '', 'length': 8416, 'size': 8992}
2024-11-14T11:24:38.8249019Z E         Use -v to get more diff
2024-11-14T11:24:38.8249470Z 
2024-11-14T11:24:38.8259421Z /project/tests/test_annots.py:345: AssertionError

I.e. 'descender': '' has changed to'description': ''.

@JorjMcKie
Copy link
Collaborator Author

Thanks for helping to locate this error.
Will make resp. changes.

Key "dictkey_desc" was defined twice, such that places expecting a "description" instead received "descender".
Added a different key, "dictkey_descr" with a string value of "description".
@JorjMcKie JorjMcKie merged commit 92ca9f4 into main Nov 15, 2024
2 checks passed
@JorjMcKie JorjMcKie deleted the address-4050 branch November 15, 2024 15:32
@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants