Access Violation Error while using Python Ctypes

HighBeliever akshay.ksth at gmail.com
Thu Jul 4 04:04:15 EDT 2013


I used the following code to import the functions of a dll in my Python code.

	from ctypes import *

	hunspell=CDLL('C:\Nhunspell\Hunspellx64.dll')
	hunspell.HunspellInit.restype = POINTER(c_int)
	hunspell.HunspellInit.argtypes = (c_char_p, c_char_p)
	hunspell.HunspellSpell.argtypes = (POINTER(c_int), c_char_p)
	hunspell.HunspellAdd.argtypes = (POINTER(c_int), c_char_p)
	hunspell.HunspellSuggest.argtypes = (POINTER(c_int), POINTER(POINTER(c_char_p)), c_char_p)

	class Hunspell(object):
		def __init__(self):
			self.hunhandle = hunspell.HunspellInit('en_US.aff', 'en_US.dic')

        a=Hunspell()

The class Hunspell should act as a wrapper for the function, but then I get this error when I try to run this.

	Traceback (most recent call last):
	  File "C:\Users\KURO\Desktop\hunspell\text.py", line 49, in <module>
		a=Hunspell()
	  File "C:\Users\KURO\Desktop\hunspell\text.py", line 17, in __init__
		self.hunhandle = hunspell.HunspellInit('en_US.aff', 'en_US.dic')
	WindowsError: exception: access violation reading 0x0000000001FBB000

Please help me out.



More information about the Python-list mailing list