Issue 147 in pydicom: Error when write dicom with Ironpython

17 views
Skip to first unread message

pyd...@googlecode.com

unread,
May 13, 2014, 2:41:26 PM5/13/14
to pydic...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium Difficulty-Medium

New issue 147 by shkt...@gmail.com: Error when write dicom with Ironpython
http://code.google.com/p/pydicom/issues/detail?id=147

c:\> ipy
IronPython 2.7.4 (2.7.0.40) on .NET 4.0.30319.18408 (32-bit)
Type "help", "copyright", "credits" or "license" for more information.
>>> import dicom
>>> da = dicom.read_file("CT.test01.dcm")
>>> dicom.write_file("CT.out.dcm")

Which causes the following error message:


File "C:\IronPython2.7.4\lib\site-packages\dicom\filewriter.py", line 338,
in write_file
File "C:\IronPython2.7.4\lib\site-packages\dicom\filewriter.py", line
278, in _write_file_meta_info
File "C:\IronPython2.7.4\lib\site-packages\dicom\filewriter.py", line
196, in write_dataset
File "C:\IronPython2.7.4\lib\site-packages\dicom\filewriter.py", line
132, in write_data_element
File "C:\IronPython2.7.4\lib\site-packages\dicom\filebase.py", line 47,
in write_tag
File "C:\IronPython2.7.4\lib\site-packages\dicom\filebase.py", line 86,
in write_leUS

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

pyd...@googlecode.com

unread,
May 13, 2014, 2:44:07 PM5/13/14
to pydic...@googlegroups.com

Comment #1 on issue 147 by Sue...@gmail.com: Error when write dicom with
Ironpython
http://code.google.com/p/pydicom/issues/detail?id=147

Could you please provide the remainder of the error message? There should
be one more line right after the trace that you've pasted here with the
actual error message.

Thanks

pyd...@googlecode.com

unread,
May 13, 2014, 2:59:24 PM5/13/14
to pydic...@googlegroups.com

Comment #2 on issue 147 by shkt...@gmail.com: Error when write dicom with
Ironpython
http://code.google.com/p/pydicom/issues/detail?id=147

Forget the last line of the error message:

TypeError: expected str, got bytes

pyd...@googlecode.com

unread,
Jun 7, 2014, 6:30:05 AM6/7/14
to pydic...@googlegroups.com

Comment #3 on issue 147 by Dimitri....@gmail.com: Error when write dicom
with Ironpython
http://code.google.com/p/pydicom/issues/detail?id=147

Indeed revision r455026896441 changed struct formats from string to byte
literals. I'm not sure why this would be needed for Python 3. The Python 3
struct.pack() documentation and example code do not refer to byte literals
for the format:
https://docs.python.org/3/library/struct.html#examples

You need to change line:
self.write(pack(b"<H", val))
back to:
self.write(pack("<H", val))

The same for other similar errors.

pyd...@googlecode.com

unread,
Jun 7, 2014, 12:40:29 PM6/7/14
to pydic...@googlegroups.com

Comment #4 on issue 147 by Sue...@gmail.com: Error when write dicom with
Ironpython
http://code.google.com/p/pydicom/issues/detail?id=147

Thanks for your help, Dimitri. Originally, I had thought that maybe the
explicit byte literals for the format were to help with 2to3 conversion as
it often performs better when you explicitly state types, but it appears
that is not the case in this instance. That is a simple change that we can
definitely make.

There are, however, bigger problems with IronPython compatibility. After
making this basic change IronPython will still fail many of the unit tests
because of the difference in handling of strings in IronPython and standard
Python 2.x. It will likely take a decent amount of effort to get the code
base to be compatible with IronPython, Python 2.x, and 3.x and I just
haven't had the opportunity to take a closer look at this. I'm willing to
try to tackle this at some point, but anyone who has more experience with
IronPython is welcome to pitch in.
Reply all
Reply to author
Forward
0 new messages