[issue27341] mock.patch decorator fails silently on generators

2016-06-16 Thread Shoshana Berleant

New submission from Shoshana Berleant:

(at least in my case)

I committed two tests before I realized the tests were not being run: 
https://github.com/nipy/nipype/blob/abe7920a051f1570ccce4b71f26f50102d6e4e12/nipype/testing/tests/test_utils.py#L23

I realized this afternoon, while writing some more tests, that tests with the 
patch decorator were all reported as "OK", even when I wanted them to fail. 
Turns out they aren't being run at all.

I commented out all the yield statements, and the tests ran just as they should.

I don't know exactly what is going on here, but might raising an error or 
warning be good here?

Originally filed here: https://github.com/testing-cabal/mock/issues/366

--
components: Tests
messages: 268709
nosy: shoshber
priority: normal
severity: normal
status: open
title: mock.patch decorator fails silently on generators
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23360] Content-Type when sending data with urlopen()

2016-06-16 Thread Martin Panter

Martin Panter added the comment:

Fixed conflicts with recent changes

--
versions: +Python 2.7 -Python 3.4
Added file: http://bugs.python.org/file43428/non-urlencoded.6.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Method Chaining

2016-06-16 Thread Lawrence D’Oliveiro
On Friday, June 17, 2016 at 4:24:24 PM UTC+12, Michael Selik wrote:
> On Thu, Jun 16, 2016 at 10:53 PM Lawrence D’Oliveiro wrote:
> 
> > Example from ,
> > concisely expressing a complex drawing sequence:
> >
> > (g
> > .move_to((p1 + p2a) / 2)
> > .line_to(p1 + (p2 - p1) * frac)
> > .line_to((p1 + p1a) / 2)
> > .stroke()
> > .move_to((p2 + p2a) / 2)
> > .line_to(p2 + (p1 - p2) * frac)
> > .line_to((p2 + p1a) / 2)
> > .stroke()
> > )
> 
> Wouldn't that look nicer with the ``g`` repeated on every line, no extra
> indentation, and no extraneous parentheses?
> 
> g.move_to((p1 + p2a) / 2)
> g.line_to(p1 + (p2 - p1) * frac)
> g.line_to((p1 + p1a) / 2)
> g.stroke()
> g.move_to((p2 + p2a) / 2)
> g.line_to(p2 + (p1 - p2) * frac)
> g.line_to((p2 + p1a) / 2)
> g.stroke()

Clearly, no.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tie dictionary to database table?

2016-06-16 Thread Lawrence D’Oliveiro
On Friday, June 10, 2016 at 12:30:47 AM UTC+12, Peter Heitzer wrote:
> What I would like is if I write 
> 
> email['frank']='fr...@middle-of-nowhere.org'
> 
> in my python script it generates a statement like
> update users set email='fr...@middle-of-nowhere.org' where username='frank';

That’s not a database, that’s a key-value store.


-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23740] http.client request and send method have some datatype issues

2016-06-16 Thread Martin Panter

Changes by Martin Panter :


--
dependencies: +bytes-like objects with socket.sendall(), SSL, and http.client

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Method Chaining

2016-06-16 Thread Michael Selik
On Thu, Jun 16, 2016 at 10:53 PM Lawrence D’Oliveiro 
wrote:

> Example from ,
> concisely expressing a complex drawing sequence:
>
> (g
> .move_to((p1 + p2a) / 2)
> .line_to(p1 + (p2 - p1) * frac)
> .line_to((p1 + p1a) / 2)
> .stroke()
> .move_to((p2 + p2a) / 2)
> .line_to(p2 + (p1 - p2) * frac)
> .line_to((p2 + p1a) / 2)
> .stroke()
> )
>

Wouldn't that look nicer with the ``g`` repeated on every line, no extra
indentation, and no extraneous parentheses?

g.move_to((p1 + p2a) / 2)
g.line_to(p1 + (p2 - p1) * frac)
g.line_to((p1 + p1a) / 2)
g.stroke()
g.move_to((p2 + p2a) / 2)
g.line_to(p2 + (p1 - p2) * frac)
g.line_to((p2 + p1a) / 2)
g.stroke()

Sometimes it's hard to know when a function has a side-effect. I appreciate
that these impure functions tend to return None.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27340] bytes-like objects with socket.sendall(), SSL, and http.client

2016-06-16 Thread Martin Panter

New submission from Martin Panter:

According to the documentation, HTTPSConnection.request() should accept 
arbitrary bytes-like objects, but this is not the case. Currently (since Issue 
23756), a “bytes-like object” is defined to be anything that works with 
Python’s buffer API, as long as it is C-contiguous. These objects can be passed 
to socket.sendall():

>>> byteslike = (ctypes.c_ubyte * 6).from_buffer_copy(b"DATA\r\n")
>>> s = socket.create_connection(("localhost", 80))
>>> s.sendall(byteslike)  # Server receives b"DATA\r\n"

This is not explicitly documented for socket objects. But since Issue 23539 
(3.4+), HTTPConnection.request() does document support for bytes-like objects:

>>> h = HTTPConnection("localhost", 80)
>>> # Send Content-Length: 6 and body b"DATA\r\n"
>>> h.request("POST", "/", body=byteslike)

On its own, there is no problem with Python relying on its own undocumented 
behaviour. But Python’s “ssl” module does not support arbitrary bytes-like 
objects, and as a result neither does HTTPSConnection:

>>> s = ssl.wrap_socket(socket.create_connection(("localhost", 443)))
>>> s.sendall(byteslike)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.5/ssl.py", line 886, in sendall
v = self.send(data[count:])
  File "/usr/lib/python3.5/ssl.py", line 856, in send
return self._sslobj.write(data)
  File "/usr/lib/python3.5/ssl.py", line 581, in write
return self._sslobj.write(data)
TypeError: a bytes-like object is required, not 'list'
>>> c = ssl.create_default_context(cafile="/lib/python3.5/test/keycert.pem")
>>> h = HTTPSConnection("localhost", 443, context=c)
>>> h.request("POST", "/", body=byteslike)
Traceback (most recent call last):
  File "/usr/lib/python3.5/http/client.py", line 885, in send
self.sock.sendall(data)
  File "/usr/lib/python3.5/ssl.py", line 886, in sendall
v = self.send(data[count:])
  File "/usr/lib/python3.5/ssl.py", line 856, in send
return self._sslobj.write(data)
  File "/usr/lib/python3.5/ssl.py", line 581, in write
return self._sslobj.write(data)
TypeError: a bytes-like object is required, not 'list'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.5/http/client.py", line 1083, in request
self._send_request(method, url, body, headers)
  File "/usr/lib/python3.5/http/client.py", line 1128, in _send_request
self.endheaders(body)
  File "/usr/lib/python3.5/http/client.py", line 1079, in endheaders
self._send_output(message_body)
  File "/usr/lib/python3.5/http/client.py", line 913, in _send_output
self.send(message_body)
  File "/usr/lib/python3.5/http/client.py", line 892, in send
"or an iterable, got %r" % type(data))
TypeError: data should be a bytes-like object or an iterable, got 

This could be fixed in the implementation of SSLSocket.sendall(). But I am not 
sure if that is an appropriate change for 3.5. Another option would be to 
adjust the documentation of HTTP(S)Connection in 3.5, either not mentioning 
bytes-like objects at all, or clarifying that they don’t work with SSL.

--
assignee: docs@python
components: Documentation, Library (Lib)
messages: 268707
nosy: docs@python, martin.panter
priority: normal
severity: normal
status: open
title: bytes-like objects with socket.sendall(), SSL, and http.client
versions: Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26867] test_ssl test_options fails on ubuntu 16.04

