Skip to content

Replace buffer()-->memoryview() in Lib/ctypes/test/ #51952

Closed

Description

@florentx
mannequin
BPO 7703
Nosy @theller, @pitrou, @florentx
Files
  • issue7703_ctypes_memoryview.diff: Patch, apply to trunk
  • issue7703_test_ctypes.diff: Patch, apply to trunk
  • 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 = 'https://github.com/theller'
    closed_at = <Date 2010-03-22.16:09:41.610>
    created_at = <Date 2010-01-14.14:17:09.816>
    labels = ['ctypes', 'type-bug']
    title = 'Replace buffer()-->memoryview() in Lib/ctypes/test/'
    updated_at = <Date 2010-03-22.16:09:41.580>
    user = 'https://github.com/florentx'

    bugs.python.org fields:

    activity = <Date 2010-03-22.16:09:41.580>
    actor = 'flox'
    assignee = 'theller'
    closed = True
    closed_date = <Date 2010-03-22.16:09:41.610>
    closer = 'flox'
    components = ['ctypes']
    creation = <Date 2010-01-14.14:17:09.816>
    creator = 'flox'
    dependencies = []
    files = ['15875', '15876']
    hgrepos = []
    issue_num = 7703
    keywords = ['patch']
    message_count = 13.0
    messages = ['97765', '97766', '97768', '97769', '97772', '97773', '97867', '97868', '97872', '97877', '97885', '97886', '101518']
    nosy_count = 3.0
    nosy_names = ['theller', 'pitrou', 'flox']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue7703'
    versions = ['Python 2.7']

    Activity

    1. florentx commented on Jan 14, 2010

      florentxmannequin
      MannequinAuthor

      In order to upgrate the tests for ctypes, following changes are required:

      • binascii.hexlify should accept memoryview() objects
      • the ctypes character buffer should accept assignment of memoryview() objects using their "raw" property

      Then we can backport the Py3 ctypes tests to Py2.

    2. added
      type-bug
      on Jan 14, 2010
    3. florentx commented on Jan 14, 2010

      florentxmannequin
      MannequinAuthor

      Patches attached:

    4. pitrou commented on Jan 14, 2010

      @pitrou
      Member

      Does binascii still work with array.array objects? Also, there should be additional tests for compatibility of binascii with memoryview objects.

    5. florentx commented on Jan 14, 2010

      florentxmannequin
      MannequinAuthor

      Additional tests for binascii.

    6. pitrou commented on Jan 14, 2010

      @pitrou
      Member

      Please be careful with the coding style. Stuff like:

      + if (_PyString_Resize(&rv, 2*out_len) < 0) \
      + { Py_DECREF(rv); PyBuffer_Release(&pin); return NULL; } \

      should be spread out on several lines.
      Otherwise, the binascii patch looks good.

    7. pitrou commented on Jan 14, 2010

      @pitrou
      Member

      I've now committed the binascii patch + tests to trunk, and merged the tests into py3k.

      Note: binascii_a2b_hqx() still uses the "t#" argument specifier in py3k as well as in trunk, this would deserve a separate patch.

    8. florentx commented on Jan 16, 2010

      florentxmannequin
      MannequinAuthor

      Patch for the last "t#" format string in binascii module.
      And provide additional tests.

      PS: I removed this comment. IMHO, it is a wrong assertion:
      "# The hqx test is in test_binhex.py"

    9. pitrou commented on Jan 16, 2010

      @pitrou
      Member

      I don't think the bytes -> bytearray changes are useful, e.g.:

      •    fillers = ""
        

      + fillers = bytearray()

      As for:

      + try:
      + f(empty)
      + except SystemError, err:
      + self.fail("{}({!r}) raises SystemError: {}".format(func, empty, err))
      + except Exception, err:
      + self.fail("{}({!r}) raises {!r}".format(func, empty, err))

      The "except SystemError" is pointless, since "except Exception" will catch SystemError anyway.

    10. florentx commented on Jan 16, 2010

      florentxmannequin
      MannequinAuthor

      Changed.

    11. florentx commented on Jan 16, 2010

      florentxmannequin
      MannequinAuthor

      Removed no-op str("...") conversions.

    12. pitrou commented on Jan 16, 2010

      @pitrou
      Member

      When the following snippet is taken:

      	if (_PyString_Resize(&rv,
      			   (bin_data -
      			    (unsigned char *)PyString_AS_STRING(rv))) < 0) {
      		PyBuffer_Release(&pascii);
      		Py_DECREF(rv);
      		rv = NULL;
      	}

      pascii will get released a second time at the end of function. The rest is fine, I'm gonna fix it myself.

    13. pitrou commented on Jan 16, 2010

      @pitrou
      Member

      The a2b_hqx() patch was committed in r77528 (trunk) and r77529 (py3k). Thanks again!

    14. florentx commented on Mar 22, 2010

      florentxmannequin
      MannequinAuthor

      Fixed with r79288 and r79295.

    15. 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

    Labels

    topic-ctypestype-bug

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions