h2py.py and char literals
lsmithso at hare.demon.co.uk
lsmithso at hare.demon.co.uk
Wed Sep 14 13:00:20 EDT 2005
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.
More information about the Python-list
mailing list