From brett at yvrsfo.ca  Wed Mar 12 12:40:02 2014
From: brett at yvrsfo.ca (Brett Cannon)
Date: Wed, 12 Mar 2014 07:40:02 -0400
Subject: [Python-porting] Caniusepython3
In-Reply-To: <CAP1=2W6w4AbkXrz2m41=y9CN56nAaJz56cpKTgBSH0zYV8ENfA@mail.gmail.com>
References: <CAP1=2W6w4AbkXrz2m41=y9CN56nAaJz56cpKTgBSH0zYV8ENfA@mail.gmail.com>
Message-ID: <CAP1=2W5rVq5u3duKMZBGNPe5Ttd6RCuCRuHm34ydSWLcjZD8yQ@mail.gmail.com>

I keep forgetting to mention here that I created
https://pypi.python.org/pypi/caniusepython3 to help projects figure out who
is holding up their port. Jannis Leidel has also created a web front-end at
caniuseputhon3.com .
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-porting/attachments/20140312/6dabe58f/attachment.html>

From yarkot1 at gmail.com  Wed Mar 12 13:16:20 2014
From: yarkot1 at gmail.com (Yarko Tymciurak)
Date: Wed, 12 Mar 2014 07:16:20 -0500
Subject: [Python-porting] Caniusepython3
In-Reply-To: <CAP1=2W5rVq5u3duKMZBGNPe5Ttd6RCuCRuHm34ydSWLcjZD8yQ@mail.gmail.com>
References: <CAP1=2W6w4AbkXrz2m41=y9CN56nAaJz56cpKTgBSH0zYV8ENfA@mail.gmail.com>
 <CAP1=2W5rVq5u3duKMZBGNPe5Ttd6RCuCRuHm34ydSWLcjZD8yQ@mail.gmail.com>
Message-ID: <CAJ+Z=P+Rv9KKkEBgqKw3TZh0zi--FbykJFYNcjuYP4=mDq-U-g@mail.gmail.com>

On Mar 12, 2014 6:40 AM, "Brett Cannon" <brett at yvrsfo.ca> wrote:
>
> I keep forgetting to mention here that I created
https://pypi.python.org/pypi/caniusepython3 to help projects figure out who
is holding up their port. Jannis Leidel has also created a web front-end at
caniuseputhon3.com .

Thanks Brett!

Minor typo: caniusepython3.com

>
>
> _______________________________________________
> 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/20140312/3a16adfe/attachment.html>

From benjamin at python.org  Wed Mar 12 18:39:23 2014
From: benjamin at python.org (Benjamin Peterson)
Date: Wed, 12 Mar 2014 10:39:23 -0700
Subject: [Python-porting] six 1.5.2 breaks calendar server 5.1
In-Reply-To: <78D20541-C3FC-46B2-9031-3B6050B4FA92@Chaos1.DE>
References: <78D20541-C3FC-46B2-9031-3B6050B4FA92@Chaos1.DE>
Message-ID: <1394645963.4582.93691921.3A86E1BA@webmail.messagingengine.com>

On Tue, Jan 21, 2014, at 10:44 AM, Axel Rau wrote:
> Hi,
> While preparing a FreeBSD port of calendar server 5.1, I get
> ---
> Traceback (most recent call last):
>   File "/usr/local/bin/calendarserver_manage_principals", line 32, in
>   <module>
>     main()
>   File
>   "/usr/local/lib/python2.7/site-packages/calendarserver/tools/principals.py",
>   line 333, in main
>     utilityMain(configFileName, PrincipalService, verbose=verbose)
>   File
>   "/usr/local/lib/python2.7/site-packages/calendarserver/tools/cmdline.py",
>   line 95, in utilityMain
>     service = maker.makeService(options)
>   File
>   "/usr/local/lib/python2.7/site-packages/calendarserver/tap/caldav.py",
>   line 746, in makeService
>     replaceTwistedLoggers()
>   File "/usr/local/lib/python2.7/site-packages/twext/python/log.py", line
>   937, in replaceTwistedLoggers
>     newLogger = Logger(namespace=module.__name__)
>   File "/usr/local/lib/python2.7/site-packages/six.py", line 115, in
>   __getattr__
>     raise AttributeError
> AttributeError
> ---
> See https://trac.calendarserver.org/ticket/832

The note in this section of the docs may help you:
https://six.readthedocs.org/#module-six.moves

From bcannon at gmail.com  Wed Mar 12 16:17:06 2014
From: bcannon at gmail.com (Brett Cannon)
Date: Wed, 12 Mar 2014 15:17:06 +0000
Subject: [Python-porting]  edge case
References: <52FE9F60.1000500@dewhirst.com.au>
Message-ID: <CAP1=2W4Z9s57on0GEbMGeAPKARghi4EAVHX_qqJdrkwi9vgrsA@mail.gmail.com>

I hope Ed is on this mailing list, but in case he isn't you might want to
file an official bug at https://github.com/PythonCharmers/python-future .

On Wed Mar 12 2014 at 7:24:49 AM, Mike Dewhirst <miked at dewhirst.com.au>
wrote:

> While porting a project - all modules at once - futurize threw a
> traceback without contextual clues for which of my modules it found
> problematic.
>
> Traceback (most recent call last):
>   ... (snipped)
>    File
> "c:\users\miked\env\xxdx\lib\site-packages\libfuturize\fixer_util.py",
> line 373, in check_future_import
>      assert 0, "strange import"
> AssertionError: strange import
>
>
> Rather than start again one module at a time I rummaged around line 373
> in fixer_util.py to see what it was trying to do.
>
>
> I hacked it as follows:
>
> ---
> C:/users/miked/env/xxdx/Lib/site-packages/libfuturize/fixer_util.py~
>  Sat
> Feb 15 09:33:01 2014
> +++ C:/users/miked/env/xxdx/Lib/site-packages/libfuturize/fixer_util.py
> Sat Feb 15 09:33:17 2014
> @@ -341,6 +341,7 @@ def check_future_import(node):
>       """If this is a future import, return set of symbols that are
> imported,
>       else return None."""
>       # node should be the import statement here
> +    savenode = node
>       if not (node.type == syms.simple_stmt and node.children):
>           return set()
>       node = node.children[0]
> @@ -370,6 +371,6 @@ def check_future_import(node):
>       elif node.type == token.NAME:
>           return set([node.value])
>       else:
> -        assert 0, "strange import"
> +        assert 0, "strange import: %s" % savenode
>
> Then I ran futurize again and got a clue ...
>
> Traceback (most recent call last):
>   ... (snipped)
>    File
> "c:\users\miked\env\xxdx\lib\site-packages\libfuturize\fixer_util.py",
> line 374, in check_future_import
>      assert 0, "strange import: %s" % savenode
> AssertionError: strange import: from __future__ import
> (unicode_literals, division)
>
>
> Whereupon I searched for the offending text and removed the parentheses
> from the import line and all was well.
>
> Lovely software - thanks Ed
>
> Mike
> _______________________________________________
> 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/20140312/e4a47f86/attachment-0001.html>

From benjamin at python.org  Fri Mar 14 04:14:45 2014
From: benjamin at python.org (Benjamin Peterson)
Date: Thu, 13 Mar 2014 20:14:45 -0700
Subject: [Python-porting] [RELEASED] six 1.6.0
Message-ID: <1394766885.552.94324617.38287F81@webmail.messagingengine.com>

I'm releasing six 1.6.0. It has a few more backports and another attempt
to solve the great lazy proxy module problem suggested by Diana Clark.

Here's the changelog:

- Raise an AttributeError for every attribute of unimportable modules.

- Issue #56: Make the fake modules six.moves puts into sys.modules
appear not to
  have a __path__ unless they are loaded.

- Pull request #28: Add support for SplitResult.

- Issue #55: Add move mapping for xmlrpc.server.

- Pull request #29: Add move for urllib.parse.splitquery.

From benjamin at python.org  Fri Mar 14 04:16:56 2014
From: benjamin at python.org (Benjamin Peterson)
Date: Thu, 13 Mar 2014 20:16:56 -0700
Subject: [Python-porting] [RELEASED] six 1.6.0
In-Reply-To: <1394766885.552.94324617.38287F81@webmail.messagingengine.com>
References: <1394766885.552.94324617.38287F81@webmail.messagingengine.com>
Message-ID: <1394767016.1343.94325345.40AF0B22@webmail.messagingengine.com>



On Thu, Mar 13, 2014, at 08:14 PM, Benjamin Peterson wrote:
> I'm releasing six 1.6.0. It has a few more backports and another attempt
> to solve the great lazy proxy module problem suggested by Diana Clark.

This should be "Diana Clarke". Sorry!

From wtz_wh at foxmail.com  Tue Mar 18 08:05:12 2014
From: wtz_wh at foxmail.com (=?gb18030?B?sbGx+dHz?=)
Date: Tue, 18 Mar 2014 15:05:12 +0800
Subject: [Python-porting] Issues about relative& absolute import way for
	Porting from python2.4 to python2.7
Message-ID: <tencent_5E9DA5AF493E3C6F437E674A@qq.com>

Dear,


I just wrote a sample like this:
testPy/
         __init__.py
         client.py
         SoamFactory.c
         SoamFactory.so
         soamapi.py
         sample/testP.py
