[python-win32] Errors (?) in win32con.py
Tim Roberts
timr at probo.com
Fri Sep 3 23:20:08 CEST 2004
On Fri, 03 Sep 2004 19:59:22 +0200, Thomas Heller <theller at python.net>
wrote:
> I'm currently writing code to parse the windows header files and
> create Python code from them - see recent articles in the ctypes-users
> mailing list. When I compare the output of my tools with the contents
> in win32con.py, I see several differences. One example is the
> (arbitrarily chosen) CDN_SELCHANGE symbol. In the commdlg.h file I
> have I see this: #define CDN_FIRST (0U - 601U) ... #define
> CDN_SELCHANGE (CDN_FIRST - 0x0001) Ignoring signed/unsigned issues
> (and not showing the FutureWarning from Python 2.3):
>
>>>>>>> hex(0 - 601 - 1)
>>>>
>>>>
>'0xfffffda6'
>
>
>>>>>>> import win32con
>>>>>>> hex(win32con.CDN_SELCHANGE)
>>>>
>>>>
>'0x4efda6'
>
>
>>>>>>>
>>>>
>>>>
>
>Looking into the win32con.py source code:
>
>PY_0U = 5177344
>CDN_FIRST = (PY_0U-601)
>CDN_SELCHANGE = (CDN_FIRST - 1)
>
>I'm puzzled. What is PY_0U?
>
>
Interesting; I would call that a bug. It's clearly an attempt to render
the C unsigned constant 0U into Python, but you are correct: the
resulting values are not the same. CDN_FIRST should be -601, which is
FFFFFDA7, not 004FDA7.
Unfortunately, playing with this stuff runs into the new
FutureWarnings. I would have guessed that
PY_0U = 0x10000000L
would produce the best overall results.
--
- Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-win32
mailing list