From buck.2019 at gmail.com  Thu May  1 23:32:52 2014
From: buck.2019 at gmail.com (Buck Golemon)
Date: Thu, 1 May 2014 14:32:52 -0700
Subject: [Python-porting] porting %s for bytes
In-Reply-To: <CAPQx2vd0=URs9bbF4nqiDRfs5xfshhXhh8p0=SPUzkFFzLkUxw@mail.gmail.com>
References: <CAPQx2vd0=URs9bbF4nqiDRfs5xfshhXhh8p0=SPUzkFFzLkUxw@mail.gmail.com>
Message-ID: <CAPQx2vf-j980+6f1xyurCe-mrdLgD5n=jpfmKG5nppw+J=Vi_Q@mail.gmail.com>

My below message didn't seem to get through.
Is there a moderation issue?


On Tue, Apr 29, 2014 at 1:31 PM, Buck Golemon <buck.2019 at gmail.com> wrote:

> We're working on porting MySQLdb, and run up against a hard wall in %s in
> bytestrings.
> SQL queries are truly bytes (they can contain arbitrary binary blobs for
> insertion), but also need substition operations. The substition scheme in
> MySQLdb is %s. This was handy when we could do query_bytesring % params,
> but makes things very tough in python3.
>
> My options seem to be:
>
> A) Somehow decode arbitrary bytes to str, do the substitution, and encode
> back to bytes. I can use the 'sorrogateescape' erorr handler to do this in
> python3, but since this doesn't existing in 2.6 or 2.7, it doesn't jive
> with my goals of 2+3 support.
>
> B) Implement modulo substitution for bytes in python3. I see that this
> operation is making a reappearance in python3.5, so this seems fairly
> reasonable:
> http://legacy.python.org/dev/peps/pep-0461/
>
>
> I'm using the `future` package <http://python-future.org/> to do the
> port, and am very pleased with the result, but it doesn't handle this one
> rough spot. Can I request a 2+3 implementation of bytes.__mod__?  Or, has
> anyone seen a currently-existing implementation of this function?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-porting/attachments/20140501/6d910348/attachment.html>

From ethan at stoneleaf.us  Sat May 10 17:14:46 2014
From: ethan at stoneleaf.us (Ethan Furman)
Date: Sat, 10 May 2014 08:14:46 -0700
Subject: [Python-porting] porting %s for bytes
In-Reply-To: <CAPQx2vd0=URs9bbF4nqiDRfs5xfshhXhh8p0=SPUzkFFzLkUxw@mail.gmail.com>
References: <CAPQx2vd0=URs9bbF4nqiDRfs5xfshhXhh8p0=SPUzkFFzLkUxw@mail.gmail.com>
Message-ID: <536E4266.4050007@stoneleaf.us>

On 04/29/2014 01:31 PM, Buck Golemon wrote:
>
> B) Implement modulo substitution for bytes in python3. I see that
> this operation is making a reappearance in python3.5, so this
> seems fairly reasonable:
>
>  http://legacy.python.org/dev/peps/pep-0461/

There will be a backport (eventually ;), but as long as your implementation conforms to the PEP you should be fine.


> I'm using the `future` package to do the port, and am very pleased
>  with the result, but it doesn't handle this one rough spot. Can I
>  request a 2+3 implementation of bytes.__mod__?  Or, has anyone seen
>  a currently-existing implementation of this function?

As I recall there was a functional function implementation somewhere in the PEP460-461 threads that may work well 
enough.  I /think/ it was Terry Reedy that offered it (but I could easily be wrong).

--
~Ethan~

From buck.2019 at gmail.com  Tue May 13 19:40:31 2014
From: buck.2019 at gmail.com (Buck Golemon)
Date: Tue, 13 May 2014 10:40:31 -0700
Subject: [Python-porting] future newdict kwargs result in bytes
Message-ID: <CAPQx2vcMCNMU+d2t_uGRLCZ1B70qnXN4NURDro30PjtL_nM1FQ@mail.gmail.com>

As I understand it, the contract of future.builtins is to act like the
python3 builtins, but this behavior is distinctly python2-ish (and
necessitates me to write my own `udict`).

>>> dict
<class 'future.builtins.types.newdict.newdict'>
>>> type(tuple(dict(a=1).keys())[0]).mro()
[<type 'str'>, <type 'basestring'>, <type 'object'>]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-porting/attachments/20140513/aa7af9df/attachment.html>

