[python-win32] Bug in pywin32 PyIADs?

Tim Golden mail at timgolden.me.uk
Sun Apr 22 19:42:44 CEST 2012

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.



More information about the python-win32 mailing list