Skip to content

Add support of bytes objects in PyBytes_FromFormatV() #55041

Closed

Description

@vstinner
BPO 10832
Nosy @vstinner
Files
  • pybytes_fromformat_y.patch
  • 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 2011-05-24.23:43:47.363>
    created_at = <Date 2011-01-05.02:55:05.972>
    labels = ['interpreter-core', 'invalid']
    title = 'Add support of bytes objects in PyBytes_FromFormatV()'
    updated_at = <Date 2011-05-24.23:43:47.361>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2011-05-24.23:43:47.361>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2011-05-24.23:43:47.363>
    closer = 'vstinner'
    components = ['Interpreter Core']
    creation = <Date 2011-01-05.02:55:05.972>
    creator = 'vstinner'
    dependencies = []
    files = ['20268']
    hgrepos = []
    issue_num = 10832
    keywords = ['patch']
    message_count = 3.0
    messages = ['125398', '125401', '136811']
    nosy_count = 1.0
    nosy_names = ['vstinner']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue10832'
    versions = ['Python 3.3']

    Activity

    1. vstinner commented on Jan 5, 2011

      @vstinner
      MemberAuthor

      It would be very practical use have a format, eg. '%y', to accept bytes object in PyBytes_FromFormatV().

      Example (extracted from posixmodule.c):

              k = PyBytes_AsString(key2);
              v = PyBytes_AsString(val2);
              len = PyBytes_GET_SIZE(key2) + PyBytes_GET_SIZE(val2) + 2;
              p = PyMem_NEW(char, len);
              if (p == NULL) { PyErr_NoMemory(); ... }
              PyOS_snprintf(p, len, "%s=%s", k, v);

      With %y, it can be written:

              p = PyBytes_FromFormat("%y=%y", key2, val2);
              if (p == NULL) { PyErr_NoMemory(); ... }

      The '%y' may also accept bytearray and any object with the buffer interface (as the 'y' format of PyArg_Parse*() functions).

    2. vstinner commented on Jan 5, 2011

      @vstinner
      MemberAuthor

      Patch implementing this feature. It only supports bytes.

    3. vstinner commented on May 24, 2011

      @vstinner
      MemberAuthor

      The "%y" format is useless for the posixmodule.c example (it doesn't simplify the code), and I cannot find another usage of this feature. So let's forget it :-)

    4. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      interpreter-core(Objects, Python, Grammar, and Parser dirs)

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions