[Python-checkins] r43115 - in python/trunk: Lib/ctypes/__init__.py Lib/ctypes/test/test_byteswap.py Lib/ctypes/test/test_cfuncs.py Lib/ctypes/test/test_loading.py Lib/ctypes/test/test_sizes.py Modules/_ctypes/_ctypes.c Modules/_ctypes/callproc.c

Thomas Heller theller at python.net
Sat Mar 18 18:36:18 CET 2006


Neal Norwitz wrote:
> On 3/17/06, thomas.heller <python-checkins at python.org> wrote:
>> Author: thomas.heller
>> Date: Fri Mar 17 16:52:58 2006
>> New Revision: 43115
>>
>> @@ -198,17 +199,20 @@
>>              pass
>>          self.assertRaises(TypeError, setattr, S, "_fields_", [("s", T)])
>>
>> -    # crashes on solaris with a core dump.
>> -    def X_test_struct_fields(self):
>> +    def test_struct_fields_2(self):
>> +        # standard packing in struct uses no alignment.
>> +        # So, we have to align using pad bytes.
>> +        #
>> +        # Unaligned accesses will crash Python (on those platforms that
>> +        # don't allow it, like sparc solaris).
> 
> Note: this is really a bug in Python that should be fixed.
> 
> 
>> Modified: python/trunk/Modules/_ctypes/_ctypes.c
>> ==============================================================================
>> --- python/trunk/Modules/_ctypes/_ctypes.c      (original)
>> +++ python/trunk/Modules/_ctypes/_ctypes.c      Fri Mar 17 16:52:58 2006
>> @@ -2529,9 +2556,14 @@
>>  #ifdef MS_WIN32
>>         address = FindAddress(handle, name, (PyObject *)type);
>>         if (!address) {
>> -               PyErr_Format(PyExc_AttributeError,
>> -                            "function '%s' not found",
>> -                            name);
>> +               if ((size_t)name & ~0xFFFF)
>> +                       PyErr_Format(PyExc_AttributeError,
>> +                                    "function '%s' not found",
>> +                                    name);
>> +               else
>> +                       PyErr_Format(PyExc_AttributeError,
>> +                                    "function ordinal %d not found",
>> +                                    name);
> 
> name can't be both a string and an integer.  That last error message
> looks wrong.
> 
> n
I'm working on both.

Thomas



More information about the Python-checkins mailing list