From wtz_wh at foxmail.com  Sun May 18 03:14:15 2014
From: wtz_wh at foxmail.com (=?gb18030?B?sbGx+dHz?=)
Date: Sun, 18 May 2014 09:14:15 +0800
Subject: [Python-porting] How to solve the compatibility issue when import
	xxx.so
Message-ID: <tencent_173349DB3247638C40117E6A@qq.com>

Hi guys,


When I using Python2.7 to import xxx.so file which is compiled under Python2.4, There will be an error message 
     "ImportError: xxx.so: undefined symbol: Py_InitModule4"


I know need use the xxx.so compiled by 2.7.2 here. But my concern is that how to keep backwad compatibility? Post one xxx.so for one version?


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

From regebro at gmail.com  Mon May 19 14:21:31 2014
From: regebro at gmail.com (Lennart Regebro)
Date: Mon, 19 May 2014 14:21:31 +0200
Subject: [Python-porting] How to solve the compatibility issue when
	import xxx.so
In-Reply-To: <tencent_173349DB3247638C40117E6A@qq.com>
References: <tencent_173349DB3247638C40117E6A@qq.com>
Message-ID: <CAL0kPAX=7ZR1E86HJ8bBpnUss566VBxCa2A2ssqTgj1Mpye3uA@mail.gmail.com>

On Sun, May 18, 2014 at 3:14 AM, ??? <wtz_wh at foxmail.com> wrote:
> Hi guys,
>
> When I using Python2.7 to import xxx.so file which is compiled under
> Python2.4, There will be an error message
>      "ImportError: xxx.so: undefined symbol: Py_InitModule4"
>
> I know need use the xxx.so compiled by 2.7.2 here. But my concern is that
> how to keep backwad compatibility? Post one xxx.so for one version?

Yes. Generally you only need to do this for windows, as Unices tend to
include a compiler, so there the source code is enough.

//Lennart

From buck.2019 at gmail.com  Mon May 19 17:42:42 2014
From: buck.2019 at gmail.com (Buck Golemon)
Date: Mon, 19 May 2014 08:42:42 -0700
Subject: [Python-porting] future newdict kwargs result in bytes
In-Reply-To: <A220739F-F319-4A53-B9A4-688089ED2F15@pythoncharmers.com>
References: <CAPQx2vcMCNMU+d2t_uGRLCZ1B70qnXN4NURDro30PjtL_nM1FQ@mail.gmail.com>
 <A220739F-F319-4A53-B9A4-688089ED2F15@pythoncharmers.com>
Message-ID: <CAPQx2vc_qmcv_cLtGyWcW-FiFxnbWryFr+57v-iNHH-DZ_uHsQ@mail.gmail.com>

Yes, I'd expect the keys to be newstr, since that would match python3
behavior.

Here's my udict:


def udict(*args, **kwargs):
    """Similar to dict(), but keyword-keys are text.
    TODO: refactor out udict in favor of future.newdict
    """
    kwargs = dict([
        (u(key), val)
        for key, val in kwargs.items()
    ])

    return dict(*args, **kwargs)



On Mon, May 19, 2014 at 4:30 AM, Ed Schofield <ed at pythoncharmers.com> wrote:

