[New-bugs-announce] [issue5119] inconsistent wide character parameter handling in 64-bit python

Jason R. Coombs report at bugs.python.org
Sat Jan 31 21:53:39 CET 2009

New submission from Jason R. Coombs <jaraco at jaraco.com>:

Using Python 2.5.4 and Python 2.6.1 on 32-bit python, when passing a
regular string to a function expecting pointer to a wide string
(wintypes.LPCWSTR), the function executes without problems.

When calling the same using Python 2.6.1 on 64-bit windows, the called
function appears not to recognize the parameter unless it is first
converted to unicode.

I discovered this when calling the WNetAddConnection2 function.

Assuming a properly-initialized NETRESOURCE, resource.

password = None
username = 'username at domain.com'
flags = 0

val = ctypes.windll.mpr.WNetAddConnection2W(

This method works fine on 32-bit python but fails on 64-bit python
unless username=unicode(username).  The error returned is "The specified
password is incorrect", indicating that the username is in fact
incorrect because the correct username does not require a password.

I wish I had a better test case; I'll try to track down one that doesn't
require such a complex underlying API.

I'm not sure what the correct fix is for this, but regardless, I would
expect the behavior to be consistent for the same Python version
independent of word size.

assignee: theller
components: ctypes
messages: 80883
nosy: jaraco, theller
severity: normal
status: open
title: inconsistent wide character parameter handling in 64-bit python
type: behavior
versions: Python 2.5, Python 2.6

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list