[New-bugs-announce] [issue3077] h2py char literal doesn work
Gabriel
report at bugs.python.org
Wed Jun 11 10:26:09 CEST 2008
New submission from Gabriel <misc at evotex.ch>:
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
----------
components: Demos and Tools
files: h2py.py.patch2
messages: 67943
nosy: grossetti
severity: normal
status: open
title: h2py char literal doesn work
type: behavior
versions: Python 2.5
Added file: http://bugs.python.org/file10578/h2py.py.patch2
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3077>
_______________________________________
More information about the New-bugs-announce
mailing list