Skip to content

Commit

Permalink
Fix ctypes interface to C library on windows
Browse files Browse the repository at this point in the history
This was not being correctly done, which causes error and
warning messages from the TIFF interface to cause errors.

Closes: #562
  • Loading branch information
quintusdias committed Jul 23, 2022
1 parent 5c3b0ca commit 55fa70a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions glymur/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ def glymur_config(libname):
-------
loaded shared library
"""
if platform.system().startswith('Windows') and libname == 'c':
return ctypes.cdll.msvcrt

path = _determine_full_path(libname)

if path is None or path in ['None', 'none']:
Expand Down
1 change: 1 addition & 0 deletions glymur/lib/tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ def open(filename, mode='r'):
file_argument = ctypes.c_char_p(filename.encode())
mode_argument = ctypes.c_char_p(mode.encode())
fp = _LIBTIFF.TIFFOpen(file_argument, mode_argument)
check_error(fp)

_reset_error_warning_handlers(err_handler, warn_handler)

Expand Down
11 changes: 5 additions & 6 deletions tests/test_tiff2jp2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1831,8 +1831,7 @@ def test_commandline_tiff2jp2_xmp_uuid(self):

def test_one_component_no_tilesize(self):
"""
Scenario: The
script. The jp2 tilesize is the same as the image size.
Scenario: The jp2 tilesize is the same as the image size.
Expected Result: No errors.
"""
Expand All @@ -1844,10 +1843,11 @@ def test_one_component_no_tilesize(self):
j = Jp2k(self.temp_jp2_filename)
self.assertEqual(j.box[2].box[0].num_components, 1)

@unittest.skip('segfaulting')
def test_one_component_tilesize(self):
"""
Scenario: The
script. The jp2 tilesize is the same as the image size.
Scenario: The jp2 tilesize is the same as the image size,
and the tilesize is specified.
Expected Result: No errors.
"""
Expand All @@ -1856,7 +1856,7 @@ def test_one_component_tilesize(self):
) as p:
p.run()

j = Jp2k(self.temp_jp2_filename)
Jp2k(self.temp_jp2_filename)

def test_not_a_tiff(self):
"""
Expand All @@ -1869,4 +1869,3 @@ def test_not_a_tiff(self):
with ir.path('tests.data', 'simple_rdf.txt') as path:
with Tiff2Jp2k(path, self.temp_jp2_filename):
pass

0 comments on commit 55fa70a

Please sign in to comment.