[python-win32] Bug in pywin32 PyIADs?
mail at timgolden.me.uk
Sun Apr 22 21:35:57 CEST 2012
.... except that a recent change to distutils has
broken the pywin32 setup.py. So I'll have to dig
into that first before I can rebuild pywin32
before I can retest my own module. I feel like
I have a hole in my bucket....
On 22/04/2012 19:38, Tim Golden wrote:
> On 22/04/2012 19:34, Roger Upole wrote:
>> "Tim Golden"<mail at timgolden.me.uk> wrote in message
>> news:4F944314.4030406 at timgolden.me.uk...
>>> Could someone glance at this to confirm that it does indeed
>>> seem to be a bug before I start hunting up the chain of
>>> function calls to spot the issue, please?
>>> Steps are simple:
>>> 1) Use Python 3.2 and pywin32 217
>>> 2) Use the following code (obviously substituting some suitable domain):
>>> from win32com import adsi
>>> adsi.ADsGetObject("LDAP://dc=example,dc=com", adsi.IID_IADs)
>>> 3) Receive: "TypeError: expected bytes, str found"
>>> The error appears to be in a hasattr call in _get_good_ret
>>> inside the __init__.py of the adsi subpackage. I've also
>>> seen this in another circumstance where it doesn't make sense:
>>> in an isinstance call where the first param is an PyIADs object.
>>> Further information: this doesn't happen if you don't request
>>> the IID_IADs interface (and it defaults to a wrapped IDispatch)
>>> I assume that, somewhere up the chain of attribute handling from
>>> PyIADs upwards, the ytes/str error is occurring either
>>> specifically within the pywin32 code or implicitly as it passes
>>> something to Python itself.
>>> I've eyeballed the getattro code in PyIADs.cpp but I can't see anything
>>> absolutely obvious.
>>> As it happens I don't have a build environment set up here so I'll
>>> have to build Python& then pywin32 in order to drop into the debugger.
>>> I thought I'd ask first in case anyone else could spot something
>>> which I'd missed.
>> The problem is in this code:
>> PyObject* PyIADs_getattro(PyObject *ob, PyObject *obname)
>> char *name = PyString_AsString(obname);
>> if (!name) return NULL;
>> It should be using PYWIN_ATTR_CONVERT on the attribute name.
> Thanks, Roger. I'll build a patch locally.
More information about the python-win32