2016-06-16 Thread Martin Panter

Martin Panter added the comment:

FWIW I imagine Ubuntu overriding the option will break the example code in the 
documentation of clearing SSL_OP_NO_SSLv3: 
. If 
we keep that documentation, I think we should continue to test that clearing 
the option works, which conflicts with the proposed patch.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25724] SSLv3 test failure on Ubuntu 16.04 LTS

2016-06-16 Thread Martin Panter

Martin Panter added the comment:

This patch was also posted to Issue 26867, with a bit more discussion and 
analysis, so closing as a duplicate.

--
resolution:  -> duplicate
status: open -> closed
superseder:  -> test_ssl test_options fails on ubuntu 16.04

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: What is structured programming (was for/while else doesn't make sense)

2016-06-16 Thread Lawrence D’Oliveiro
On Thursday, June 16, 2016 at 11:13:14 PM UTC+12, Rustom Mody wrote:

> Please see https://en.wikipedia.org/wiki/Nassi%E2%80%93Shneiderman_diagram
> 
> | Nassi–Shneiderman diagrams are (almost) isomorphic with
> | flowcharts. Everything you can represent with a Nassi–Shneiderman
> | diagram you can also represent with a flowchart.
> 
> which is in line with what I am saying, viz that break/continue/goto are same
> in the sense of being 'unstructured' and therefore do not fit into a
> structured framework like NSDs

This is just a restatement of the “structure theorem”, which proves that 
structured control statements are mathematically equivalent to gotos, and 
anything that can be expressed one way can be expressed the other way.

True, but a complete red herring.
-- 
https://mail.python.org/mailman/listinfo/python-list


Method Chaining

2016-06-16 Thread Lawrence D’Oliveiro
Some kinds of objects often receive a whole lot of method calls in sequence. In 
these situations, it is handy if each method call ends with “return self”, so 
that you can chain the calls together. This is particularly common with 
graphics APIs, for instance.

Example from , 
concisely expressing a complex drawing sequence:

(g
.move_to((p1 + p2a) / 2)
.line_to(p1 + (p2 - p1) * frac)
.line_to((p1 + p1a) / 2)
.stroke()
.move_to((p2 + p2a) / 2)
.line_to(p2 + (p1 - p2) * frac)
.line_to((p2 + p1a) / 2)
.stroke()
)

Another example 
, where an 
object requires setup calls that cannot all be expressed in the constructor:

pattern = \
qah.Pattern.create_linear \
  (
p0 = (0, 0),
p1 = (pattern_length, 0), # base orientation is parallel to X-axis
colour_stops =
(
(0, Colour.from_hsva((0.475, 0.9, 0.8))),
(1, Colour.from_hsva((0.975, 0.9, 0.8))),
)
  ).set_extend(CAIRO.EXTEND_REPEAT)

In , a temporary 
drawing context is created, used to create the image pattern, and then 
discarded, without even having to give it a name:

mask = qah.ImageSurface.create \
  (
format = CAIRO.FORMAT_RGB24,
dimensions = dimensions * scale
  )
(qah.Context.create(mask)
.set_matrix(Matrix.scale(scale))
.set_source_colour(primary[component])
.set_operator(CAIRO.OPERATOR_SOURCE)
.rectangle(spot)
.fill()
)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Method Chaining

2016-06-16 Thread Steven D'Aprano
On Fri, 17 Jun 2016 12:02 pm, Lawrence D’Oliveiro wrote:

> Some kinds of objects often receive a whole lot of method calls in
> sequence. In these situations, it is handy if each method call ends with
> “return self”, so that you can chain the calls together. This is
> particularly common with graphics APIs, for instance.
[...]


Yes, this is design that (for example) Ruby classes tend to follow. It's not
one that the Python builtins tend to follow, but of course people are free
to return self from their own classes' methods if they like.

As an alternative, you might find this simple adaptor useful:

http://code.activestate.com/recipes/578770-method-chaining/



-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Contradictory error messages in Python 3.4 - standard library issue!

2016-06-16 Thread Steven D'Aprano
Hi Harrison, and welcome!


On Fri, 17 Jun 2016 08:25 am, Harrison Chudleigh wrote:

> While working on a program, I ran into an error with the usage of the
> module tokenize.

So you have an error with the use of tokenize. Fair enough.

But why do you imagine that the errors lies in the module itself, rather
that your use of it? There are probably tens of thousands, maybe hundreds
of thousands, of people using that module (directly or indirectly). The
chances that you have identified a bug in the module that nobody else has
seen before is pretty slim.

And that certainly shouldn't be your first assumption.


> The following message was displayed. 
>  File
> "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tokenize.py",
> line 467, in tokenize
> encoding, consumed = detect_encoding(readline)
>   File
> "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tokenize.py",
> line 409, in detect_encoding
> if first.startswith(BOM_UTF8):
> TypeError: startswith first arg must be str or a tuple of str, not bytes
> Undaunted, I changed the error on line 409. The line then read:
> 
> if first.startswith(BOM_UTF8):

I'm not seeing any actual difference between the before and after:

if first.startswith(BOM_UTF8):
if first.startswith(BOM_UTF8):

but in another email, you state that you changed it to:

if first.startswith('BOM_UTF8'):


Changing the source code of the standard library is almost never what you
want to be do. I've been programming in Python for 20+ years, and the
number of times I've edited the source code of the standard library to fix
a program is exactly zero.

But making random changes to the source code of the standard library without
understanding what it is doing or why is NEVER what you want to do.

All you have accomplished by editing the code is changing the situation
from "one in a 100,000 chance of a bug in the standard library"
to "certainly a bug in a non-standard module shared by absolutely nobody
else in the world".

Before we can help you, you MUST revert the module back to the way it was.
You have introduced a bug to the module, but worse, you've now made it so
that it is different from everyone else's tokenize module. Any errors you
have received after making that change, or changes, are irrelevant.

Then you need to show us how you are calling tokenize. Show us the ENTIRE
traceback, starting with the line beginning "Traceback", not just the last
line with the error message. Once we've seen that, we may be able to help
you, or we may have more questions, but that's the bare minimum we need.



-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue14562] urllib2 maybe blocks too long with small chunks

2016-06-16 Thread Martin Panter

Changes by Martin Panter :


--
versions:  -Python 3.2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27335] Clarify that writing to locals() inside a class body is supported

2016-06-16 Thread Martin Panter

Martin Panter added the comment:

I think my proposed patch for Issue 17546 addresses this. That patch was also 
written to address Issue 17960.

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com




Re: Re - Contradictory error messages in Python 3.4 - standard library issue!

2016-06-16 Thread Matt Wheeler
On Thu, 16 Jun 2016, 23:31 Harrison Chudleigh, <
harrison.chudlei...@education.nsw.gov.au> wrote:

> Sorry! I was trying to indent a line and accidentally sent only half of the
> message.
>

It would be helpful if your reply was actually a reply to your previous
message, to enable us to follow the thread of the conversation.

As I was saying, I changed the line and reran the program. However, this
> produced another group of error messages. One was -
>

>From what, to what? Just showing us stacktraces means we have to guess at
the problem.

File
>
> "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tokenize.py",
> line 438, in open
> encoding, lines = detect_encoding(buffer.readline)
>   File
>
> "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tokenize.py",
> line 409, in detect_encoding
> if first.startswith('BOM_UTF8'):
> TypeError: startswith first arg must be bytes or a tuple of bytes, not str.
> So, first the interpreter says startswith() takes strings, now it says it
> takes bytes? What should the module be doing?
>

The reason you're getting seemingly contradictory error messages is that
`.startswith()` is a method which belongs to the `first` object, and that
object is a different type between the first and the second time it's
called.
Both the `bytes` and `str` types have a `startswith` method, but each one
(understandably) only accepts an argument of the same type.