export PYTHONPATH=$(TEST_LOCATION):$(TEST_LOCATION)/testPy
Here's the source codes:
__init__.py:
import client
client.py
import soamapi
class Client(soamapi.SessionCallback):


  def __init__(self):
    print "----class Client----"
    super(Client, self).__init__()
    soamapi.initialize()


  def create_session(self):
    sec_cb = soamapi.DefaultSecurityCallback()
    self.connection = soamapi.connect(sec_cb)

soamapi.py
import SoamFactory


class ConnectionSecurityCallback(object):  
  def __init__(self):
    print "----class ConnectionSecurityCallback----"


  def __del__(self):
    pass


  def test_P(self):
    print "test_P in class ConnectionSecurityCallback"


class DefaultSecurityCallback(ConnectionSecurityCallback):
  def __init__(self):
    super(DefaultSecurityCallback, self).__init__()
    print "----class DefaultSecurityCallback----"


  def __del__(self):
    super(DefaultSecurityCallback, self).__del__()


  def test(self):
    print "test in class DefaultSecurityCallback"


class SessionCallback(object):
  def __init__(self):
    pass
  
  def __del__(self):
    pass


def connect(security_callback):
  return SoamFactory.SoamFactory_connect(security_callback)


def initialize():
  SoamFactory.SoamFactory_initialize()


print "call soamapi"

SoamFactory.c
#include "Python.h"
#include "PythonLoop.c"


PyObject* SOAM_API_MODULE = NULL;
PyObject* pyModule = NULL;


static PyObject* SoamFactory_initialize(PyObject* self, PyObject* args){
    PyEval_InitThreads();
    init();
    Py_RETURN_NONE;
}


static PyObject* SoamFactory_connect(PyObject* self, PyObject* args){
    PyObject* pySecCallback = NULL;
    int ok = PyArg_ParseTuple(args, "O", &pySecCallback);
    if (!ok){
        printf("parse tuple error!\n");
        Py_RETURN_NONE;
    }
    if (! PyObject_IsInstance(pySecCallback, connectSecCallback)){
        printf("pySecCallback is not an instance of ConnectionSecurityCallback!\n");
        Py_RETURN_NONE;
    }
    printf("Successful!\n");
    Py_RETURN_NONE;
}


static PyMethodDef SoamFactory[] = {
    {"SoamFactory_connect", SoamFactory_connect, METH_VARARGS, "connection function"},
    {"SoamFactory_initialize", SoamFactory_initialize, METH_VARARGS, "SoamFactory_initialize"},
    {NULL, NULL}
};


void initSoamFactory(){
    PyEval_InitThreads();
    Py_Initialize();
    pyModule = Py_InitModule("SoamFactory", SoamFactory);
    SOAM_API_MODULE = PyImport_ImportModule("soamapi");
}

sample/testP.py
import testPy


print "========================================"
submitter = testPy.client.Client()
submitter.create_session()
print "========================================"



When I ran it on python2.4, it worked well, and the result was
call soamapi
after import soamapi------client.py
========================================
----class Client----
----class ConnectionSecurityCallback----
----class DefaultSecurityCallback----
Successful!
========================================   
     
But when I ran it on python2.7, it worked beyond my expectation, the result was 
call soamapi
call soamapi
========================================
----class Client----
----class ConnectionSecurityCallback----
----class DefaultSecurityCallback----
pySecCallback is not an instance of ConnectionSecurityCallback!
========================================



I found that soamapi was imported twice, and I investigated this is related to absolute&relative import way.  PyImport_ImportModule in python2.7 uses absolute import way, it will look up sys.path to get soamapi module, and when testP.py file import testPy module, it will find local module soamapi under testPy package, and binds module's name to package, as testPy.soamapi.
There are two ways to correct it for python2.7, 1) Don't use import testPy, use import client directly to avoid using relative; 2) Use from __future__ import absolute_import to enable absolute import feature.


But there are two Pre-conditions:
1) Should not modify testP.py;
2) Should be ran on both python2.4 and 2.7.


I don't know how to fix it. Is there any official way about how to porting this scenario or better idea?


Thanks,
Vatel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-porting/attachments/20140318/3b86f53d/attachment.html>

From regebro at gmail.com  Sun Mar 30 09:51:32 2014
From: regebro at gmail.com (Lennart Regebro)
Date: Sun, 30 Mar 2014 09:51:32 +0200
Subject: [Python-porting] Issues about relative& absolute import way for
 Porting from python2.4 to python2.7
In-Reply-To: <tencent_5E9DA5AF493E3C6F437E674A@qq.com>
References: <tencent_5E9DA5AF493E3C6F437E674A@qq.com>
Message-ID: <CAL0kPAVrfMUcXHMY93NG4gwJv4yWjiifGsGuxKDVRFwgf-VtVg@mail.gmail.com>

On Tue, Mar 18, 2014 at 8:05 AM, ??? <wtz_wh at foxmail.com> wrote:
> export PYTHONPATH=$(TEST_LOCATION):$(TEST_LOCATION)/testPy

