bug in Makepy

J

Jim

I was trying to use Makepy to wrap a typelib, but couldn't find the one
I wanted in the list of libs offered, and couldn't find a way to browse
to a specific one.

Turns out the reason was that the lib was version 10, which was listed
in the registry in hex as version a.0. The tlb chooser in Makepy
rejects hex values. The author was evidently aware of this, since there
is a comment in the code about it.

Here is a fix -- add 4 lines in
site-packages\win32com\client\selecttlb.py:

try:
# For some reason, this code used to assume the values were hex.
# This seems to not be true - particularly for CDO 1.21
# *sigh* - it appears there are no rules here at all, so when we need
# to know the info, we must load the tlb by filename and request it.
# The Resolve() method on the TypelibSpec does this.
major = int(major_minor[0])
minor = int(major_minor[1])
except ValueError: # try again in case values are in hex
=> try:
=> major = int(major_minor[0], 16)
=> minor = int(major_minor[1], 16)
=> except ValueError: # crap in the registry!
continue

Hope this helps someone.

-- Jim
 
S

Sybren Stuvel

Jim enlightened us with:
major = int(major_minor[0])
minor = int(major_minor[1])
except ValueError: # try again in case values are in hex
=> try:
=> major = int(major_minor[0], 16)
=> minor = int(major_minor[1], 16)
=> except ValueError: # crap in the registry!
continue

This only works if the hexadecimal representation has digits in [A-F].
What if the stored value is 10, but in hexadecimal?

Sybren
 
J

Jim

This only works if the hexadecimal representation has digits in [A-F].
What if the stored value is 10, but in hexadecimal?

I don't get what you mean. If the value is "10, but in hexadecimal",
isn't that A?

The problem my fix solves is where the folder under the typelib guid is
named something like "a.0." It does what I need. If you see a case it
doesn't handle, maybe you could propose a better fix?

-- Jim
 
D

Dennis Lee Bieber

I don't get what you mean. If the value is "10, but in hexadecimal",
isn't that A?
No... it's 1*16 + 0 => 16 decimal.

Your except block only triggers if an alpha character is found when
trying to interpret the values as decimal integer.
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
S

Sybren Stuvel

Jim enlightened us with:
This only works if the hexadecimal representation has digits in
[A-F]. What if the stored value is 10, but in hexadecimal?

I don't get what you mean. If the value is "10, but in
hexadecimal", isn't that A?

'10, but in hexadecimal' is 16 in decimal.
The problem my fix solves is where the folder under the typelib guid
is named something like "a.0." It does what I need. If you see a
case it doesn't handle, maybe you could propose a better fix?

Always interpret it as hex, or always interpret it as decimal.

Sybren
 
J

Jim

Always interpret it as hex, or always interpret it as decimal.

I see what you mean. But I don't think I'll worry about it.

-- Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top