#801 closed task (fixed)

Investigate Py_ssize_t behavior in wrappers for CPython < 2.5

Reported by: nejucomo Owned by: nejucomo
Priority: minor Milestone: 1.6.0
Component: code Version: 1.5.0
Keywords: wrapper cast Cc:
Launchpad Bug:

Description

Py_ssize_t was introduced in CPython 2.5 in Pep 353 [1]. Older Python wrappers treated sizes inconsistently.

This ticket is closed when:

  1. An explanation is given of how wrapper code that relies on Py_ssize_t compiles in pre 2.5 environments (start with [2]).
  1. A unit test is written which determines if code relying on Py_ssize_t behaves correctly on < 2.5 and >= 2.5 platforms.
  1. If the unit test shows no distinction between the two version cases, an explanation of why there's no failure in all cases. Otherwise, jump to step b and devise a new unit test.
  1. A ticket is opened for each created failing unit test.

[1] http://www.python.org/dev/peps/pep-0353/ [2] http://www.google.com/search?q=Py_ssize_t

Change History (6)

comment:1 Changed at 2009-09-11T03:17:32Z by zooko

  1. Python 2.4 just uses int as the type of values which hold the sizes of arrays. We have the following stanza at the top of each .cpp file:
#if (PY_VERSION_HEX < 0x02050000)
typedef int Py_ssize_t;
#endif

This creates a Py_ssize_t type, which is actually int, if the Python version is < 2.5.0. The only thing to be safe is to pass objects of type Py_ssize_t (instead of int or size_t as I apparently did) to PyArg_ParseTupleAndKeywords() as a "#" argument. Your patch does that.

  1. We already have tests of (most of?) the CPython wrapper code, and we already have a Python 2.4 buildbot: http://allmydata.org/buildbot-pycryptopp/builders/solaris-amd64-nexenta-nooxie . Is there any more specific way that you can think of to test that the wrapper code is passing an object of the right size as the "#" argument?
  1. Explanation is that typedef.

Good? :-)

comment:2 Changed at 2009-09-11T03:17:56Z by zooko

P.S. Step (e), release a new version of pycryptopp as soon as you've signed off on this ticket...

comment:3 Changed at 2009-09-11T21:12:58Z by zooko

Everyone please see http://allmydata.org/trac/pycryptopp/ticket/19#comment:8 and post your results.

comment:4 Changed at 2009-10-02T19:08:00Z by zooko

  • Owner changed from nobody to nejucomo

Nej: good enough? Then please close this ticket.

comment:5 Changed at 2009-12-01T00:21:09Z by davidsarah

  • Component changed from unknown to code
  • Milestone changed from undecided to 1.6.0

comment:6 Changed at 2009-12-01T00:42:59Z by zooko

  • Resolution set to fixed
  • Status changed from new to closed

nejucomo closed the sister ticket http://allmydata.org/trac/pycryptopp/ticket/19 so I'm closing this one.

Note: See TracTickets for help on using tickets.