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

Better error handling for DEP5 parse errors #841

Merged
merged 5 commits into from
Oct 31, 2023

Conversation

carmenbianca
Copy link
Member

@carmenbianca carmenbianca commented Oct 17, 2023

Fixes #803 by having better error handling.

Upstream PR to improve some exception catching: https://salsa.debian.org/python-debian-team/python-debian/-/merge_requests/123

After adding a duplicate Copyright field, the lint output looks like this:

$ reuse lint
usage: reuse [-h] [--debug] [--suppress-deprecation] [--include-submodules] [--include-meson-subprojects] [--no-multiprocessing] [--root PATH] [--version]
             {annotate,download,init,lint,spdx,supported-licenses,supported-licences} ...
reuse: error: '.reuse/dep5' could not be parsed. We received the following error message: Duplicate field "Copyright" in paragraph number 1

@carmenbianca carmenbianca force-pushed the fix-dep5-parse branch 4 times, most recently from d9caa36 to 2d8337b Compare October 17, 2023 12:37
@carmenbianca carmenbianca marked this pull request as ready for review October 17, 2023 12:41
@carmenbianca carmenbianca force-pushed the fix-dep5-parse branch 2 times, most recently from 7565ee7 to 278953d Compare October 17, 2023 13:17
src/reuse/project.py Outdated Show resolved Hide resolved
src/reuse/_main.py Outdated Show resolved Hide resolved
@carmenbianca
Copy link
Member Author

Copyright goes to FSFE, not Coop IT Easy. Fixed the commits.

This was referenced Oct 24, 2023
@carmenbianca carmenbianca force-pushed the fix-dep5-parse branch 2 times, most recently from 1cdcf9c to fdf3b9d Compare October 25, 2023 05:44
This will help improve the error handling of DEP5 when the syntax is not
valid.

Signed-off-by: Carmen Bianca BAKKER <carmenbianca@fsfe.org>
Before, the Debian Copyright object was created lazily. When it is first
needed, it is created. The Projects that were passed to other processes
did not yet have Copyright objects (because they weren't yet needed, and
can't be pickled). However, this sometimes resulted in every process
separately trying to parse the DEP5 file, and failing.

Now, the DEP5 file is parsed immediately instead of being lazily
created. We circumvent the pickling problem by unsetting the attribute
and re-parsing the file in the process. This is a bit stupid, but it
shouldn't result in errors if the DEP5 file is not changed in the
meantime.

Signed-off-by: Carmen Bianca BAKKER <carmenbianca@fsfe.org>
Signed-off-by: Carmen Bianca BAKKER <carmenbianca@fsfe.org>
Signed-off-by: Carmen Bianca BAKKER <carmenbianca@fsfe.org>
Signed-off-by: Carmen Bianca BAKKER <carmenbianca@fsfe.org>
@carmenbianca carmenbianca merged commit 728c9d6 into fsfe:main Oct 31, 2023
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dep5 Duplicate field "Copyright": Fails to parse many files with REUSE v2.1.0 Release
1 participant