>
> On 14 May 2014, at 3:40 am, Buck Golemon <buck.2019 at gmail.com> wrote:
>
> As I understand it, the contract of future.builtins is to act like the
> python3 builtins, but this behavior is distinctly python2-ish (and
> necessitates me to write my own `udict`).
>
> >>> dict
> <class 'future.builtins.types.newdict.newdict'>
> >>> type(tuple(dict(a=1).keys())[0]).mro()
> [<type 'str'>, <type 'basestring'>, <type 'object?>]
>
>
> Hi Buck,
>
> Yes, the type of ?a? is a native string. This seems to be what Python does
> when passing a kwarg to a function. Can you think of a way around this?
>
> What would you prefer to happen instead? Would you prefer for
> ``dict(a=1)`` to give you a dict with a ``newstr`` as the key? What is the
> application you have in mind?
>
> I would be interested in seeing your ``udict`` class to consider whether
> ``future.types.newdict`` can be modified to meet this need.
>
> Best wishes,
>     Ed
>
>
>
>
> --
> Dr. Edward Schofield
> Python Charmers
> http://pythoncharmers.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-porting/attachments/20140519/7c732c91/attachment.html>

From g.gogs at aol.com  Wed May 21 20:49:56 2014
From: g.gogs at aol.com (Gaurav Gogs)
Date: Wed, 21 May 2014 14:49:56 -0400 (EDT)
Subject: [Python-porting] ImportError: No module named urllib
Message-ID: <8D1433C97AD5D4C-EE4-36CA@webmail-d247.sysops.aol.com>

Hi,

I'm trying to use python-novaclient for my openstack project.

Installation is successful but when executing "nova", it give following error.
I've a MAC with maverick as latest OS.

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/nova", line 6, in <module>
    from novaclient.shell import main
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/novaclient/shell.py", line 45, in <module>
    from novaclient import client
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/novaclient/client.py", line 34, in <module>
    from six.moves.urllib import parse
ImportError: No module named urllib


pip show six
---
Name: six
Version: 1.6.1
Location: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Requires: 


pip show python-novaclient
---
Name: python-novaclient
Version: 2.17.0
Location: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Requires: pbr, iso8601, PrettyTable, requests, simplejson, six, Babel


Don't know if this is the right place to ask.


 Thanks,

 

Gaurav

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-porting/attachments/20140521/f430289c/attachment.html>

From regebro at gmail.com  Fri May 23 16:35:44 2014
From: regebro at gmail.com (Lennart Regebro)
Date: Fri, 23 May 2014 16:35:44 +0200
Subject: [Python-porting] ImportError: No module named urllib
In-Reply-To: <8D1433C97AD5D4C-EE4-36CA@webmail-d247.sysops.aol.com>
References: <8D1433C97AD5D4C-EE4-36CA@webmail-d247.sysops.aol.com>
Message-ID: <CAL0kPAUbyS6u5J0kt2QWZhyxwZ7RVbaj0DffZ8OcotMSOs8Dow@mail.gmail.com>

That's very strange. You are running Python 2.7, but it says that it
can't find urllib. The only reason I can think of it is you are
manipulating the python path, and somehow removed the path to the
standard library.

On Wed, May 21, 2014 at 8:49 PM, Gaurav Gogs
<g.gogs at aol.com.dmarc.invalid> wrote:
> Hi,
>
> I'm trying to use python-novaclient for my openstack project.
>
> Installation is successful but when executing "nova", it give following
> error.
> I've a MAC with maverick as latest OS.
>
> Traceback (most recent call last):
>   File "/Library/Frameworks/Python.framework/Versions/2.7/bin/nova", line 6,
> in <module>
>     from novaclient.shell import main
>   File
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/novaclient/shell.py",
> line 45, in <module>
>     from novaclient import client
>   File
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/novaclient/client.py",
> line 34, in <module>
>     from six.moves.urllib import parse
> ImportError: No module named urllib
>
>
> pip show six
> ---
> Name: six
> Version: 1.6.1
> Location:
> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
> Requires:
>
>
> pip show python-novaclient
> ---
> Name: python-novaclient
> Version: 2.17.0
> Location:
> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
> Requires: pbr, iso8601, PrettyTable, requests, simplejson, six, Babel
>
>
> Don't know if this is the right place to ask.
>
> Thanks,
>
> Gaurav
>
> _______________________________________________
> Python-porting mailing list
> Python-porting at python.org
> https://mail.python.org/mailman/listinfo/python-porting
>

From nad at acm.org  Fri May 23 22:06:30 2014
From: nad at acm.org (Ned Deily)
Date: Fri, 23 May 2014 13:06:30 -0700
Subject: [Python-porting] ImportError: No module named urllib
References: <8D1433C97AD5D4C-EE4-36CA@webmail-d247.sysops.aol.com>
 <CAL0kPAUbyS6u5J0kt2QWZhyxwZ7RVbaj0DffZ8OcotMSOs8Dow@mail.gmail.com>
Message-ID: <nad-853283.13063023052014@news.gmane.org>

In article 
<CAL0kPAUbyS6u5J0kt2QWZhyxwZ7RVbaj0DffZ8OcotMSOs8Dow at mail.gmail.com>,
 Lennart Regebro <regebro at gmail.com> 
 wrote:
> That's very strange. You are running Python 2.7, but it says that it
> can't find urllib.

It's easy to overlook: the relevant part of the traceback is earlier:

> > line 34, in <module>
> >     from six.moves.urllib import parse
> > ImportError: No module named urllib

So it's not the standard library urllib module, rather part of the six 
compatibility lib.  Dunno, I was just able to install python-novo using 
pip with Python 2.7.6 on OS X 10.9 and the nova command seemed to work.  
And, in particular, from within the Python interactive interpreter, 
typing:

from six.moves.urllib import parse

worked.  Perhaps you should check permissions on the the site-packages 
files?

-- 
 Ned Deily,
 nad at acm.org


From regebro at gmail.com  Fri May 23 22:44:25 2014
From: regebro at gmail.com (Lennart Regebro)
Date: Fri, 23 May 2014 22:44:25 +0200
Subject: [Python-porting] ImportError: No module named urllib
In-Reply-To: <nad-853283.13063023052014@news.gmane.org>
References: <8D1433C97AD5D4C-EE4-36CA@webmail-d247.sysops.aol.com>
 <CAL0kPAUbyS6u5J0kt2QWZhyxwZ7RVbaj0DffZ8OcotMSOs8Dow@mail.gmail.com>
 <nad-853283.13063023052014@news.gmane.org>
Message-ID: <CAL0kPAXmvA4TJ9F8mnfhhTRhh1vucvoukp9Gf_6Nr2_-4optqA@mail.gmail.com>

On Fri, May 23, 2014 at 10:06 PM, Ned Deily <nad at acm.org> wrote:
> It's easy to overlook: the relevant part of the traceback is earlier:
>
>> > line 34, in <module>
>> >     from six.moves.urllib import parse
>> > ImportError: No module named urllib
>
> So it's not the standard library urllib module, rather part of the six
> compatibility lib.

Ah, well, yes you are right, I thought that pointed to the urllib
module, but it doesn't, it points to a sort of proxy. That perhaps
means that it is that the six module somehow failed during
initialization?

//Lennart

From chris.jerdonek at gmail.com  Fri May 23 23:17:57 2014
From: chris.jerdonek at gmail.com (Chris Jerdonek)
Date: Fri, 23 May 2014 14:17:57 -0700
Subject: [Python-porting] ImportError: No module named urllib
In-Reply-To: <nad-853283.13063023052014@news.gmane.org>
References: <8D1433C97AD5D4C-EE4-36CA@webmail-d247.sysops.aol.com>
 <CAL0kPAUbyS6u5J0kt2QWZhyxwZ7RVbaj0DffZ8OcotMSOs8Dow@mail.gmail.com>
 <nad-853283.13063023052014@news.gmane.org>
Message-ID: <CAOTb1wf=JDGEz6QrOXSDNRxBUXKDuzSzCE=g5cNJO1E2D3jSNQ@mail.gmail.com>

On Fri, May 23, 2014 at 1:06 PM, Ned Deily <nad at acm.org> wrote:
> In article
> <CAL0kPAUbyS6u5J0kt2QWZhyxwZ7RVbaj0DffZ8OcotMSOs8Dow at mail.gmail.com>,
>  Lennart Regebro <regebro at gmail.com>
>  wrote:
>> That's very strange. You are running Python 2.7, but it says that it
>> can't find urllib.
>
> It's easy to overlook: the relevant part of the traceback is earlier:
>
>> > line 34, in <module>
>> >     from six.moves.urllib import parse
>> > ImportError: No module named urllib
>
> So it's not the standard library urllib module, rather part of the six
> compatibility lib.  Dunno, I was just able to install python-novo using
> pip with Python 2.7.6 on OS X 10.9 and the nova command seemed to work.
> And, in particular, from within the Python interactive interpreter,
> typing:
>
> from six.moves.urllib import parse
>
> worked.  Perhaps you should check permissions on the the site-packages
> files?

It's also possible that the error message is misleading and the
underlying error being swallowed if six is doing something fancy.  For
example, I seem to remember a bug in the unittest module where, when
loading tests (to use the example above), an error processing the
parse module would show up as an error like the above ("ImportError:
No module named urllib").

--Chris

From shai at platonix.com  Wed May 28 20:01:17 2014
From: shai at platonix.com (Shai Berger)
Date: Wed, 28 May 2014 21:01:17 +0300
Subject: [Python-porting] six.buffer_types?
Message-ID: <201405282101.17718.shai@platonix.com>

Hi Python porters,

This is my first message here; usually, I work on Django. In this work, I 
recently felt the need to have a collection of the buffer, or bytes types 
(parallel to the existing string_types) for an isinstance check. That is,

if six.PY2:
	buffer_types = buffer, bytearray
if six.PY3:
	buffer_types = bytes, bytearray, memoryview

We will probably add this soon to Django's customized version of six (the 
initial PR is at https://github.com/django/django/pull/2732/files if you're 
interested).

Do you think this would be useful for six in general?

Thanks,
	Shai.