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

[MRG] Prevent crash due to invalid private creator #1639

Merged
merged 2 commits into from Apr 27, 2022

Conversation

mrbean-bremen
Copy link
Member

@mrbean-bremen mrbean-bremen commented Apr 22, 2022

Describe the changes

I decided to make a minimum impact change that only prevents the crash. Any invalid private creator will still be handled as a private creator with respect to the private tags.
The crash itself only happens due to the lookup of the key in the private dictionary, which now behaves the same as a valid private creator not present in the dictionary.

Tasks

  • Unit tests added that reproduce the issue or prove feature is working
  • Fix or feature added
  • Code typed and mypy shows no errors
  • Unit tests passing and overall coverage the same or better

- issue a warning but don't change the private creator logic
- fixes pydicom#1638
@codecov
Copy link

codecov bot commented Apr 22, 2022

Codecov Report

Merging #1639 (48a21f2) into master (9aaaa24) will increase coverage by 0.10%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1639      +/-   ##
==========================================
+ Coverage   97.57%   97.67%   +0.10%     
==========================================
  Files          66       66              
  Lines       10666    10674       +8     
==========================================
+ Hits        10407    10426      +19     
+ Misses        259      248      -11     
Impacted Files Coverage Δ
pydicom/dataelem.py 98.39% <ø> (ø)
pydicom/datadict.py 100.00% <100.00%> (ø)
pydicom/tag.py 100.00% <100.00%> (ø)
pydicom/valuerep.py 99.53% <0.00%> (+0.15%) ⬆️
pydicom/filewriter.py 98.06% <0.00%> (+0.24%) ⬆️
pydicom/filereader.py 94.62% <0.00%> (+0.25%) ⬆️
pydicom/uid.py 100.00% <0.00%> (+1.09%) ⬆️
pydicom/filebase.py 99.19% <0.00%> (+1.61%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@mrbean-bremen mrbean-bremen changed the title Prevent crash due to invalid private creator [MRG] Prevent crash due to invalid private creator Apr 22, 2022
Copy link
Member

@darcymason darcymason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - just one small suggestion.

@@ -553,6 +553,10 @@ def get_private_entry(
f"Private creator '{private_creator}' not in the private "
"dictionary"
) from exc
except TypeError as exc:
msg = f"'{private_creator}' is not a valid private creator"
warnings.warn(msg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be helpful to have the tag number here as well as its value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, for some reason I missed that comment - adapted now.

@darcymason darcymason merged commit fce985c into pydicom:master Apr 27, 2022
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.

Pydicom - TypeError: unhashable type 'list'
3 participants