This is the fundamental problem. By adding both these locations, you
make each module in testPy importable both as "testPy.something" and
as "something". This means they can be imported twice. As a general
rule, you should avoid modifying PYTHONPATH at all, unless you are
doing something "frameworky".

Although in this case the simplest fix may be to remove the testPy
directory from the PYTHONPATH. I can't see why it would be needed.
Possibly some of the imports need to be made absolute in that case, ie
"from testPy import client" instead of just "import client", etc.

//Lennart

From ndbecker2 at gmail.com  Mon Mar 31 21:34:10 2014
From: ndbecker2 at gmail.com (Neal Becker)
Date: Mon, 31 Mar 2014 15:34:10 -0400
Subject: [Python-porting] questions about future package here?
Message-ID: <lhcfvi$dlj$1@ger.gmane.org>

I'm  just experimenting with future package.

1st problem:
I tried converting a small py2 module
futurize mod.py -w

Then I get segfault. It seems to want to do:

from future.builtins import int

Then when my code says:

<some numpy container>.astype(int)

instead of converting to int, it is converted to object.

So what is this newint anyway?


From dirkjan at ochtman.nl  Mon Mar 31 22:13:43 2014
From: dirkjan at ochtman.nl (Dirkjan Ochtman)
Date: Mon, 31 Mar 2014 22:13:43 +0200
Subject: [Python-porting] Doctests in single-source port
Message-ID: <CAKmKYaDnpg0dWJxWvPDD5ryrjbrcsE-2AvRKjunw_S+tU-KzuA@mail.gmail.com>

Hi there,

I've just had another run at completing my single-source port of
CouchDB-Python (see [1]), trying to converge on something that passes
the test suite on both 2.7 and 3.3. However, I can't think of any
clever ways to deal with doctest failures I'm seeing. Are there any
established best practices or ugly hacks to make this easier? Here are
some typical failures:

======================================================================
FAIL: delete (couchdb.client.Database)
Doctest: couchdb.client.Database.delete
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.3/doctest.py", line 2154, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for couchdb.client.Database.delete
  File "./couchdb/client.py", line 512, in delete

----------------------------------------------------------------------
File "./couchdb/client.py", line 528, in couchdb.client.Database.delete
Failed example:
    db.delete(doc)
Expected:
    Traceback (most recent call last):
      ...
    ResourceConflict: (u'conflict', u'Document update conflict.')
Got:
    Traceback (most recent call last):
      File "/usr/lib/python3.3/doctest.py", line 1287, in __run
        compileflags, 1), test.globs)
      File "<doctest couchdb.client.Database.delete[7]>", line 1, in <module>
        db.delete(doc)
      File "./couchdb/client.py", line 541, in delete
        _doc_resource(self.resource, doc['_id']).delete_json(rev=doc['_rev'])
      File "./couchdb/http.py", line 530, in delete_json
        return self._request_json('DELETE', path, headers=headers, **params)
      File "./couchdb/http.py", line 556, in _request_json
        headers=headers, **params)
      File "./couchdb/http.py", line 552, in _request
        credentials=self.credentials)
      File "./couchdb/http.py", line 404, in request
        raise ResourceConflict(error)
    couchdb.http.ResourceConflict: ('conflict', 'Document update conflict.')

FAIL: ViewResults (couchdb.client)
Doctest: couchdb.client.ViewResults
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.3/doctest.py", line 2154, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for couchdb.client.ViewResults
  File "./couchdb/client.py", line 1097, in ViewResults

----------------------------------------------------------------------
File "./couchdb/client.py", line 1136, in couchdb.client.ViewResults
Failed example:
    list(results[['City', 'Gotham City']])
Expected:
    [<Row id=u'gotham', key=[u'City', u'Gotham City'], value=u'Gotham City'>]
Got:
    [<Row id='gotham', key=['City', 'Gotham City'], value='Gotham City'>]

Thanks for any suggestions,

Dirkjan

[1] https://code.google.com/p/couchdb-python/source/list?name=db566517e8af

From ethan at stoneleaf.us  Mon Mar 31 21:38:52 2014
From: ethan at stoneleaf.us (Ethan Furman)
Date: Mon, 31 Mar 2014 12:38:52 -0700
Subject: [Python-porting] questions about future package here?
In-Reply-To: <lhcfvi$dlj$1@ger.gmane.org>
References: <lhcfvi$dlj$1@ger.gmane.org>
Message-ID: <5339C44C.1030605@stoneleaf.us>

On 03/31/2014 12:34 PM, Neal Becker wrote:
>
> So what is this newint anyway?

I haven't looked at the code, but I would guess it's the 'long' type.  I would also guess that numpy really wants an 
int, not a long.

But that's all just guesses.

--
~Ethan~