Without actually seeing your code I can't guess what the cause of that is,
but perhaps you need to decode a `bytes` object to a `str` or encode the
other way around.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Re - Contradictory error messages in Python 3.4 - standard library issue!

2016-06-16 Thread Ned Batchelder
On Thursday, June 16, 2016 at 6:39:27 PM UTC-4, Harrison Chudleigh wrote:
> Sorry! I was trying to indent a line and accidentally sent only half of the
> message.
> 
> As I was saying, I changed the line and reran the program. However, this
> produced another group of error messages. One was -
> File
> "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tokenize.py",
> line 438, in open
> encoding, lines = detect_encoding(buffer.readline)
>   File
> "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tokenize.py",
> line 409, in detect_encoding
> if first.startswith('BOM_UTF8'):
> TypeError: startswith first arg must be bytes or a tuple of bytes, not str.
> So, first the interpreter says startswith() takes strings, now it says it
> takes bytes? What should the module be doing?
> This is an error with the standard library of Python 3.4.1, Mac OS X.

You shouldn't have to edit the stdlib files to get your program to work.
It sounds like you are using values with the tokenize module that it isn't
expecting. Can you show your code?

--Ned.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re - Contradictory error messages in Python 3.4 - standard library issue!

2016-06-16 Thread Harrison Chudleigh
Sorry! I was trying to indent a line and accidentally sent only half of the
message.

As I was saying, I changed the line and reran the program. However, this
produced another group of error messages. One was -
File
"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tokenize.py",
line 438, in open
encoding, lines = detect_encoding(buffer.readline)
  File
"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tokenize.py",
line 409, in detect_encoding
if first.startswith('BOM_UTF8'):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str.
So, first the interpreter says startswith() takes strings, now it says it
takes bytes? What should the module be doing?
This is an error with the standard library of Python 3.4.1, Mac OS X.
***
This message is intended for the addressee named and may contain privileged 
information or confidential information or both. If you are not the intended 
recipient please delete it and notify the sender.
-- 
https://mail.python.org/mailman/listinfo/python-list


Contradictory error messages in Python 3.4 - standard library issue!

2016-06-16 Thread Harrison Chudleigh
While working on a program, I ran into an error with the usage of the
module tokenize. The following message was displayed.
 File
"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tokenize.py",
line 467, in tokenize
encoding, consumed = detect_encoding(readline)
  File
"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tokenize.py",
line 409, in detect_encoding
if first.startswith(BOM_UTF8):
TypeError: startswith first arg must be str or a tuple of str, not bytes
Undaunted, I changed the error on line 409. The line then read:

if first.startswith(BOM_UTF8):
***
This message is intended for the addressee named and may contain privileged 
information or confidential information or both. If you are not the intended 
recipient please delete it and notify the sender.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27278] py_getrandom() uses an int for syscall() result

2016-06-16 Thread STINNER Victor

STINNER Victor added the comment:

> Adding a cast would solve this compiler warning:

I changed the code to use the long type. It should fix the warning, even if it 
was no more a real bug: the original bug was already fixed.

I close the issue, it's now solved.

--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27278] py_getrandom() uses an int for syscall() result

2016-06-16 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 193f50babfa4 by Victor Stinner in branch '3.5':
py_getrandom(): use long type for the syscall() result
https://hg.python.org/cpython/rev/193f50babfa4

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27339] Security Issue: Typosquatting

2016-06-16 Thread STINNER Victor

STINNER Victor added the comment:

Hum, I guess that you are talking about https://pypi.python.org/pypi ? If yes, 
you should open an issue in their bug tracker:
https://bitbucket.org/pypa/pypi/issues

By the way, I don't see any obvious fix for typo squatting.

--
nosy: +haypo
resolution:  -> third party
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26171] heap overflow in zipimporter module

2016-06-16 Thread Vlad K.

Vlad K. added the comment:

Here's the patch that I made for FreeBSD's Python 3.3 port. With this patch, on 
FreeBSD, Python 3.3 built fine and passed the zipimport related unit tests. 
It's basically the same code from 3.4, 3.5 and 2.7, just placed at appropriate 
place in the source.

--
versions:  -Python 3.3
Added file: 
http://bugs.python.org/file43427/patch-Modules_zipimport-CVE-2016-5636.c

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26439] ctypes.util.find_library fails when ldconfig/glibc not available (e.g., AIX)

2016-06-16 Thread Michael Felt

Michael Felt added the comment:

updated patch for Python 2.7 (shall adopt and submit new patch for Python3 
based on this - next week)

used gnu diff to generate diff output.

Additional tests in util.py are for demo only, would expect them to be removed, 
however, the additional test in test/test_loading.py could remain.

--
Added file: http://bugs.python.org/file43426/Python2.Lib.ctypes.160611.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26171] heap overflow in zipimporter module

2016-06-16 Thread Ned Deily

Ned Deily added the comment:

reopening for 3.3.7 evaluation.  Georg?

--
nosy: +georg.brandl, ned.deily
priority: normal -> 
resolution: fixed -> 
stage: resolved -> needs patch
status: closed -> open
versions: +Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26439] ctypes.util.find_library fails when ldconfig/glibc not available (e.g., AIX)

2016-06-16 Thread Michael Felt

Michael Felt added the comment:

