From benjamin at python.org  Sun Sep 17 14:51:15 2017
From: benjamin at python.org (Benjamin Peterson)
Date: Sun, 17 Sep 2017 11:51:15 -0700
Subject: [Python-porting] six 1.11.0
Message-ID: <1505674275.2167132.1109002928.2987493A@webmail.messagingengine.com>

It's been a while, but six 1.11.0 is now live on PyPI! six is a Python
2&3 compatibility library.

Many thanks to the various contributors who did most the work.

Here is the changelog for 1.11.0:

- Pull request #178: `with_metaclass` now properly proxies `__prepare__`
to the
  underlying metaclass.

- Pull request #191: Allow `with_metaclass` to work with metaclasses
implemented
  in C.

- Pull request #203: Add parse_http_list and parse_keqv_list to moved
  urllib.request.

- Pull request #172 and issue #171: Add unquote_to_bytes to moved
urllib.parse.

- Pull request #167: Add `six.moves.getoutput`.

- Pull request #80: Add `six.moves.urllib_parse.splitvalue`.

- Pull request #75: Add `six.moves.email_mime_image`.

- Pull request #72: Avoid creating reference cycles through tracebacks
in
  `reraise`.

From guettliml at thomas-guettler.de  Tue Sep  5 08:44:59 2017
From: guettliml at thomas-guettler.de (=?UTF-8?Q?Thomas_G=c3=bcttler?=)
Date: Tue, 5 Sep 2017 14:44:59 +0200
Subject: [Python-porting] repr() with same output on Python2.7 and Python3.x
Message-ID: <ee767839-2dbd-05dc-203b-f0e8b366a4a6@thomas-guettler.de>

Hi,	

I have a Python 2.7 code base before me, where some tests contain the output of repr().

On Python2.7 I see u'foo' and on Python3 I see 'foo'.

This is the reason why some tests fail.

Is there a repr() which outputs the same string on Python2.7 and Python3?

It would be nice if I could get the Python3 output on Python2.7

Regards,
   Thomas G?ttler

-- 
Thomas Guettler http://www.thomas-guettler.de/

From guettliml at thomas-guettler.de  Mon Sep 11 09:12:56 2017
From: guettliml at thomas-guettler.de (=?UTF-8?Q?Thomas_G=c3=bcttler?=)
Date: Mon, 11 Sep 2017 15:12:56 +0200
Subject: [Python-porting] repr() with same output on Python2.7 and Python3.x
Message-ID: <6ff499f6-a418-81e2-f8b2-88e72cfa268e@thomas-guettler.de>

Hi,	

I have a Python 2.7 code base before me, where some tests contain the output of repr().

On Python2.7 I see u'foo' and on Python3 I see 'foo'.

This is the reason why some tests fail.

Is there a repr() which outputs the same string on Python2.7 and Python3?

It would be nice if I could get the Python3 output on Python2.7

Regards,
   Thomas G?ttler

-- 
Thomas Guettler http://www.thomas-guettler.de/

From chris.jerdonek at gmail.com  Mon Sep 18 14:09:50 2017
From: chris.jerdonek at gmail.com (Chris Jerdonek)
Date: Mon, 18 Sep 2017 18:09:50 +0000
Subject: [Python-porting] repr() with same output on Python2.7 and
 Python3.x
In-Reply-To: <6ff499f6-a418-81e2-f8b2-88e72cfa268e@thomas-guettler.de>
References: <6ff499f6-a418-81e2-f8b2-88e72cfa268e@thomas-guettler.de>
Message-ID: <CAOTb1weOjyRiXJcZZv1ckQ9VSwHRHF=aK3pnp8zxykb0f_1Rig@mail.gmail.com>

This doesn't seem possible in general because __repr__() can contain
arbitrary code, and it could have different logic depending on whether it's
being executed in Python 2 or 3. Is there a more constrained question you
can ask, maybe for the repr of certain types of objects?

There are also various hacks you could do, like in your test equality
checker, replace "u'" with "'" in the given string before comparing.

--Chris


On Mon, Sep 18, 2017 at 10:59 AM Thomas G?ttler <
guettliml at thomas-guettler.de> wrote:

> Hi,
>
> I have a Python 2.7 code base before me, where some tests contain the
> output of repr().
>
> On Python2.7 I see u'foo' and on Python3 I see 'foo'.
>
> This is the reason why some tests fail.
>
> Is there a repr() which outputs the same string on Python2.7 and Python3?
>
> It would be nice if I could get the Python3 output on Python2.7
>
> Regards,
>    Thomas G?ttler
>
> --
> Thomas Guettler http://www.thomas-guettler.de/
> _______________________________________________
> Python-porting mailing list
> Python-porting at python.org
> https://mail.python.org/mailman/listinfo/python-porting
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-porting/attachments/20170918/bdb45707/attachment.html>

From rstoyanov1 at gmail.com  Fri Sep 29 04:17:46 2017
From: rstoyanov1 at gmail.com (Radostin Stoyanov)
Date: Fri, 29 Sep 2017 09:17:46 +0100
Subject: [Python-porting] python 2/3 compatibility of function call
Message-ID: <652c277c-52c1-25a7-6eda-3d8042a41cb1@gmail.com>

Hello all,

I am working on a patch series for virt-manager [1] which aims to
resolve compatibility issues with Python 3. However I stuck with the
following issue:

1. When I run the tests with Python 3 some of them fail with:

??? TypeError: set_memory_cb() takes 4 positional arguments but 5 were given

These errors are coming from this function call
<https://github.com/virt-manager/virt-manager/blob/master/virtinst/cli.py#L927>:

??? self.cb(parser, inst, self.val, self)

Where `self.cb` is assigned to `ParserMemory.set_memory_cb`.

I found that the concept of ?unbound methods? has been removed in Python
3. [2]
When referencing a method as a class attribute, you now get a plain
function object.

Example:

- Python 2????????????????????????????????

??? >>> class X:????????????????????????????
??? ...???? def foo(self): return 1?????????
??? ...?????????????????????????????????????
??? >>> bar = X.foo?????????????????????????
??? >>> type(bar)???????????????????????????
??? <type 'instancemethod'>?????????????????
??? >>> X.foo(X())??????????????????????????
??? 1???????????????????????????????????????
??? >>> X.foo(0)????????????????????????????
??? Traceback (most recent call last):??????
????? File "<stdin>", line 1, in <module>???
??? TypeError: unbound method foo() must be c
??? alled with X instance as first argument (
??? got int instance instead)

- Pyhton 3

???>>> class X:
??? ...???? def foo(self): return 1
??? ...
??? >>> bar = X.foo
??? >>> type(bar)
??? <class 'function'>
??? >>> X.foo(X())
??? 1
??? >>> X.foo(0)
??? 1

However, I could not reproduce the issue causing TypeError as above. One
hacky solution could be to change functions like `set_memory_cb` in the
following way:

from

??? def set_memory_cb(self, inst, val, virtarg):
??????? setattr(inst, virtarg.cliname, int(val) * 1024)

to

??? def set_memory_cb(self, inst, val, virtarg, ignore=None):
??????? if ignore:
??????????? self, inst, val, virtarg = inst, val, virtarg, ignore
???????? setattr(inst, virtarg.cliname, int(val) * 1024)

However,? I would like to ask for suggestions on how this issue could be
resolved properly?

[1] https://github.com/virt-manager/virt-manager
[2]
https://docs.python.org/release/3.0.1/whatsnew/3.0.html#operators-and-special-methods

Kind Regards,
Radostin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-porting/attachments/20170929/76a7f41d/attachment.html>