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

deprecated conversion from string constant to char * #51201

Closed
barry-scott mannequin opened this issue Sep 20, 2009 · 13 comments
Closed

deprecated conversion from string constant to char * #51201

barry-scott mannequin opened this issue Sep 20, 2009 · 13 comments
Labels
build The build process and cross-build extension-modules C modules in the Modules dir

Comments

@barry-scott
Copy link
Mannequin

barry-scott mannequin commented Sep 20, 2009

BPO 6952
Nosy @loewis, @barry-scott, @bitdancer, @Trundle, @berkerpeksag
Files
  • const_api_r75468.patch: Patch to add const to python API for strings
  • const_api_r75619.patch: Patch to add const to python API for strings (2)
  • 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 2018-08-05.00:57:44.271>
    created_at = <Date 2009-09-20.11:29:45.718>
    labels = ['extension-modules', 'build']
    title = 'deprecated conversion from string constant to char *'
    updated_at = <Date 2018-08-05.00:57:44.222>
    user = 'https://github.com/barry-scott'

    bugs.python.org fields:

    activity = <Date 2018-08-05.00:57:44.222>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-08-05.00:57:44.271>
    closer = 'berker.peksag'
    components = ['Extension Modules']
    creation = <Date 2009-09-20.11:29:45.718>
    creator = 'barry-scott'
    dependencies = []
    files = ['15156', '15184']
    hgrepos = []
    issue_num = 6952
    keywords = ['patch']
    message_count = 13.0
    messages = ['92890', '92917', '92931', '92938', '92940', '92942', '94184', '94189', '94214', '94223', '94368', '110580', '323126']
    nosy_count = 6.0
    nosy_names = ['loewis', 'barry-scott', 'sebastinas', 'r.david.murray', 'Trundle', 'berker.peksag']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'compile error'
    url = 'https://bugs.python.org/issue6952'
    versions = ['Python 3.2']

    @barry-scott
    Copy link
    Mannequin Author

    barry-scott mannequin commented Sep 20, 2009

    Many Python API functions are causing GCC to rightly complain
    that const char * strings are being passed to python functions
    that take char * but do not need to modify the args.

    g++ reports example.cxx:633: warning: deprecated conversion from string
    constant to ‘char*’

    The example I encountered today, while testing PyCXX against
    G++ 4.2.1 on Mac OS X, was PyObject_CallMethod
    but it is not limited to this function.

    Would a patch help progress this issue?

    @barry-scott barry-scott mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) build The build process and cross-build labels Sep 20, 2009
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Sep 20, 2009

    A patch would definitely help. Such a patch shouldn't whole-sale replace
    char with const char, but selectively only change locations where it is
    actually necessary and doesn't hurt.

    @Trundle
    Copy link
    Mannequin

    Trundle mannequin commented Sep 21, 2009

    See also issue bpo-1699259.

    @barry-scott
    Copy link
    Mannequin Author

    barry-scott mannequin commented Sep 21, 2009

    I'd guess that this change can first be made against 2.7 and 3.2
    so that API's do not change.

    Where do I find the source code to generate the patch against
    for 2.7 and 3.2?

    @bitdancer
    Copy link
    Member

    Take a look at http://www.python.org/dev, specifically the 'How to Get
    Started' article (which points you to the developer's FAQ, which
    explains how to do an anonymous checkout of the source).

    @bitdancer
    Copy link
    Member

    I'm setting the targets to 2.7/3.2 per the discussion in issue bpo-1699259.
    Perhaps the question of whether or not it is "really" an API change
    could be revisited, but if so that would probably have to go through
    python-dev.

    @barry-scott
    Copy link
    Mannequin Author

    barry-scott mannequin commented Oct 17, 2009

    Here is my 1st patch to allow const char * and const Py_UNICODE *
    It is agsinst http://svn.python.org/projects/python/trunk.

    What I have attempted to do is stop the public API of python needing
    char * or Py_UNICODE * where the API clearly does not need to modify
    the argument. I have only modified internal API where its necessary
    to provide a public const API.

    Please give feedback and let me know if you wish me raise anything
    with python dev.

    I'm happy to produce a 3.2 version of the patch after the 2.7 version
    is acceptable.

    Barry

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Oct 17, 2009

    Without looking into the details: the places where you cast-away
    constness look wrong. Either the parameter shouldn't have been declared
    const, or the target of the assignment needs to be converted to const,
    too. If the cast is really legitimite, a comment needs to justify it
    (but then, I think I would still prefer not to change the parameter to
    const).

    @barry-scott
    Copy link
    Mannequin Author

    barry-scott mannequin commented Oct 18, 2009

    I was trying to avoid changing the const ness of output parameters.
    Given the advice not to go mad on putting const everywhere.

    1. I can comment the casts to maintain this goal.
    2. Or change the output paramter const ness.

    Given your feedback I'm guessing you want me to go further with
    the use of const and do (2).

    Barry

    @barry-scott barry-scott mannequin added extension-modules C modules in the Modules dir and removed interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Oct 18, 2009
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Oct 18, 2009

    1. I can comment the casts to maintain this goal.
    2. Or change the output paramter const ness.

    Given your feedback I'm guessing you want me to go further with
    the use of const and do (2).

    Ah, ok - as I said, I didn't look into detail further. IIUC, changing
    output parameters to const could break existing code (right?); this
    should be avoided absolutely.

    Rather than having the casts, I think I would prefer to take no action
    at these places; I recommend to discuss that on python-dev (some may
    argue in favor of changing output pointers to const if that is
    semantically correct).

    @barry-scott
    Copy link
    Mannequin Author

    barry-scott mannequin commented Oct 22, 2009

    Updated patch with comment explaining cast.

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 17, 2010

    Drop 2.7 as it's gone. See also bpo-1699259.

    @berkerpeksag
    Copy link
    Member

    All changes (except PyUnicode_EncodeDecimal() which was deprecated in Python 3.3) have already been implemented in the following commits:

    Closing this as 'out of date'.

    @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
    build The build process and cross-build extension-modules C modules in the Modules dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants