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.

classification
Title: h2py char literal doesn't work
Type: behavior Stage: patch review
Components: Demos and Tools Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, georg.brandl, grossetti
Priority: normal Keywords: patch

Created on 2008-06-11 08:26 by grossetti, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
h2py.py.patch2 grossetti, 2008-06-11 08:26 this fixes the bug, maintaining the way the original h2py script tried to process a char literal.
h2py.py.patch grossetti, 2008-06-11 08:26 this fixes the bug, but makes a char literal become a string literal in python instead of the ordinal value.
Messages (3)
msg67943 - (view) Author: Gabriel (grossetti) Date: 2008-06-11 08:25
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
msg109946 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-10 23:45
Both patch files are two liners, could someone please take a look and decide if one of them can be accepted?
msg119288 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-10-21 13:29
Fixed in r85770.
History
Date User Action Args
2022-04-11 14:56:35adminsetgithub: 47327
2010-10-21 13:29:18georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg119288

resolution: fixed
2010-07-10 23:45:39BreamoreBoysetnosy: + BreamoreBoy
title: h2py char literal doesn work -> h2py char literal doesn't work
messages: + msg109946

versions: + Python 3.1, Python 3.2
stage: patch review
2009-07-04 03:17:59ezio.melottisetpriority: normal
versions: + Python 2.7, - Python 2.5
2008-06-11 08:26:40grossettisetfiles: + h2py.py.patch
keywords: + patch
2008-06-11 08:26:06grossetticreate