suever / pydicom-experimental

pydicom test
0 stars 1 forks source link

Error when trying to open a DICOM image with a unicode path #58

Closed suever closed 9 years ago

suever commented 9 years ago

From pierre.raybaut on September 25, 2009 07:56:11

Hi,

To avoid this error when trying to pass a unicode path to dicom.ReadFile:

Traceback (most recent call last): File "***_.py", line __, in _****

dcm = dicom.ReadFile(filename)

File "C:\Python26\lib\site-packages\dicom\filereader.py", line 416, in read_file fp.defer_size = defer_size AttributeError: 'unicode' object has no attribute 'defer_size'

I suggest replacing line 409 in dicom/filereader.py, function "read_file":

original code: (does not handle the unicode case) if type(fp) is type(""):

suggested replacement code: (handle any type of string, including unicode) if isinstance(fp, basestring):

Keep up the good work, Cheers, Pierre

Original issue: http://code.google.com/p/pydicom/issues/detail?id=58

suever commented 9 years ago

From darcymason@gmail.com on September 26, 2009 16:41:15

Thanks, Pierre. Excellent suggestion. I checked that basestring is available since python 2.3 so it is available for all python versions pydicom supports. Will make this change.

Status: Accepted
Owner: darcymason
Labels: -Difficulty-Medium Difficulty-Easy

suever commented 9 years ago

From darcymason@gmail.com on October 05, 2009 20:08:15

Fixed in r142

Status: Fixed