h2py.py and char literals

L

lsmithso

Python 2.3.4 on RedHat Linux FC3.

Tools/scripts/h2py.py doesn't translate C char literals. When I feed it
a .h file with the single line:

#define GOO 'L'

It throws out:

Skipping: GOO = ord()

And doesn't generate any code. I'm sure this used to work. I fixed it
by hacking h2py.py:

diff -Naur /usr/lib/python2.3/Tools/scripts/h2py.py h2py.py
--- /usr/lib/python2.3/Tools/scripts/h2py.py 2005-02-02
17:22:30.000000000 +0000
+++ h2py.py 2005-09-14 17:58:31.000000000 +0100
@@ -95,7 +95,7 @@
for p in ignores:
body = p.sub(' ', body)
# replace char literals by ord(...)
- body = p_char.sub('ord(\\0)', body)
+ body = p_char.sub("ord('\\1')", body)
# Compute negative hexadecimal constants
start = 0
UMAX = 2*(sys.maxint+1)


Is this a bug or am I being silly.
 

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
474,264
Messages
2,571,317
Members
48,003
Latest member
coldDuece

Latest Threads

Top