Benjamin Peterson | 23 Nov 06:45 2011

[RELEASED] six 1.1

I'm pleased to announce the immediate availability of six 1.1.0. six
is a small compatibility library for writing code that works on Python
2 and 3 without modification.

six 1.1 features several incremental improvements over 1.0. The
complete list of changes is:

- Add the int2byte function for converting an int of value less than
256 to a bytes object.

- Add compatibility mappings for iterators over the keys, values, and
items of a dictionary.

- Fix six.MAXSIZE on platforms where sizeof(long) != sizeof(Py_ssize_t).

- Issue #3: Add six.moves mappings for filter, map, and zip.

You can download six on PyPi:
    http://pypi.python.org/pypi/six

The documentation is at:
    http://packages.python.org/six/

Please report bugs at:
    http://bitbucket.org/gutworth/six

Regards,
Benjamin
Barry Warsaw | 23 Nov 16:14 2011

Re: [RELEASED] six 1.1

On Nov 22, 2011, at 11:45 PM, Benjamin Peterson wrote:

>I'm pleased to announce the immediate availability of six 1.1.0. six
>is a small compatibility library for writing code that works on Python
>2 and 3 without modification.

Nice.  I skimmed the documentation, and there are definitely a few things that
I think would have been helpful in my current porting tasks.  I especially
like with_metaclass() since that's the one syntax that I've had to resort to
exec'ing for.

There are some good porting guides out there, but I've found some holes, at
both the Python and C levels.  I'll write up the details (e.g. __next__()
vs. next()) hopefully today, I've also found a few more traps and tricks for
extension modules.  I wonder if you have any interest in adding some C level
portability helpers.

Cheers,
-Barry
Benjamin Peterson | 23 Nov 17:55 2011

Re: [RELEASED] six 1.1

2011/11/23 Barry Warsaw <barry <at> python.org>:
> On Nov 22, 2011, at 11:45 PM, Benjamin Peterson wrote:
>
>>I'm pleased to announce the immediate availability of six 1.1.0. six
>>is a small compatibility library for writing code that works on Python
>>2 and 3 without modification.
> Nice.  I skimmed the documentation, and there are definitely a few things that
> I think would have been helpful in my current porting tasks.  I especially
> like with_metaclass() since that's the one syntax that I've had to resort to
> exec'ing for.

Glad to be helpful. :)

>
> There are some good porting guides out there, but I've found some holes, at
> both the Python and C levels.  I'll write up the details (e.g. __next__()
> vs. next()) hopefully today, I've also found a few more traps and tricks for
> extension modules.  I wonder if you have any interest in adding some C level
> portability helpers.

You mean like a header file with macros for PyInt -> PyLong/PyString
-> PyUnicode etc?

--

-- 
Regards,
Benjamin
_______________________________________________
Python-porting mailing list
Python-porting <at> python.org
http://mail.python.org/mailman/listinfo/python-porting
(Continue reading)

Barry Warsaw | 23 Nov 21:59 2011

Re: [RELEASED] six 1.1

On Nov 23, 2011, at 10:55 AM, Benjamin Peterson wrote:

>2011/11/23 Barry Warsaw <barry@...>:
>> both the Python and C levels.  I'll write up the details (e.g. __next__()
>> vs. next()) hopefully today, I've also found a few more traps and tricks for
>> extension modules.  I wonder if you have any interest in adding some C level
>> portability helpers.
>
>You mean like a header file with macros for PyInt -> PyLong/PyString
>-> PyUnicode etc?

There are a bunch of little things I've found helpful while porting
dbus-python.  I think some at least would be generally useful for extension
modules.  Here's a quick summary (so far :).  I should note first that I only
care about Python 2.6, 2.7, and 3.2.  I think there was only one case where
2.6 didn't have what I needed.

I tried to reduce the number of #ifdefs in the code by converting some things
that can be made common between the two versions.

 - In Python 2, I always #include <bytesobject.h> and unilaterally change all
   PyString names to PyBytes names.  That reduces a lot of the ugliness.

 - I changed all the reprs to return unicodes in both Python versions instead
   of conditionally continuing to return strings in Python 2.  That reduced
   another source of noise, but I had to use a little trick with
   PyUnicode_FromFormat().  The reprs in this package embed the repr of the
   parent class, but you don't know whether that will be a bytes (under Python
   2) or a unicode (under Python 3).  It was fairly ugly to ifdef around this,
   so instead of using either the %s or %U codes wrapped in macros, I use the
(Continue reading)

David Malcolm | 24 Nov 16:22 2011
Picon

Re: [RELEASED] six 1.1

On Wed, 2011-11-23 at 15:59 -0500, Barry Warsaw wrote:
[...snip...]
> There are a bunch of little things I've found helpful while porting
> dbus-python.  [...snip...]

BTW, for porting dbus-python to py3k, did you see:
  https://bugs.freedesktop.org/show_bug.cgi?id=26420

Dave
Barry Warsaw | 27 Nov 02:05 2011

Re: [RELEASED] six 1.1

On Nov 24, 2011, at 10:22 AM, David Malcolm wrote:

>On Wed, 2011-11-23 at 15:59 -0500, Barry Warsaw wrote:
>[...snip...]
>> There are a bunch of little things I've found helpful while porting
>> dbus-python.  [...snip...]
>
>BTW, for porting dbus-python to py3k, did you see:
>https://bugs.freedesktop.org/show_bug.cgi?id=26420

Yep.  I did review the patch in the Fedora tracker, but I need to review this
again now that I'm farther along.  I still don't know whether Simon will like
my changes, but I will post my diff to that issue early next week.

I should note though that the test suite for the version in Ubuntu doesn't
fully pass even with Python 2.6 or 2.7, and it fails in my branch in the same
way.  I'd like to try to get that fixed, or at least see if the upstream
branch fails in the same way.  I am also seeing one test hang for reasons I
haven't figured out yet (but I have a suspicion ;).

Cheers,
-Barry
_______________________________________________
Python-porting mailing list
Python-porting@...
http://mail.python.org/mailman/listinfo/python-porting

Gmane