This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author grossetti
Recipients grossetti
Date 2008-06-11.08:25:59
SpamBayes Score 0.00066845637
Marked as misclassified No
Message-id <1213172768.79.0.156029263713.issue3077@psf.upfronthosting.co.za>
In-reply-to
Content
Tools/scripts/h2py.py doesn't work with char literals in a define. This
was first reported in the following post :

http://mail.python.org/pipermail/python-list/2005-September/340608.html

The fix works, I have included the patch as h2py.py.patch2.

Also, the current thing that is done when a char literal is encountered
is to use the char's ordinal value. I think that this is misleading,
since in C, if you use a char literal you are usually meaning to check
for an ascii char value like so :

#define EXIT_CHAR 'x'

/* ..... */

if(char_read == EXIT_CHAR)
   exit(0)

and not an integer/numeric value, and if you intend to do numerical
things then you'd use an integer/numeric value instead.

This is the way ctypes does it with their h2xml.py & xml2py.py scripts.

So currently, a defines like the following :

#define EXIT_CHAR 'x'
#define MASK 0xfe
#define LIMIT 4

give (after the h2py.py.patch2 being applied) :

EXIT_CHAR = 120
MASK = 0xfe
LIMIT = 4

and the second patch I am submitting (h2py.py.patch) makes it give :

EXIT_CHAR = 'x'
MASK = 0xfe
LIMIT = 4

which I think is a better interpretation of the intent of the defines.

So to resume :

h2py.py.patch2 : this fixes the bug, maintaining the way the original
h2py script tried to process a char literal.

h2py.py.patch : this fixes the bug, but makes a char literal become a
string literal in python instead of the ordinal value.

Gabriel
History
Date User Action Args
2008-06-11 08:26:09grossettisetspambayes_score: 0.000668456 -> 0.00066845637
recipients: + grossetti
2008-06-11 08:26:08grossettisetspambayes_score: 0.000668456 -> 0.000668456
messageid: <1213172768.79.0.156029263713.issue3077@psf.upfronthosting.co.za>
2008-06-11 08:26:06grossettilinkissue3077 messages
2008-06-11 08:26:04grossetticreate