The patch for Python2 - however, only now see the change in selections for 
version. Will need to redo/test Lib/ctypes/*.py in newer version.

Note also, the additional tests in util.py are for my testing - I do not expect 
them to stay, but I do want you aware of how I am testing - see also change in 
Lib/ctypes/test/test_loading.py

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26439] ctypes.util.find_library fails when ldconfig/glibc not available (e.g., AIX)

2016-06-16 Thread Michael Felt

Michael Felt added the comment:

_aixutil.py to be paired with Python2.Lib.ctypes.16.06.11.patch

--
Added file: http://bugs.python.org/file43425/_aixutil.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27336] --without-threads build fails due to undeclared _PyGILState_check_enabled

2016-06-16 Thread STINNER Victor

STINNER Victor added the comment:

issue27336.diff LGTM with a minor comment on the review.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27336] --without-threads build fails due to undeclared _PyGILState_check_enabled

2016-06-16 Thread STINNER Victor

STINNER Victor added the comment:

@Alex Willmer: Why do you build Python without threads?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26171] heap overflow in zipimporter module

2016-06-16 Thread Vlad K.

Vlad K. added the comment:

I believe this should be applied to Python 3.3 as well, since the same problem 
(unchecked data_size before adding +1 for bytes_size) exists there too, and is 
thus a security issue.

--
nosy: +vladk

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27339] Security Issue: Typosquatting

2016-06-16 Thread YoSTEALTH

New submission from YoSTEALTH:

I read this new article that explains Typosquatting well: 
http://incolumitas.com/2016/06/08/typosquatting-package-managers/ making it 
known here so python developers can address this issue accordingly!

--
messages: 268692
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: Security Issue: Typosquatting

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Bulk Adding Methods Pythonically

2016-06-16 Thread Ethan Furman
On 06/16, Random832 wrote:
> On Wed, Jun 15, 2016, at 15:03, Ethan Furman wrote:

>> [1] https://docs.python.org/3/library/functions.html#locals
>>  Yes, returning the class namespace is a language gaurantee.
> 
> How do you get a guarantee from that text?

Oops, my bad -- the gaurantee is in the vars() description on the same
page... although that still isn't very clear about during-class-construction;
okay, I'll have to chime in on the issue Steven opened.

--
~Ethan~
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27338] python 2.7 platform.system reports wrong on Mac OS X El Capitan

2016-06-16 Thread Audric D'Hoest (Dr. Pariolo)

Changes by Audric D'Hoest (Dr. Pariolo) :


--
resolution:  -> works for me
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27338] python 2.7 platform.system reports wrong on Mac OS X El Capitan

2016-06-16 Thread Audric D'Hoest (Dr. Pariolo)

Audric D'Hoest (Dr. Pariolo) added the comment:

Hello Ned,

That is a brilliant answer!

After reporting this initially, I tried with 3.5.1, and uname... Convinced it 
was a 2.7.1, I could not be more wrong! What a stupid and confusing output does 
the OS report.

platform.mac_ver() does the trick!

thank you!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27336] --without-threads build fails due to undeclared _PyGILState_check_enabled

2016-06-16 Thread Berker Peksag

Berker Peksag added the comment:

The attached patch should fix this.

--
keywords: +patch
nosy: +berker.peksag
Added file: http://bugs.python.org/file43424/issue27336.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27336] --without-threads build fails due to undeclared _PyGILState_check_enabled

2016-06-16 Thread Berker Peksag

Changes by Berker Peksag :


--
nosy: +haypo
stage:  -> patch review
type:  -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27338] python 2.7 platform.system reports wrong on Mac OS X El Capitan

2016-06-16 Thread Ned Deily

Ned Deily added the comment:

Python's platform module has both platform-independent and platform-dependent 
functions as noted in its documentation.  While it isn't as clearly documented 
as perhaps it should be, on most "Unix-y" platforms, like OS X, much of the 
platform-independent system information comes from the same source as the 
platform's "uname" command.  You can see that, if you use platform.uname(), it 
matches the output of OS X's uname(1) command:

>>> platform.uname()
('Darwin', 'kitt.local', '15.5.0', 'Darwin Kernel Version 15.5.0: Tue Apr 19 
18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64', 'x86_64', 'i386')
>>> platform.system()
'Darwin'
>>> platform.release()
'15.5.0'

$ uname -a
Darwin kitt.local 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 
2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64

Somewhat confusingly, "Darwin" is how the OS X kernel identifies itself and 
"15.5.0" is the Darwin version number that corresponds to OS X 10.11.5.  And 
the uname output is what the platform module uses.

For OS X, the platform module does provide a Mac-specific function, 
platform.mac_ver.  From it, you can get the OS X version information, rather 
than the Darwin kernel information.

>>> platform.mac_ver()
('10.11.5', ('', '', ''), 'x86_64')

Suggestions on how to improve the documentation are welcome!  But changing the 
results from the platform-independent functions after all these years is not 
likely to happen.

https://docs.python.org/2.7/library/platform.html#cross-platform
https://en.wikipedia.org/wiki/Darwin_(operating_system)#Release_history

--
nosy: +lemburg

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27330] Possible leaks in ctypes

2016-06-16 Thread Roundup Robot

Roundup Robot added the comment:

New changeset e04c054beb53 by Serhiy Storchaka in branch '2.7':
Issue #27330: Fixed possible leaks in the ctypes module.
https://hg.python.org/cpython/rev/e04c054beb53

New changeset 41f99ee19804 by Serhiy Storchaka in branch '3.5':
Issue #27330: Fixed possible leaks in the ctypes module.
https://hg.python.org/cpython/rev/41f99ee19804

New changeset 27e7945c4ecd by Serhiy Storchaka in branch 'default':
Issue #27330: Fixed possible leaks in the ctypes module.
https://hg.python.org/cpython/rev/27e7945c4ecd

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27338] python 2.7 platform.system reports wrong on Mac OS X El Capitan

2016-06-16 Thread Audric D'Hoest (Dr. Pariolo)

Changes by Audric D'Hoest (Dr. Pariolo) :


--
title: python 2.7 platform.system reports wrong -> python 2.7 platform.system 
reports wrong on Mac OS X El Capitan

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27338] python 2.7 platform.system reports wrong

2016-06-16 Thread Audric D'Hoest (Dr. Pariolo)

New submission from Audric D'Hoest (Dr. Pariolo):

Mac mini late 2014, upgraded to El capitan.

Out of the box python 2.7 reports the wrong system info.

platform.system() should report El Capitan
platform.release() should report 10.11.5

--
components: Macintosh
files: pybug.png
messages: 268687
nosy: Audric D'Hoest (Dr. Pariolo), ned.deily, ronaldoussoren
priority: normal
severity: normal
status: open
title: python 2.7 platform.system reports wrong
versions: Python 2.7
Added file: http://bugs.python.org/file43423/pybug.png

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27337] 3.6.0a2 tarball has weird paths

2016-06-16 Thread Ned Deily

Changes by Ned Deily :


--
Removed message: http://bugs.python.org/msg268685

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27337] 3.6.0a2 tarball has weird paths

2016-06-16 Thread Ned Deily

Ned Deily added the comment:

That's unfortunate and my fault, basically, the .tgz tarball was built with a 
BSD-ish tar while the .xz one was built with a GNU tar, as intended.  I hate to 
do a stealth update, unless absolutely necessary, and I don't get see any 
errors unpacking the .tgz one with a recent GNU tar.  Can you say with which 
version of tar and on what platform you see the tar failure?  I'll make sure it 
doesn't happen in subsequent releases.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27337] 3.6.0a2 tarball has weird paths

2016-06-16 Thread Ned Deily

Ned Deily added the comment:

That's unfortunate and my fault, basically, the .tgz tarball was built with a 
BSD-ish while the .xz one was built with GNU tar, as intended.  I hate to do a 
stealth update, unless absolutely necessary, and I don't get see any errors 
unpacking the .tgz one with a recent GNU tar.  Can you say with which version 
of tar and on what platform you see the tar failure?  I'll make sure it doesn't 
happen in subsequent releases.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27305] Crash with "pip list --outdated" on Windows 10 with Python 2.7.12rc1

2016-06-16 Thread Christoph Gohlke

Changes by Christoph Gohlke :


--
nosy: +cgohlke

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27337] 3.6.0a2 tarball has weird paths

2016-06-16 Thread Ned Deily

Changes by Ned Deily :


--
assignee:  -> ned.deily
priority: normal -> high

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27337] 3.6.0a2 tarball has weird paths

2016-06-16 Thread Berker Peksag

Changes by Berker Peksag :


--
nosy: +ned.deily

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27337] 3.6.0a2 tarball has weird paths

2016-06-16 Thread Peter Eisentraut

New submission from Peter Eisentraut:

The file Python-3.6.0a2.tgz contains paths that start with "..", e.g., 

$ tar tf Python-3.6.0a2.tgz | head
../Python-3.6.0a2/
../Python-3.6.0a2/Doc/
../Python-3.6.0a2/Grammar/
../Python-3.6.0a2/Include/
../Python-3.6.0a2/LICENSE
../Python-3.6.0a2/Lib/
../Python-3.6.0a2/Mac/
../Python-3.6.0a2/Makefile.pre.in
../Python-3.6.0a2/Misc/
../Python-3.6.0a2/Modules/

This causes tar to error out when unpacking the file.

This was not the case in previous tarballs and also not in 
Python-3.6.0a2.tar.xz.

--
components: Build
messages: 268684
nosy: petere
priority: normal
severity: normal
status: open
title: 3.6.0a2 tarball has weird paths
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Bulk Adding Methods Pythonically

2016-06-16 Thread Steven D'Aprano
On Fri, 17 Jun 2016 01:53 am, Julien Salort wrote:

> Ethan Furman  wrote:
> 
>> If that is all correct, then, as Random suggested, move that loop into
>> the class body and use locals() [1] to update the class dictionary.
>> Just make sure and delete any temporary variables.[
> [...]
>> [1] https://docs.python.org/3/library/functions.html#locals
>>  Yes, returning the class namespace is a language gaurantee.
> 
> But that says:
> "Note The contents of this dictionary should not be modified; changes
> may not affect the values of local and free variables used by the
> interpreter."

That only applies to locals() inside a function. The intent of locals()
inside a class is to be writable, and if the docs don't explicitly make
that guarantee, they should.

http://bugs.python.org/issue27335



-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27336] --without-threads build fails due to undeclared _PyGILState_check_enabled

2016-06-16 Thread Alex Willmer

New submission from Alex Willmer:

Building current tip (rev 102062:3d726dbfca31), on Ubuntu 16.04/x86_64, using 
--without-thread fails; with the following error
gcc -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall 
-Wstrict-prototypes-Werror=declaration-after-statement   -I. -IInclude 
-I./Include-DPy_BUILD_CORE -o Python/pylifecycle.o Python/pylifecycle.c
Python/pylifecycle.c: In function ‘Py_NewInterpreter’:
Python/pylifecycle.c:751:5: error: ‘_PyGILState_check_enabled’ undeclared 
(first use in this function)
 _PyGILState_check_enabled = 0;
 ^
Python/pylifecycle.c:751:5: note: each undeclared identifier is reported only 
once for each function it appears in
Makefile:1575: recipe for target 'Python/pylifecycle.o' failed
make: *** [Python/pylifecycle.o] Error 1

I've attached the full build log.

--
components: Build
files: without-threads.build.log
messages: 268683
nosy: Alex.Willmer
priority: normal
severity: normal
status: open
title: --without-threads build fails due to undeclared _PyGILState_check_enabled
versions: Python 3.6
Added file: http://bugs.python.org/file43422/without-threads.build.log

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27335] Clarify that writing to locals() inside a class body is supported

2016-06-16 Thread Steven D'Aprano

New submission from Steven D'Aprano:

The docs for locals() warn not to write to the dict returned, as it may not 
have the intended effect of modifying the actual variables seen by the 
interpreter.

https://docs.python.org/3/library/functions.html#locals

But as I understanding it, using locals() inside a class body is intentionally 
supported:

class K:
locals()['x'] = 1

assert K.x == 1

is not just an accident of implementation, but the intended behaviour and a 
language guarantee.

--
assignee: docs@python
components: Documentation
messages: 268682
nosy: docs@python, steven.daprano
priority: normal
severity: normal
status: open
title: Clarify that writing to locals() inside a class body is supported
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24887] Sqlite3 has no option to provide open flags

2016-06-16 Thread Berker Peksag

Changes by Berker Peksag :


--
resolution:  -> out of date
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27139] Increased test coverage for statistics.median_grouped

2016-06-16 Thread Steven D'Aprano

Steven D'Aprano added the comment:

Thanks Julio,

I hope to get to this over the next week. Please feel free to prod me if 
you see no action by then.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27334] pysqlite3 context manager not performing rollback when a database is locked elsewhere for non-DML statements

2016-06-16 Thread Berker Peksag

Berker Peksag added the comment:

You may also want to check that the method_name is "commit". A test case would 
nice to have.

Note that the connection context manager will still fail cases like nested 
context managers. See issue 16958.

--
nosy: +berker.peksag, ghaering
stage:  -> patch review
type:  -> behavior
versions: +Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27139] Increased test coverage for statistics.median_grouped

2016-06-16 Thread Julio C Cardoza

Julio C Cardoza added the comment:

Updated patch file to condense four functions into one function

--
Added file: http://bugs.python.org/file43421/test_median_grouped.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27334] pysqlite3 context manager not performing rollback when a database is locked elsewhere for non-DML statements

2016-06-16 Thread Luca Citi

New submission from Luca Citi:

I have reported this bug to the pysqlite module for python2 ( 
https://github.com/ghaering/pysqlite/issues/103 ) but I also report it here 
because it applies to python3 too.

The pysqlite3 context manager does not perform a rollback when a transaction 
fails because the database is locked by some other process performing non-DML 
statements (e.g. during the sqlite3 command line .dump method).

To reproduce the problem, open a terminal and run the following:

```bash
sqlite3 /tmp/test.db 'drop table person; create table person (id integer 
primary key, firstname varchar)'
echo -e 'begin transaction;\nselect * from person;\n.system sleep 
1000\nrollback;' | sqlite3 /tmp/test.db
```

Leave this shell running and run the python3 interpreter from a different 
shell, then type:

```python
import sqlite3
con = sqlite3.connect('/tmp/test.db')
with con:
con.execute("insert into person(firstname) values (?)", ("Jan",))
pass
```

You should receive the following:

```
  1 with con:
  2 con.execute("insert into person(firstname) values (?)", 
("Jan",))
> 3 pass
  4 

OperationalError: database is locked
```

Without exiting python, switch back to the first shell and kill the `'echo ... 
| sqlite3'` process. Then run:

```bash
sqlite3 /tmp/test.db .dump
```

you should get:

```
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
/ ERROR: (5) database is locked */
ROLLBACK; -- due to errors
```

This means that the python process never executed a `rollback` and is still 
holding the lock. To release the lock one can exit python (clearly, this is not 
the intended behaviour of the context manager).

I believe the reason for this problem is that the exception happened in the 
implicit `commit` that is run on exiting the context manager, rather than 
inside it. In fact the exception is in the `pass` line rather than in the 
`execute` line. This exception did not trigger a `rollback` because the it 
happened after `pysqlite_connection_exit` checks for exceptions.

The expected behaviour (pysqlite3 rolling back and releasing the lock) is 
recovered if the initial blocking process is a Data Modification Language (DML) 
statement, e.g.:

```bash
echo -e 'begin transaction; insert into person(firstname) values 
("James");\n.system sleep 1000\nrollback;' | sqlite3 /tmp/test.db
```

because this raises an exception at the `execute` time rather than at `commit` 
time.

To fix this problem, I think the `pysqlite_connection_exit` function in 
src/connection.c should handle the case when the commit itself raises an 
exception, and invoke a rollback. Please see patch attached.

--
components: Extension Modules
files: fix_pysqlite_connection_exit.patch
keywords: patch
messages: 268678
nosy: lciti
priority: normal
severity: normal
status: open
title: pysqlite3 context manager not performing rollback when a database is 
locked elsewhere for non-DML statements
versions: Python 3.6
Added file: http://bugs.python.org/file43420/fix_pysqlite_connection_exit.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27333] validate_step in rangeobject.c, incorrect code logic but right result

2016-06-16 Thread Xiang Zhang

Changes by Xiang Zhang :


--
components: +Interpreter Core
type:  -> behavior
versions: +Python 2.7, Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27333] validate_step in rangeobject.c, incorrect code logic but right result

2016-06-16 Thread Xiang Zhang

New submission from Xiang Zhang:

Here is a drawback in validate_step of rangeobject. PyNumber_AsSsize_t returns 
clipped value and won't set an exception when the argument *exc* is set NULL. 
So if step overflows, istep is always PY_SSIZE_MAX or PY_SSIZE_MIN. But the 
following code is to check if istep is -1 and there is an exception. The code 
actually conflicts. But fortunately the result is always right. I suggest to 
make the code logic right.

--
files: incorrect_logic_in_validate_step.patch
keywords: patch
messages: 268677
nosy: xiang.zhang
priority: normal
severity: normal
status: open
title: validate_step in rangeobject.c, incorrect code logic but right result
Added file: 
http://bugs.python.org/file43419/incorrect_logic_in_validate_step.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27332] Clinic: first parameter for module-level functions should be PyObject*, not PyModuleDef*

2016-06-16 Thread Petr Viktorin

New submission from Petr Viktorin:

Currently, Argument Clinic generates "PyModuleDef * module" for the first 
argument of module-level functions. But, the functions are passed the actual 
module object, not the ModuleDef.

The correct type to use is PyObject*, which is used for modules in the 
PyModule_* API.

(It turns out nothing in core Python currently uses the argument except passing 
it to other _impl functions, but this could change as PEP 489 is improved upon.)

The attached patch contains manual changes only. Please run `make clinic` after 
applying it to regenerate a the code.

--
components: Argument Clinic
files: 0001-clinic-Switch-the-module-argument-to-PyObject.patch
keywords: patch
messages: 268676
nosy: encukou, larry, ncoghlan
priority: normal
severity: normal
status: open
title: Clinic: first parameter for module-level functions should be PyObject*, 
not PyModuleDef*
versions: Python 3.6
Added file: 
http://bugs.python.org/file43418/0001-clinic-Switch-the-module-argument-to-PyObject.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Bulk Adding Methods Pythonically

2016-06-16 Thread Random832
On Wed, Jun 15, 2016, at 15:03, Ethan Furman wrote:
> [1] https://docs.python.org/3/library/functions.html#locals
>  Yes, returning the class namespace is a language gaurantee.

How do you get a guarantee from that text? I don't see any definition
asserting that the "current local symbol table" is the class namespace
(more specifically, the object returned by (metaclass).__prepare__,
which will be copied into [not used as, for normal types]
(class).__dict__). We *know* that "representing the current local symbol
table" can and often does mean "copied from the local symbol table which
is not a in fact a dictionary" rather than "being the local symbol table
which is a real dictionary object" (that's *why*, after all, updating
locals() doesn't work in the general case), nor does it mention any
exemption to the warning about updating it.

If there's a guarantee of this, it's somewhere else.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bulk Adding Methods Pythonically

2016-06-16 Thread Julien Salort
Ethan Furman  wrote:

> If that is all correct, then, as Random suggested, move that loop into
> the class body and use locals() [1] to update the class dictionary. 
> Just make sure and delete any temporary variables.[
[...]
> [1] https://docs.python.org/3/library/functions.html#locals
>  Yes, returning the class namespace is a language gaurantee.

But that says:
"Note The contents of this dictionary should not be modified; changes
may not affect the values of local and free variables used by the
interpreter."

-- 
Julien Salort
Entia non sunt multiplicanda praeter necessitatem
http://www.juliensalort.org
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26171] heap overflow in zipimporter module

2016-06-16 Thread STINNER Victor

Changes by STINNER Victor :


--
versions: +Python 2.7, Python 3.4, Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27256] email header indentation destroyed

2016-06-16 Thread Hans-Peter Jansen

Hans-Peter Jansen added the comment:

Sorry guys for not providing this earlier.

It turned out, that the sub optimal behaviour is related to a unfortunate 
policy choice: email.policy.SMTP.

--
Added file: http://bugs.python.org/file43417/email_flatten.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27257] get_addresses results in traceback with an addrspec with an empty local part.

2016-06-16 Thread Hans-Peter Jansen

Hans-Peter Jansen added the comment:

Sorry guys for not providing this earlier.

It turned out, that the sub optimal behaviour is related to a unfortunate 
policy choice: email.policy.SMTP.

--
Added file: http://bugs.python.org/file43416/email_flatten.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27258] Exception in BytesGenerator.flatten

2016-06-16 Thread Hans-Peter Jansen

Hans-Peter Jansen added the comment:

Sorry guys for not providing this earlier.

It turned out, that the sub optimal behaviour is related to a unfortunate 
policy choice: email.policy.SMTP.

--
Added file: http://bugs.python.org/file43415/email_flatten.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24424] xml.dom.minidom: performance issue with Node.insertBefore()

2016-06-16 Thread Berker Peksag

Changes by Berker Peksag :


--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26985] Information about CodeType in inspect documentation is outdated

2016-06-16 Thread Xiang Zhang

Xiang Zhang added the comment:

Hmm, when I am going to delete the list in the docstring, I find other 
functions get lists too in inspect.py. So maybe we should open another issue to 
clean them after first merging this thread?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24424] xml.dom.minidom: performance issue with Node.insertBefore()

2016-06-16 Thread Robert Haschke

Robert Haschke added the comment:

Uploaded a "hg diff" against the recent 2.7 branch of the source repo.

--
Added file: http://bugs.python.org/file43414/minidom.insertBefore.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6057] sqlite3 error classes should be documented

2016-06-16 Thread Jaysinh shukla

Jaysinh shukla added the comment:

Adding forgotten reference of ProgrammingError to last patch. Please review 
issue6057_python3_6_v2.diff
Thanks!

--
Added file: http://bugs.python.org/file43413/issue6057_python3_6_v2.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24424] xml.dom.minidom: performance issue with Node.insertBefore()

2016-06-16 Thread Berker Peksag

Berker Peksag added the comment:

Please attach the patch in unified diff format. See 
https://docs.python.org/devguide/patch.html for details.

--
nosy: +berker.peksag

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27282] Raise BlockingIOError in os.urandom if kernel is not ready

2016-06-16 Thread Donald Stufft

Changes by Donald Stufft :


--
nosy:  -dstufft

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27266] Always use getrandom() in os.random() on Linux and add block=False parameter to os.urandom()

2016-06-16 Thread Donald Stufft

Changes by Donald Stufft :


--
nosy:  -dstufft

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27250] Add os.urandom_block()

2016-06-16 Thread Donald Stufft

Changes by Donald Stufft :


--
nosy:  -dstufft

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27288] secrets should use getrandom() on Linux

2016-06-16 Thread Donald Stufft

Changes by Donald Stufft :


--
nosy:  -dstufft

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27297] Add support for /dev/random to "secrets"

2016-06-16 Thread Donald Stufft

Changes by Donald Stufft :


--
nosy:  -dstufft

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22636] avoid using a shell in ctypes.util: replace os.popen with subprocess

2016-06-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

ctypes_util_popen-6.py2.patch LGTM.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6057] sqlite3 error classes should be documented

2016-06-16 Thread Jaysinh shukla

Jaysinh shukla added the comment:

Submitting the patch for Python 3.6.

--
keywords: +patch
Added file: http://bugs.python.org/file43412/issue6057_python3_6.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27292] Warn users that os.urandom() can return insecure values

2016-06-16 Thread Donald Stufft

Changes by Donald Stufft :


--
nosy:  -dstufft

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27292] Warn users that os.urandom() can return insecure values

2016-06-16 Thread STINNER Victor

STINNER Victor added the comment:

> As far as I can see (looking at Python/random.c and configure.ac), the 
> Solaris version should also use GRND_NONBLOCK:

Oh, you're right: I didn't notice that GRND_NONBLOCK was also used on Solaris. 
The change is not deliberate, but it is good to do that :-)

Solaris getrandom() is documented to fail with EAGAIN if "No entropy is 
available and GRND_NONBLOCK is set."
https://docs.oracle.com/cd/E53394_01/html/E54765/getrandom-2.html

The question is more if reading from /dev/urandom block in this case.

If we don't know, I would prefer to keep the "On Linux" prefix in the doc, and 
don't say anything about Solaris.

I'm able to check the behaviour of Solaris.

You should contact the developers who get access to Solaris, you can meet them 
in the previous random issues specific to Solaris: issue #25003 and issue 
#26735.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22228] Adapt bash readline operate-and-get-next function

2016-06-16 Thread Lele Gaifax

Lele Gaifax added the comment:

I will try to address your concerns.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24424] xml.dom.minidom: performance issue with Node.insertBefore()

2016-06-16 Thread GuiHome

GuiHome added the comment:

kindly ping

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27292] Warn users that os.urandom() can return insecure values

2016-06-16 Thread Martin Panter

Martin Panter added the comment:

Rebased so Rietveld can work with it, earlier version was my fault.

As far as I can see (looking at Python/random.c and configure.ac), the Solaris 
version should also use GRND_NONBLOCK:

#ifdef MS_WINDOWS
#elif defined(HAVE_GETENTROPY) && !defined(sun)
#else

#if defined(HAVE_GETRANDOM) || defined(HAVE_GETRANDOM_SYSCALL)
const int flags = GRND_NONBLOCK;
#ifdef HAVE_GETRANDOM
n = getrandom(dest, n, flags);
#else
n = syscall(SYS_getrandom, dest, n, flags);
#endif

Apart from using a C function call versus syscall(), I don’t see there is much 
difference between the Solaris and Linux cases. Correct me if I’m wrong though.

--
Added file: http://bugs.python.org/file43411/urandom-doc.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27292] Warn users that os.urandom() can return insecure values

2016-06-16 Thread STINNER Victor

STINNER Victor added the comment:

Strange, I don't see the [Review] button.

.. versionchanged:: 3.5.2
-  On Linux, if ``getrandom()`` blocks (the urandom entropy pool is not
+  If ``getrandom()`` blocks (the urandom entropy pool is not
   initialized yet), fall back on reading ``/dev/urandom``.

Please keep "On Linux", getrandom() is also used on Solaris, and my change is 
really restricted to Linux.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22228] Adapt bash readline operate-and-get-next function

2016-06-16 Thread Martin Panter

Martin Panter added the comment:

I will try to have a closer look at this some time, but my immediate worry is 
it looks like you are directly copying Bash code (GPL) into Python (less 
restrictive license).

Perhaps a more general solution would be to expose rl_add_defun() to native 
Python code, if that is possible.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27330] Possible leaks in ctypes

2016-06-16 Thread Martin Panter

Martin Panter added the comment:

Mostly looks good. I left a two comments.

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22228] Adapt bash readline operate-and-get-next function

2016-06-16 Thread Berker Peksag

Changes by Berker Peksag :


--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22228] Adapt bash readline operate-and-get-next function

2016-06-16 Thread Berker Peksag

Berker Peksag added the comment:

The review comments are at http://bugs.python.org/review/8/#ps12743 (you 
can also click to the 'review' link above)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: mod_python compilation error in VS 2008 for py2.7.1

2016-06-16 Thread asimkostas
Τη Τρίτη, 14 Ιουνίου 2016 - 3:36:23 μ.μ. UTC+3, ο χρήστης Pavel S έγραψε:
> Have you considered to use rather WSGI-based solution? (for Apache Httpd is 
> mod_wsgi). Mod_python is totally obsolete.

Regarding my blog post, i would like to inform you that someone helped me to 
overcome this error but i got another one that i do not know it's meaning:

deleted #define ssize_t

error: [Errno 22] invalid mode ('wb') or filename: "dist\\mod_python-'{' \x9b\x9
c\xa4 \x98\xa4\x98\x9a\xa4\xe0\xa8\xe5\x9d\x9c\xab\x98\xa0 \xe0\xaa \x9c\xa9\xe0
\xab\x9c\xa8\xa0\xa1\xe3 \xe3 \x9c\xa5\xe0\xab\x9c\xa8\xa0\xa1\xe3 \x9c\xa4\xab\
xa6\xa2\xe3,\n\x9c\xa1\xab\x9c\xa2\xe2\xa9\xa0\xa3\xa6 \xa7\xa8\xe6\x9a\xa8\x98\
xa3\xa3\x98 \xe3 \x98\xa8\xae\x9c\xe5\xa6 \x9b\xe2\xa9\xa3\x9e\xaa \x9c\xa4\x9c\
xa8\x9a\x9c\xa0\xe9\xa4..win32-py2.7.exe"


Any idea would help me a lot?  Attached file for more information!

Regards
Kostas Asimakopoulos
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is structured programming (was for/while else doesn't make sense)

2016-06-16 Thread Rustom Mody
On Thursday, June 16, 2016 at 11:27:15 AM UTC+5:30, Lawrence D’Oliveiro wrote:
> On Thursday, June 16, 2016 at 5:48:48 PM UTC+12, Rustom Mody wrote:
> > On Thursday, June 16, 2016 at 8:25:10 AM UTC+5:30, Lawrence D’Oliveiro 
> > wrote:
> > So here is the formal definition I remember from decades ago:
> > 
> > A structured flow-graph is one that has a single point of entry and exit.
> > And is recursively made from smaller structured flow graphs
> > With a finite set of 'graph combinators'
> > 
> > A structured program is one who's flow graph is structured
> > 
> > As I said I dont find this definition very useful since
> > break is unstructured as is return, yield and much else.
> 
> On the contrary, it fits in nicely. Imagine trying to represent your code as 
> a Nassi-Shneiderman diagram. This consists (recursively) of nested and/or 
> concatenated sub-diagrams. Each piece has one entry point at the top, and one 
> exit point at the bottom. In particular, it is *not possible* to express a 
> goto that jumps from one arbitrary point to another--everything must strictly 
> nest.
> 
> For example, a loop is entered at the top, and exited at the bottom. A 
> “break” in the loop can cut it short, but it cannot violate this rule.
> 
> Even my C code follows this nesting principle, because it is goto-free.

Please see https://en.wikipedia.org/wiki/Nassi%E2%80%93Shneiderman_diagram

| Nassi–Shneiderman diagrams have no representation for a GOTO statement.

which seems to be what you are saying. But then next para goes on...

| Nassi–Shneiderman diagrams are (almost) isomorphic with
| flowcharts. Everything you can represent with a Nassi–Shneiderman
| diagram you can also represent with a flowchart. For flowcharts
| of programs, almost everything you can represent with a flowchart
| you can also represent with a Nassi–Shneiderman diagram. The
| exceptions are constructs like goto and the C programming
| language break and continue statements for loops.

which is in line with what I am saying, viz that break/continue/goto are same
in the sense of being 'unstructured' and therefore do not fit into a structured
framework like NSDs
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27258] Exception in BytesGenerator.flatten

2016-06-16 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for helping to triage this, Pedro. I think there is a typo in your 
example: ``email.message_from_binary_file(fp)`` needs to be passed to 
``bs.flatten()``.

With the following script I'm also unable to reproduce the issue in Python 3.4+:

import email
import email.generator
import sys

with open('flatten-exception.mail', 'rb') as f:
msg = email.message_from_binary_file(f)
gen = email.generator.BytesGenerator(sys.stdout.buffer)
gen.flatten(msg)

Hans-Peter, could you share a reproducer with us? Thanks!

--
nosy: +berker.peksag

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22228] Adapt bash readline operate-and-get-next function

2016-06-16 Thread Lele Gaifax

Lele Gaifax added the comment:

The patch does not apply cleanly anymore, with current 3.6a3.

If there is any chance it could be taken into consideration, I will try to 
rebase it on top of current version.

@Berker: as I don't use Rietveld, is it possible for me to reach the comment 
you mentioned?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27292] Warn users that os.urandom() can return insecure values

2016-06-16 Thread Martin Panter

Martin Panter added the comment:

Here is a possible patch for 3.5+ based on my modest understanding of the 
concerns about insecure results and blocking. I hope that my wording is clear, 
couldn’t be confused with Linux’s /dev/random blocking and running out of fresh 
entropy, etc.

I also tried to make it clearer what APIs are used in what circumstances. It is 
not just Linux: we also call getrandom() on Solaris, because its getentropy() 
is not good enough.

--
keywords: +patch
Added file: http://bugs.python.org/file43410/urandom-doc.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27140] Opcode for creating dict with constant keys

2016-06-16 Thread STINNER Victor

STINNER Victor added the comment:

Nice enhancement.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10839] email module should not allow some header field repetitions

2016-06-16 Thread Berker Peksag

Berker Peksag added the comment:

> Right, that's what I meant by "plumb". :)

Sorry, apparently I can't read in the mornings :) I have just opened issue 
27331 to implement this idea.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27331] Add a policy argument to email.mime.MIMEBase

2016-06-16 Thread Berker Peksag

New submission from Berker Peksag:

Quoting Barry's message msg268430 from issue 10839:

On Jun 13, 2016, at 06:38 AM, Berker Peksag wrote:

>I don't know if it's a good idea or API but can we add a 'policy' keyword
>argument to email.mime.base.MIMEBase? Right now, this is the only way to
>change the default policy without using high level functions like
>email.message_from_string():
>
>m = MIMEMultipart()
>m.policy = email.policy.default

I think we just need to plumb a `policy` argument through to the ultimate 
base
class, email.message.Message

--
components: email
files: mimebase_policy.diff
keywords: patch
messages: 268653
nosy: barry, berker.peksag, r.david.murray
priority: normal
severity: normal
stage: patch review
status: open
title: Add a policy argument to email.mime.MIMEBase
type: enhancement
versions: Python 3.6
Added file: http://bugs.python.org/file43409/mimebase_policy.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27213] Rework CALL_FUNCTION* opcodes

2016-06-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Do you take this for your Demur?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27140] Opcode for creating dict with constant keys

2016-06-16 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Multiline parsing of python compiler demistification needed

2016-06-16 Thread Frank Millman
"Yubin Ruan"  wrote in message 
news:930753e3-4c9c-45e9-9117-d340c033a...@googlegroups.com...


Hi, everyone, I have some problem understand the rule which the python 
compiler use to parsing the multiline string.


Consider this snippet:

str_1 = "foo"
str_2 = "bar"

print "A test case" + \
   "str_1[%s] " + \
   "str_2[%s] " % (str_1, str_2)

Why would the snippet above give me an "TypeError: not all arguments 
converted during string formatting" while the one below not ?


This has nothing to do with multi-line strings.

Try that as a single line -

   print "A test case " + "str_1[%s] " + "str_2[%s]" % (str_1, str_2)

You will get the same error message.

The reason is that the use of the '+' sign to concatenate strings requires 
that each sub-string is a valid string in its own right.


The correct way to write it is -

   print "A test case " + "str_1[%s] " % (str_1) + "str_2[%s]" % (str_2)

If you wrote it without the '+' signs, the answer would be different. Python 
treats contiguous strings as a single string, so you could write it like 
this -


   print "A test case " "str_1[%s] " "str_2[%s]" % (str_1, str_2)

Frank Millman


--
https://mail.python.org/mailman/listinfo/python-list


Re: Multiline parsing of python compiler demistification needed

2016-06-16 Thread Jussi Piitulainen
Yubin Ruan writes:

> Hi, everyone, I have some problem understand the rule which the python
> compiler use to parsing the multiline string.
>
> Consider this snippet:
>
> str_1 = "foo"
> str_2 = "bar"
>
> print "A test case" + \
>"str_1[%s] " + \
>"str_2[%s] " % (str_1, str_2)
>
> Why would the snippet above give me an "TypeError: not all arguments
> converted during string formatting" while the one below not ?
>
> print "A test case" + \
>"str_1[%s] " % str1
>
> Obviously the first snippet have just one more line and one more
> argument to format than the second one. Isn't that unreasonable ? I
> couldn't find any clue about that. Anyone help ?

Multiline is irrelevant. What is happening is that % binds more tightly
(has a higher precedence) than +.

print "foo" + "bar %s" % "baz"
==> foobar baz

print "foo %s" + "bar %s" % ("baz", "baz")
==> Traceback (most recent call last):
  File "", line 1, in 
TypeError: not all arguments converted during string formatting

print ("foo %s" + "bar %s") % ("baz", "baz")
==> foo bazbar baz
-- 
https://mail.python.org/mailman/listinfo/python-list


[ANN] Pythran 0.7.5 is out

2016-06-16 Thread serge guelton
(sorry for the double posting, if any)

Dear pythraners and pythonists,

The Pythran team (still 2 active developers) is delighted to
announce the release of Pythran 0.7.5, available on the traditional
channels:

- pypi: https://pypi.python.org/pypi/pythran
- conda: https://anaconda.org/serge-sans-paille/pythran
- github: https://github.com/serge-sans-paille/pythran


What is it?
===

Pythran is a static compiler for numerical kernels written in Python + Numpy.
It basically turns Python-compatible modules into native ones,
eventually vectorized and parallelized.

Example
===

Following the tradition, each release comes with a code sample. This one
comes from http://jakevdp.github.io/blog/2012/08/24/numba-vs-cython/

#pythran export pythran_pairwise(float64 [][])
import numpy as np
def pythran_pairwise(X):
return np.sqrt(((X[:, None, :] - X) ** 2).sum(-1))

This kernel relies a lot on Numpy's broadcasting, but Pythran can now
compile it efficiently, which is a really nice improvement! It can rip
(without vectorization and parallelization turned on) more than a x5
speedup over the Numpy version \o/

More Infos
==

We have published some technical details about Pythran internal on the
blog:

http://serge-sans-paille.github.io/pythran-stories/

It is open to third-party contribution!

Changelog
=

* Better Jupyter Note book integration

* Numpy Broadcasting support

* Improved value binding analysis

* Simple inlining optimization

* Type engine improvement

* Less fat in the generated modules

* More and better support for various Numpy functions

* Various performance improvement

* Global variable handling, as constants only though

Acknowledgments
===

Thanks a lot to Pierrick Brunet for his dedicated work, and to all the
bug reporters and patch providers that helped a lot for this release:

nils-werner, ronbarak, fred oble, geekou, hainm, nbecker and xantares.

-- 
https://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Re: Multiline parsing of python compiler demistification needed

2016-06-16 Thread Peter Otten
Yubin Ruan wrote:

> Hi, everyone, I have some problem understand the rule which the python
> compiler use to parsing the multiline string.
> 
> Consider this snippet:
> 
> str_1 = "foo"
> str_2 = "bar"
> 
> print "A test case" + \
>"str_1[%s] " + \
>"str_2[%s] " % (str_1, str_2)
> 
> Why would the snippet above give me an "TypeError: not all arguments
> converted during string formatting" while the one below not ?
> 
> print "A test case" + \
>"str_1[%s] " % str1
> 
> Obviously the first snippet have just one more line and one more argument
> to format than the second one. Isn't that unreasonable ? I couldn't find
> any clue about that. Anyone help ?
> 
> I am using python 2.7.6
> 

It doesn't matter into how many lines you break your statement. The % 
operator has higher precedence than +, so

a + b % c

is evaluated as a + (b % c). When c is a 2-tuple and b contains only one 
"%s" that inevitably fails:

>>> "%s" + "%s" % (1, 2)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: not all arguments converted during string formatting

> Also, I know the **Pythonic** way to play with multiline, which would be
> using triple quote or a pair of parenthesis to surround the multiline
> string to make it a **online** string. You don't have to show code in that
> respect.

Did you know that adjacent string literals are merged into one? Compare:

>>> print "foo" + \
...   "%s" + \
...   "%s" % (1, 2)
Traceback (most recent call last):
  File "", line 3, in 
TypeError: not all arguments converted during string formatting
>>> print "foo" \
...   "%s" \
...   "%s" % (1, 2)
foo12


-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   >