Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

h2py char literal doesn't work #47327

Closed
grossetti mannequin opened this issue Jun 11, 2008 · 3 comments
Closed

h2py char literal doesn't work #47327

grossetti mannequin opened this issue Jun 11, 2008 · 3 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@grossetti
Copy link
Mannequin

grossetti mannequin commented Jun 11, 2008

BPO 3077
Nosy @birkenfeld
Files
  • 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.
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2010-10-21.13:29:18.708>
    created_at = <Date 2008-06-11.08:26:06.570>
    labels = ['type-bug']
    title = "h2py char literal doesn't work"
    updated_at = <Date 2010-10-21.13:29:18.706>
    user = 'https://bugs.python.org/grossetti'

    bugs.python.org fields:

    activity = <Date 2010-10-21.13:29:18.706>
    actor = 'georg.brandl'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-10-21.13:29:18.708>
    closer = 'georg.brandl'
    components = ['Demos and Tools']
    creation = <Date 2008-06-11.08:26:06.570>
    creator = 'grossetti'
    dependencies = []
    files = ['10578', '10579']
    hgrepos = []
    issue_num = 3077
    keywords = ['patch']
    message_count = 3.0
    messages = ['67943', '109946', '119288']
    nosy_count = 3.0
    nosy_names = ['georg.brandl', 'grossetti', 'BreamoreBoy']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue3077'
    versions = ['Python 3.1', 'Python 2.7', 'Python 3.2']

    @grossetti
    Copy link
    Mannequin Author

    grossetti mannequin commented Jun 11, 2008

    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

    @grossetti grossetti mannequin added the type-bug An unexpected behavior, bug, or error label Jun 11, 2008
    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 10, 2010

    Both patch files are two liners, could someone please take a look and decide if one of them can be accepted?

    @BreamoreBoy BreamoreBoy mannequin changed the title h2py char literal doesn work h2py char literal doesn't work Jul 10, 2010
    @birkenfeld
    Copy link
    Member

    Fixed in r85770.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant