By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,930 Members | 2,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,930 IT Pros & Developers. It's quick & easy.

h2py.py and char literals

P: n/a
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.

Sep 14 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.