Skip to content

Commit

Permalink
Fix codify rel path (#1867)
Browse files Browse the repository at this point in the history
* cherry-picked from main branch of 3.0 dev
  • Loading branch information
darcymason committed Aug 15, 2023
1 parent 87266d9 commit f86e0df
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/release_notes/index.rst
Expand Up @@ -2,6 +2,7 @@
Release notes
=============

.. include:: v2.4.3.rst
.. include:: v2.4.0.rst
.. include:: v2.3.0.rst
.. include:: v2.2.0.rst
Expand Down
7 changes: 7 additions & 0 deletions doc/release_notes/v2.4.3.rst
@@ -0,0 +1,7 @@
Version 2.4.3
==============

Fixes
-----

* Fixed pydicom codify error when relative path did not exist
3 changes: 2 additions & 1 deletion pydicom/cli/main.py
Expand Up @@ -137,7 +137,8 @@ def filespec_parser(filespec: str) -> List[Tuple[Dataset, Any]]:
if not pydicom_filename:
try:
char_filenames = get_charset_files(filename)
pydicom_filename = char_filenames[0]
if char_filenames:
pydicom_filename = char_filenames[0]
except NotImplementedError: # will get this if absolute path passed
pass

Expand Down
7 changes: 7 additions & 0 deletions pydicom/tests/test_util.py
Expand Up @@ -171,6 +171,13 @@ def test_code_file(self, capsys):
out, err = capsys.readouterr()
assert r"c:\temp\testout.dcm" in out

def test_code_relative_filename(self, capsys):
"""Test utils.codify.code_file with a relative path that doesn't exist"""
# regression test for #1865
args = ["XXxUN_sequenceXX.dcm"] # file that doesn't exist
with pytest.raises(SystemExit):
codify_main(100, args)

def test_code_dataelem_at(self):
"""Test utils.codify.code_dataelem"""
elem = DataElement(0x00000901, 'AT', (0x1234, 0x5678))
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -35,7 +35,7 @@ license = {text = "MIT"}
name = "pydicom"
readme = "README.md"
requires-python = ">=3.7"
version = "2.4.2"
version = "2.4.3"


[project.optional-dependencies]
Expand Down

0 comments on commit f86e0df

Please sign in to comment.