Re: Python Print Error

2016-07-26 Thread Jussi Piitulainen
Cai Gengyang writes:

> How to debug this error message ?
>
> print('You will be ' + str(int(myAge) + 1) + ' in a year.')
> Traceback (most recent call last):
>   File "", line 1, in 
> print('You will be ' + str(int(myAge) + 1) + ' in a year.')
> ValueError: invalid literal for int() with base 10: ''

The last line is the error message:

ValueError: invalid literal for int() with base 10: ''

It's first component, ValueError, names a class of errors. It gives you
an idea (once you get used to error messages) of what might be wrong.

The second component describes this particular error:

invalid literal for int() with base 10

This refers to the argument to int(), and says it's an invalid
"literal", which is a bit obscure term that refers to a piece in
programming language syntax; it also informs you that the argument is
invalid in base 10, but this turns out to be irrelevant.

You should suspect that myAge is not a string of digits that form a
written representation of an integer (in base 10).

The third component shows you the invalid literal:

''

So the error message is telling you that you tried to call int(''), and
'' was an invalid thing to pass to int().

(Aside: Do not take "int()" literally. It's not the name of the
function, nor is it the actual call that went wrong. It's just a
shorthand indication that something went wrong in calling int, and the
argument is shown as a separate component of the message.)

Next you launch the interpreter and try it out:

>>> int('')
Traceback (most recent call last):
  File "", line 1, in 
ValueError: invalid literal for int() with base 10: ''

You can be pretty confident that the error is, indeed, just this. - Try
also int('ace') and int('ace', 16). That's where "base 10" is relevant.

The lines before the last are the traceback. They attempt to give you an
indication of where in the program the offending piece of code occurs,
but they need to do it dynamically by showing what called what. Scan
backwards and only pay attention to lines that you recognize (because
you are not studying an obscure bug in Python itself but a trivial
incident in your own program).

Often it happens that the real error in your program is somewhere else,
and the exception is only a symptom. In this case, you need to find
where myAge gets that value, or fails to get the value that is should
have.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27546] Integrate tkinter and asyncio (and async)

2016-07-26 Thread Guido van Rossum

Guido van Rossum added the comment:

OK, in the context of IDLE it probably doesn't matter (though I recall
that IDLE was given a hard time many years ago by people complaining
about that same busy-waiting -- I guess batteries have improved
somewhat since then).

--

___
Python tracker 

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



[issue17599] mingw: detect REPARSE_DATA_BUFFER

2016-07-26 Thread Martin Panter

Martin Panter added the comment:

Here is a patch implementing my suggestion to unconditionally define 
everything, prefixed with Py_ instead. Not tested on a normal Windows build.

--
versions: +Python 3.6 -Python 3.4
Added file: http://bugs.python.org/file43907/Py_REPARSE.patch

___
Python tracker 

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



[issue27626] Spelling fixes

2016-07-26 Thread Xiang Zhang

Xiang Zhang added the comment:

LGTM.

--
nosy: +xiang.zhang

___
Python tracker 

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



Python Print Error

2016-07-26 Thread Cai Gengyang
How to debug this error message ?

print('You will be ' + str(int(myAge) + 1) + ' in a year.')
Traceback (most recent call last):
  File "", line 1, in 
print('You will be ' + str(int(myAge) + 1) + ' in a year.')
ValueError: invalid literal for int() with base 10: ''
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27626] Spelling fixes

2016-07-26 Thread Martin Panter

Martin Panter added the comment:

Here is a patch that fixes some more related misspellings. This includes some 
test method names, and one internal C function variable.

FWIW nonexistant vs nonexistent may be a bit controversial (and neither look 
particularly wrong to me), so I didn’t change any other occurrences, but the 
existing change looks okay to be consistent with the “self._nonexistent_dir” 
spelling.

--
Added file: http://bugs.python.org/file43906/spelling.v2.patch

___
Python tracker 

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



[issue19613] test_nntplib: sporadic failures, test_article_head_body()

2016-07-26 Thread Martin Panter

Changes by Martin Panter :


Added file: http://bugs.python.org/file43905/ending-dot.v2.patch

___
Python tracker 

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



[issue19613] test_nntplib: sporadic failures, test_article_head_body()

2016-07-26 Thread Martin Panter

Changes by Martin Panter :


Removed file: http://bugs.python.org/file43904/ending-dot.v2.patch

___
Python tracker 

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



[issue19613] test_nntplib: sporadic failures, test_article_head_body()

2016-07-26 Thread Martin Panter

Martin Panter added the comment:

This version actually works :P

--
Added file: http://bugs.python.org/file43904/ending-dot.v2.patch

___
Python tracker 

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



[issue19613] test_nntplib: sporadic failures, test_article_head_body()

2016-07-26 Thread Martin Panter

Martin Panter added the comment:

I played with the server and group that is apparently used in the test:

>>> server = NNTP_SSL("nntp.aioe.org")
>>> [_, _, first, last, _] = server.group("fr.comp.lang.python")
>>> first
2900
>>> last
2915
>>> server.body(last)[1].lines[-1]
b''
>>> server.body(first)[1].lines[-1]
b'Merci'
>>> server.body(last - 1)[1].lines[-1]
b'Kevin'

I tried all articles from 2900–2915, and none of them end with a dot on its own 
line, so I don’t actually know what caused the failure.

However looking again at the _getlongresp() implementation, I cannot imagine 
how the test failure can occur except for a genuine body that ends with a dot 
on its own line (encoded as b".." and then converted to b"."). Here is a quick 
patch to alter the test cases.

--
keywords: +patch
stage: needs patch -> patch review
versions:  -Python 3.4
Added file: http://bugs.python.org/file43903/ending-dot.patch

___
Python tracker 

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



[issue27576] An unexpected difference between dict and OrderedDict

2016-07-26 Thread Xiang Zhang

Xiang Zhang added the comment:

I write a new version restoring the fast path for dict. It now uses PyDict_Next 
and seems to be much faster than the path using keys.

[cpython]$ ./python -m timeit -s 'from collections import OrderedDict; d = 
{"a":1,"c":2,"b":3,"d":4}' 'OrderedDict(d)'
100 loops, best of 3: 0.639 usec per loop
[cpython]$ ./python -m timeit -s 'from collections import OrderedDict; d = 
{"a":1,"c":2,"b":3,"d":4}' 'OrderedDict(d)'
100 loops, best of 3: 0.372 usec per loop

--
Added file: http://bugs.python.org/file43902/odict_update_v3.patch

___
Python tracker 

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



[issue19613] test_nntplib: sporadic failures, test_article_head_body()

2016-07-26 Thread Martin Panter

Martin Panter added the comment:

A few other buildbots shared this failure. It would be nice to see what the 
article is that is causing the failure, but I’m fairly confident we should just 
remove this part of the test.

--
stage:  -> needs patch

___
Python tracker 

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



Re: reshape with xyz ordering

2016-07-26 Thread Nobody
On Tue, 26 Jul 2016 07:10:18 -0700, Heli wrote:

> I sort a file with 4 columns (x,y,z, somevalue) and I sort it using
> numpy.lexsort.
> 
> ind=np.lexsort((val,z,y,x))
> 
> myval=val[ind]
> 
> myval is a 1d numpy array sorted by x,then y, then z and finally val.
> 
> how can I reshape correctly myval so that I get a 3d numpy array
> maintaining the xyz ordering of the data?

Is it guaranteed that the data actually *is* a 3-D array that's been
converted to a list of x,y,z,val tuples?

In other words, does every possible combination of x,y,z for 0<=x<=max(x),
0<=y<=max(y), 0<=z<=max(z) occur exactly once?

If so, then see Peter's answer. If not, then how do you wish to handle
a) (x,y,z) tuples which never occur (missing values), and
b) (x,y,z) tuples which occur more than once?

If the data "should" to be a 3-D array but you first wish to ensure that
it actually is, you can use e.g.

nx,ny,nz = max(x)+1,max(y)+1,max(z)+1
if val.shape != (nx*ny*nz,):
raise ValueError
i = (x*ny+y)*nz+z
found = np.zeros(val.shape, dtype=bool)
found[i] = True
if not np.all(found):
raise ValueError
ind = np.lexsort((val,z,y,x))
myval = val[ind].reshape((nx,ny,nz))

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


Re: making executables smaller

2016-07-26 Thread Steven D'Aprano
On Wed, 27 Jul 2016 03:22 am, Carter Temm wrote:

> Hi,
> I’m writing a couple different projects at the moment, and when I compile
> it into a single executable using pyinstaller, it becomes extremely large.

What do you consider "extremely large"? Ten gigabytes? 500 kilobytes? Give
us a clue.


> I’m guessing this is because of the modules used.

Maybe yes, maybe no.

On my system, Python 3.3 is a little bit less than 6 MB, and the std lib
under 130MB:


[steve@ando ~]$ du -hs /usr/local/bin/python3.3
5.7M/usr/local/bin/python3.3
[steve@ando ~]$ du -hs /usr/local/lib/python3.3/
129M/usr/local/lib/python3.3/

But nearly 50MB of that is the test suite:

[steve@ando test]$ du -hs /usr/local/lib/python3.3/test/
48M /usr/local/lib/python3.3/test/

I expect that on Windows or Mac OS X the sizes will be roughly the same.

I'm not an expert on the pyinstaller internals, but I would expect that it
would be able to drop the test suite, but will need to include the rest of
the std lib as well as the interpreter, plus whatever files you have
written. So I expect that a frozen executable will be of the order of 80MB,
give or take. There's probably a bit of overhead needed to hold it all
together, so let's say 100MB in round figures.

If you're getting less than 100MB, that doesn't sound too bad to me, not for
an interpreted language like Python. Anything less than that sounds really
good to me. If you are getting under 20MB, that's *fantastic*. What's the
problem with that? You can fit close to forty of these on a 4GB DVD-RW or
USB stick. You're not hoping to fit your application on a floppy disk are
you? Its 2016, not 1980.

If you're working with really constrained environments, like an embedded
device, then check out µPy or PyMite:

https://micropython.org/

http://deanandara.com/PyMite/

although I fear PyMite may not be under active development.



> Because I’m not that 
> skilled at python, I put stuff like for example, import sys. I imagine the
> final project could be made smaller by specifying from something import
> something_else. 

No, it doesn't work like that. For starters, sys is built into the
interpreter, so it's unlikely you'll be able to remove it. But more
generally, if you use anything from a module, the entire module must be
included.

Even if *you* don't use a module, perhaps one of the modules you do use will
in turn use that module. 


Of course, you can avoid all this overhead completely by *not* freezing the
executable down to a single file. Just distribute your Python code as a .py
file, or a .pyc file. There are other options as well, such as distributing
it bundled into a zip file. What benefit do you get from using PyInstaller?


> but the thing is, I don’t know what smaller I could import 
> with these set of modules. Is there a program that could tell me this.
> Sorry if this question is really basic, but it’d be helpful.



-- 
Steven
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


[issue11048] "import ctypes" causes segfault on read-only filesystem

2016-07-26 Thread Berker Peksag

Changes by Berker Peksag :


--
nosy: +berker.peksag
versions: +Python 3.5, Python 3.6 -Python 3.2, Python 3.3, Python 3.4

___
Python tracker 

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



Re: Python environment on mac

2016-07-26 Thread Cameron Simpson

On 26Jul2016 06:52, Crane Ugly  wrote:

Mac OS X comes with its own version of python and structure to support it.
So far it was good enough for me. Then I started to use modules that 
distributed through MacPorts and this is where I get lost.
I do not quite understand how Python environment is set. Or how to set it in a 
way of using, say MacPorts distribution alone.
For example: standard location for pip utility is /usr/local/bin/pip. MacPorts 
structure has it too but as a link
lrwxr-xr-x 1 root admin 67 May 23 22:32 /opt/local/bin/pip-2.7 -> 
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/pip
Which means that the standard utility will be used.


No, I think that means it uses the MacPorts one. Note: /opt/local vs 
/usr/local.



The things is that depending on a way I run pip I get different results:
$ pip list|grep pep8
pep8 (1.7.0)
$ sudo pip list|grep pep8
$
pep8 was installed through macports.
In second case pip is using stripped environment and pointing to standard Mac 
OS Python repository.
But in a way to install anything with pip I have to use sudo.
In my profile I have variable PYTHONPATH:
PYTHONPATH=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
It is pointing to macports structure. But when I use sudo (in case of using 
pip) it get stripped.
How to setup and maintain python environment in a trustful way? So it is clear 
where all installed modules are?


My personal habit is to use virtualenv. You could build a virtualenv based of 
the system Python or the MacPorts one (or make one of each). Then you can use 
pip (as yourself, no sudo - avoid that if possible) from the appropriate 
environment to install into that environment. Complete separation, and complete 
control for you.


The executables inside a virtualenv ("python", "pip" etc) are stubs that adjust 
PYTHONPATH etc themselves and then invoke the python one which that particular 
virtualenv was based. This means that by executing that _specific_ executable 
you automatically and correctly use that specific virtualenv. Without having to 
hand maintain your own $PYTHONPATH, and therefore with needing to adjust it 
depending which setup you want to use.


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Re: pyinstaller

2016-07-26 Thread Larry Martell
On Tue, Jul 26, 2016 at 8:49 PM, Tom Brown  wrote:
> I used pyinstaller quite a bit 3 years ago. I could brush off the cobwebs
> and see if I can help if you have not solved it already.
>
> What is the issue you are having?

If I import the requests module, then when I run the executable I get:

ImportError: No module named 'requests.packages.chardet'

I tried to post to the pyinstaller group, but it said my post had to
be approved by the moderator, and it apparently never was. I have no
idea who the moderator is, so there was no one I could contact about
that. I posted an issue to github
(https://github.com/pyinstaller/pyinstaller/issues/2060) and some
suggestions were made, but none fixed the problem. I am on RHEL 7.2
with Python 2.7.5, and it's reproducible, just by having a 1 line
script that has "import requests". Thanks for any help you could
provide.




>
> On Jun 21, 2016 16:57, "Larry Martell"  wrote:
>>
>> Anyone here have any experience with pyinstaller? I am trying to use
>> it, but I'm not having much success. I tried posting to the
>> pyinstaller ML but it said my post had to be approved first, and that
>> hasn't happened in a while. I'll post details if someone here thinks
>> they can help.
>> --
>> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23085] update internal libffi copy to 3.2.1

2016-07-26 Thread koobs

koobs added the comment:

Forgive me for asking a question that may have already been asked, or beaten to 
death, but what is preventing Python from requiring libffi as an 
external/required dependency, rather than keeping it and taking on the burden 
of fixes/backporting in lieu of updates or pending releases from upstream?

Historically (at least the last ~2-3 years), libffi in Python has been plagued 
with, at least:

* Inconsistent / incorrect merging of libffi fixes (including regressions)
* Unsolved issues in vendored copy that have been fixed/released upstream
* Complex, manual and error-prone updates to vendored copy
* Lack of regular maintenance, from what largely appears to be a lack of 
knowledge about, or confidence in updating the vendored copy (fear of breakage)

I know at least FreeBSD currently requires --sytem-libffi for i386 systems in 
certain versions due to issue 22521 (issue 23042) and there are currently 50 
open issues matching libffi (granted not all of them will be root-caused by 
libffi internal). I note that number to highlight the maintenance requirement.

--

___
Python tracker 

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



[issue27630] Generator._encoded_EMTPY misspelling in email package

2016-07-26 Thread Martin Panter

New submission from Martin Panter:

In the Generator.flatten() (Lib/email/generator.py), the code sets, among 
others, the instance attributes _EMPTY (correct spelling) and _encoded_EMTPY 
(misspelling). Further down in that class, _encoded_EMPTY (correct spelling) is 
set as a class attribute, and this correctly-spelt version appears to be used 
in the _handle_message_delivery_status() method. The BytesGenerator class 
inherits Generator and overrides the correctly-spelt _encoded_EMPTY class 
attribute.

It seems that both _EMPTY and the misspelt _encoded_EMTPY instance attributes 
are not used. Perhaps they should be removed. Or perhaps they are not doing the 
job they were intended for and there is a real bug.

--
components: email
messages: 271424
nosy: barry, martin.panter, r.david.murray
priority: normal
severity: normal
status: open
title: Generator._encoded_EMTPY misspelling in email package
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



[issue19613] test_nntplib: sporadic failures, test_article_head_body()

2016-07-26 Thread koobs

Changes by koobs :


--
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



[issue19613] test_nntplib: sporadic failures, test_article_head_body()

2016-07-26 Thread koobs

koobs added the comment:

This just failed on 3.x (default) on koobs-freebsd{9,10} bots:

==
FAIL: test_article_head_body (test.test_nntplib.NetworkedNNTP_SSLTests)
--
Traceback (most recent call last):
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd10/build/Lib/test/test_nntplib.py", 
line 240, in wrapped
meth(self)
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd10/build/Lib/test/test_nntplib.py", 
line 185, in test_article_head_body
self.check_article_resp(resp, body, art_num)
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd10/build/Lib/test/test_nntplib.py", 
line 165, in check_article_resp
self.assertNotIn(article.lines[-1], (b".", b".\n", b".\r\n"))
AssertionError: b'.' unexpectedly found in (b'.', b'.\n', b'.\r\n')

--

Full log attached

--
keywords: +buildbot
nosy: +koobs
Added file: 
http://bugs.python.org/file43901/koobs-freebsd-10-python-3x-build-4682.txt

___
Python tracker 

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



[issue27546] Integrate tkinter and asyncio (and async)

2016-07-26 Thread Yury Selivanov

Yury Selivanov added the comment:

> A proper solution IMO should somehow merge the selectors so that a
> single select() or whatever wakes up when either network I/O happens
> or a UI event comes in (which could be something that Tk transparently
> handles but it still needs to be given the chance, through
> root.update()).

I think we can do something similar to self-pipe trick: have a pipe
and a reader for it registered with 'loop.add_reader'. Whenever
a UI thread have an event to process, it should write a byte to the
pipe.

I'm not sure if there's a way to do that with Tk.

--

___
Python tracker 

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



Re: pyinstaller

2016-07-26 Thread Tom Brown
I used pyinstaller quite a bit 3 years ago. I could brush off the cobwebs
and see if I can help if you have not solved it already.

What is the issue you are having?

-Tom

On Jun 21, 2016 16:57, "Larry Martell"  wrote:

> Anyone here have any experience with pyinstaller? I am trying to use
> it, but I'm not having much success. I tried posting to the
> pyinstaller ML but it said my post had to be approved first, and that
> hasn't happened in a while. I'll post details if someone here thinks
> they can help.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: making executables smaller

2016-07-26 Thread Carter Temm
OK. So I guess the question should be, how can I make these executables smaller 
in general?

Sent from my iPhone

> On Jul 26, 2016, at 5:13 PM, Dennis Lee Bieber  wrote:
> 
> On Tue, 26 Jul 2016 12:22:16 -0500, Carter Temm 
> declaimed the following:
> 
>> Hi,
>> I’m writing a couple different projects at the moment, and when I compile it 
>> into a single executable using pyinstaller, it becomes extremely large. I’m 
>> guessing this is because of the modules used. Because I’m not that skilled 
>> at python, I put stuff like for example, import sys. I imagine the final 
>> project could be made smaller
> by specifying from something import something_else. but the thing is, I don’t 
> know what smaller I could import with these set of modules. Is there a 
> program that could tell me this. Sorry if this question is really basic, but 
> it’d be helpful.
> 
>"from module import name" still has to include the entire module --
> since that is the file. It is effectively the same as doing
> 
> import module
> name = module.name
> del module
> 
>Also -- anything that creates an executable file for Python will be
> including the Python interpreter ITSELF. That may be a lot of the bloat you
> see.
> -- 
>Wulfraed Dennis Lee Bieber AF6VN
>wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27546] Integrate tkinter and asyncio (and async)

2016-07-26 Thread Terry J. Reedy

Terry J. Reedy added the comment:

> wasting battery power ?!  We live in slightly different computing universes 
> ;-).  But I get the point.  The last two files I uploaded use call_later and 
> I should stick with that.  I should also add a note that the innermost 
> asyncio loop function sleeps when there is nothing to do and that the tk 
> updater wakes it up, if necessary, to check for gui events even when there 
> are none.  Updater is polling rather than interrupt based.  Or in other 
> words, it interrupts asyncio to poll tk.

I should also say that the update interval is passed in to the class so one can 
make an instance-specific tradeoff between overhead and responsiveness and 
display update frequency.  A read-only display might be updated just once a 
minute.

If loop.call_later(0.1, tk_update) is actually a problem on a system, then IDLE 
would likely be twice as bad, as it also has a busy loop in the user process, 
polling both the socket connection and calling tk update 20 times a second.  
There are also loops in the IDLE process.


I agree on the ideal solution and on the key component, which is to sleep until 
there is a ready Task or file event.  _run_once does this in the select call by 
adjusting the timeout to the minimum time to the next ready task (possibly 0).

Tcl has such a component, with the addition of simultaneously waiting for 
window events -- but it only only includes file events on unix.  (It took a 
brave and talented group to try to reconcile the Unix and Windows models.)

Here is a simplified Python version of Tcl_DoOneEvent. 
http://www.tcl.tk/man/tcl8.6/TclLib/DoOneEvent.htm  

Tcl has window, file, timer, and idle events.  Window events include user key 
and mouse events and other from the graphics system.  The first three types all 
go in one ready queue. Idle events are those that affect what the user sees on 
the screen and go in a separate, lower-priority queue.

def do_one_event(sleep_ok):
if ready:
process(ready.pop())
return True
load_ready()
if ready:
process(ready.pop())
return True
if idle:
for event in idle:
process(event)
return True
if sleep_ok:
sleep_until_event()  # the hard part
load_ready()
process(ready.pop())
return True
else:
return False

def load_ready():
# In some unspecified order
ready.extend(get_window_events)  # graphics system
ready.extend(get_file_events)  # select
ready.extend(get_timer_events)  # priority queue pops

Update processes all events available without sleeping. 
http://www.tcl.tk/man/tcl8.6/TclCmd/update.htm
Mainloop continues (with sleeps) while there are toplevels and not stopped.

def update():
while(do_one_event(sleep_ok=False)): pass

def mainloop():
while toplevels and not stop:
do_one_event()

Sleep_ok is actually a dont_sleep bit flag. DoOneEvent has other flags to 
select which types of event to process.  Hence

def update_idletasks()  # all currently ready
do_one_event(dont_sleep | idletasks)

It is possible for the idle queue to get starved for attention.  Hence the 
existence of update_idletasks and recommendations to call it in certain 
situations.


It would also be possible to call (from Python, via tcl) 
do_one_event(dont_sleep | gui_events) IF it were known that a gui event was 
ready to be retrieved.  It is knowing that, without polling in a 'busy loop' 
that is hard to impossible.  If it were possible, an extra call to do idletasks 
would also be needed..

In summary, I see this as a situation where practicality beats a possibly 
unattainable purity.

--

___
Python tracker 

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



[issue27629] Cannot create ssl.SSLSocket without existing socket

2016-07-26 Thread Emanuel Barry

Emanuel Barry added the comment:

Thank you for the report and the patch! :) This will need a test in 
Lib/test/test_ssl.py to check for this particular case.

I've removed 3.3 and 3.4 from the Versions field, since these versions no 
longer get regular bugfixes (only security bugfixes may go in these). As a 
result, only 3.5 and 3.6 will get the fix.

--
nosy: +alex, christian.heimes, dstufft, ebarry, giampaolo.rodola, janssen, 
pitrou
stage:  -> patch review
versions:  -Python 3.3, Python 3.4

___
Python tracker 

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



Re: Depending on enum34 from a library

2016-07-26 Thread Ethan Furman

On 07/24/2016 01:10 PM, Vasiliy Faronov wrote:


I'm building a Python library where I want to use Python 3.4-style
enums. Because I need to support Python 2.7, I'm considering using
enum34 [1]. But I'm not sure how to do this:

If I simply depend on enum34, it will install a module named `enum`
even in Python 3.4+ environments, and that could shadow the stdlib
module. Personally I would be very surprised if installing a library
caused an unrelated stdlib module to be replaced with a third-party
one, even if it's "just" a backport. However, in my environments,
`sys.path` is such that stdlib comes before site-packages -- perhaps
this is normal enough that I can rely on it?

Or I could change my setup.py to include enum34 in `install_requires`
only if running on Python 2.7. But that will make my distribution's
metadata dynamic, which doesn't sound like a good idea [2]. At the
very least, I think it will prevent me from building a universal
wheel.


enum34 is kept up-to-date, as far as I am able, with the current version of
enum in the stdlib.  As a happy side-effect if it is found before the stdlib
version Python will still run -- at least for Python 3.4 and 3.5; 3.6 is
adding some new features that I am not planning on adding to enum34.

For my own code I use the 'install_requires' option, plus some code that
checks the Python version to see if enum34 is needed.

Your other option is to use aenum [1], my other package, instead; it does
not risk conflict with enum, but has the same basic behavior (plus lots of
advanced behavior you can opt in to).

--
~Ethan~

[1] https://pypi.python.org/pypi/aenum
--
https://mail.python.org/mailman/listinfo/python-list


[issue27629] Cannot create ssl.SSLSocket without existing socket

2016-07-26 Thread nemunaire

Changes by nemunaire :


--
title: Cannot create raw ssl.SSLSocket -> Cannot create ssl.SSLSocket without 
existing socket

___
Python tracker 

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



[issue27629] Cannot create raw ssl.SSLSocket

2016-07-26 Thread nemunaire

New submission from nemunaire:

I got this stacktrace:
  File "test_ssl.py", line 3, in 
sock = ssl.SSLSocket(server_hostname="docs.python.org")
  File "/usr/lib/python3.4/ssl.py", line 536, in __init__
if sock.getsockopt(SOL_SOCKET, SO_TYPE) != SOCK_STREAM:
AttributeError: 'NoneType' object has no attribute 'getsockopt'

with this minimal code:
import ssl

sock = ssl.SSLSocket(server_hostname="docs.python.org")
sock.connect(("docs.python.org", 443))
sock.sendall(b"GET /3/library/ssl.html HTTP/1.0\r\nHost: 
docs.python.org\r\n\r\n")
print(sock.recv(4096).decode())

Whereas the None socket is correctly handled a few lines later: 
https://hg.python.org/cpython/file/tip/Lib/ssl.py#l715

All Python >= 3.3 are affected (since 
https://hg.python.org/cpython/rev/a00842b783cf) and can be patched with the 
same file, attached to this issue.

--
components: Library (Lib)
files: fix_sslsocket_init_without_socket_3.3-3_6.patch
keywords: patch
messages: 271419
nosy: nemunaire
priority: normal
severity: normal
status: open
title: Cannot create raw ssl.SSLSocket
type: behavior
versions: Python 3.3, Python 3.4, Python 3.5, Python 3.6
Added file: 
http://bugs.python.org/file43900/fix_sslsocket_init_without_socket_3.3-3_6.patch

___
Python tracker 

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



Re: NumPy frombuffer giving nonsense values when reading C float array on Windows

2016-07-26 Thread eryk sun
 On Tue, Jul 26, 2016 at 6:31 PM, sth  wrote:
>
> The restype is a ctypes Structure instance with a single __fields__ entry 
> (coords), which

Watch the underscores with ctypes attributes. Your code spells it
correctly as "_fields_".

> is a Structure with two fields (len and data) which are the FFI array's 
> length and the void
> pointer to its memory:
> https://github.com/urschrei/pypolyline/blob/master/pypolyline/util.py#L109-L117

_FFIArray.__init__ isn't properly keeping a reference to the wrapped
numpy array:

def __init__(self, seq, data_type = c_double):
ptr = POINTER(data_type)
nparr = np.array(seq, dtype=np.float64)
arr = nparr.ctypes.data_as(ptr)
self.data = cast(arr, c_void_p)
self.len = len(seq)

arr doesn't have a reference to nparr, so self.data doesn't have a
reference to the numpy array when it goes out of scope. For example,
we can trigger a segfault here:

>>> nparr = np.array(range(2**24), dtype=np.float64)
>>> ptr = ctypes.POINTER(ctypes.c_double)
>>> arr = nparr.ctypes.data_as(ptr)
>>> arr[0], arr[2**24-1]
(0.0, 16777215.0)

>>> del nparr
>>> arr[0], arr[2**24-1]
Segmentation fault (core dumped)

> I'm only half-following your explanation of how ctypeslib works, but it seems 
> clear that I'm doing
> something wrong.

The library requires the data pointers wrapped in a struct with the
length, so I think what you're doing to wrap and unwrap arbitrary
sequences is generally fine. But you don't need the bytes copy from
string_at. You can cast to a double pointer and create a numpy array
from that, all without copying any data. The only copy made is for
tolist(). For example:

def _void_array_to_nested_list(res, func, args):
""" Dereference the FFI result to a list of coordinates """
try:
shape = res.coords.len, 2
ptr = cast(res.coords.data, POINTER(c_double))
array = np.ctypeslib.as_array(ptr, shape)
return array.tolist()
finally:
drop_array(res.coords)

If you're not hard coding the double data type, consider adding a
simple C type string to the _FFIArray struct. For example:

>>> ctypes.c_double._type_
'd'

You just need a dict to map type strings to simple C types.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue16353] add function to os module for getting path to default shell

2016-07-26 Thread Michael Felt

Michael Felt added the comment:

An interesting read, but I am lost in what the goal is.

e.g., on AIX, which I know well, the system default is /bin/ksh (aka 
/usr/bin/ksh). However, /bin/sh (/usr/bin/sh) is available as well.

My expectation is that on Linux the default shell is /bin/bash, and like AIX 
/bin/sh is also available.

/bin/sh, /bin/ksh, /bin/bash are all (potentially) default shells. However, 
something every posix system is "sh" aka borne shell.

Aside: windows is different, and I expect has a different syntax. 

So, if the goal is to GET the pathname of the so-called "default" shell -again, 
interesting - BUT - what does that buy me?

For Popen or now subprocess I would want a consistent shell syntax, i.e., borne 
shell on posix, cmd.exe on windows, and whatever is correct on platforms that 
do not fit in these two.

Hence, on posix platforms where /bin/sh does not exist (hard)code the correct 
path for that platform.

FYI: CS_PATH does not exist on AIX

IMHO: (as others have stated) having . in PATH is bad for security, being 
dependent on PATH opens other security concerns as well.

IMHO2: KISS principle. After several years there is still no consenus, so make 
it simple - the popen and subprocess shell is one of /bin/sh, cmd.exe, or some 
other "hard-coded" shell.

(Although I thought that subprocess called "program" directly. Python is still 
new, so if not applicable for subprocess - please ignore

rereading, direct call would be when shell=False I expect.

Anyway, my two cents.

--
nosy: +Michael.Felt

___
Python tracker 

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



[issue25825] AIX shared library extension modules installation broken

2016-07-26 Thread Michael Felt

Michael Felt added the comment:

hmm. needs patch. For what?

One comment says a change will be undone.

If a patch is expected for src/builddir issue:

a) I sinned - that is a new issue, and should be posted seperately.
b) i do not know autotools well enough to solve the srcdir and builddir problem.

rather than a patch i can on that is see if the same issue occurs with linux 
and post a new issue.

So, my question would be - was a rollback done - if yes, perhaps a comment to 
verify and then close this issue.

--

___
Python tracker 

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



Is there a documented pylibpd (pure data wrapper/library) API?

2016-07-26 Thread Michael Sperone
Hi everyone,

I'm starting using the libpd wrapper/library for python (pylibpd), to load
and use my pure data patches within Python.  I was wondering if there was
any online documentation for this python version?  At the least I'm looking
for a list of classes and methods.

Thank you!
Mike
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27624] unclear documentation on Queue.qsize()

2016-07-26 Thread Doug Hoskisson

Doug Hoskisson added the comment:

My suggestion for this documentation:

"""
Return the number of items in the queue. Note, in multi-threading this mostly 
just serves as an approximation, and information from this doesn’t guarantee 
that a subsequent get() or put() will not block.
"""

--

___
Python tracker 

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



[issue27624] unclear documentation on Queue.qsize()

2016-07-26 Thread Doug Hoskisson

Doug Hoskisson added the comment:

One thing that is important to recognize in considering this, is which 
information is specific to what is being documented, and which information is 
more general.

Some people may think that documentation should only give information specific 
to what is being documented. Others may think it is useful to also include 
general information that can help people learn.

I don't know whether the writers of Python documentation lean to one of these 
or the other, but this contains a significant amount of information that has 
nothing to do with Python specifically, nothing to do with this class 
specifically, and nothing to do with this function specifically. (Again, I'm 
not saying this is bad. I just think it's important for people to recognize it.)

It's just general multi-threading knowledge. Anyone who knows about 
multi-threading (in any language) knows that the queue could change between two 
function calls.

But despite that extra general information, there is some specific information 
missing. Does it return the size of the queue (at the time the memory is 
accessed by the function call)? or does it use a more complex strategy for 
approximating the size of the queue? The reason this information is important 
is that if it is the former, that would be useful in single-threaded situations.

I am guessing that it is the former, but I don't know because not enough 
information is given.

Assuming that guess, I think following the model I see in the documentation of 
the next 2 functions on the page (Queue.empty() and Queue.full()) would be a 
good idea. That is, that the first sentence should only contain information 
specific to what is being documented, and more general information (about 
multi-threading) can be given afterward.

The fact that the size returned is approximate would have nothing to do with 
this function specifically, and it is just general information about how 
multi-threading works.

My suggestion for this documentation (again, assuming that my guess of the 
missing information is correct) I will put in a separate comment because this 
comment will be TLDR for many.

If my guess is incorrect, then something should be clarified to lessen people 
guessing thus. (Maybe this is just projecting, but I think most people would 
make the same guess that I am making.)

--

___
Python tracker 

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



ANN: PyQt v5.7 Released

2016-07-26 Thread Phil Thompson
PyQt v5.7 has been released. These are the Python bindings for the Qt 
application toolkit and runs on Linux, OS X, Windows, iOS and Android.

Also released for the first time under the GPL are PyQtChart, 
PyQtDataVisualization and PyQtPurchasing.

PyQtChart are the bindings for the Qt Charts library. This implements a set of 
classes for creating and manipulating 2D charts.

PyQtDataVisualization are the bindings for the Qt Data Visualization library. 
This implements a set of classes for representing data in 3D and allowing the 
user to interact with the view.

PyQtPurchasing are the bindings for the Qt Purchasing library. This implements 
a set of classes that allow applications to support in-app purchases from the 
Mac App Store on OS X, the App Store on iOS, and Google Play on Android.

Wheels are available from PyPI and include the relevent Qt libraries - nothing 
else needs to be installed.

Source packages and more information can be found at 
https://www.riverbankcomputing.com/.

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


[issue24773] Implement PEP 495 (Local Time Disambiguation)

2016-07-26 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

It looks like th Morocco issue has been reported to CentOS recently but they 
kicked it upstream. 

https://sourceware.org/ml/libc-help/2016-04/msg0.html

--

___
Python tracker 

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



[issue24773] Implement PEP 495 (Local Time Disambiguation)

2016-07-26 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

Also reported for Ubuntu:

https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1587128

--

___
Python tracker 

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



[issue24214] Exception with utf-8, surrogatepass and incremental decoding

2016-07-26 Thread RalfM

RalfM added the comment:

I just tested Python 3.6.0a3, and that (mis)behaves exactly like 3.4.3.

--
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



[issue27617] Compiled bdist_wininst missing from embedded distribution

2016-07-26 Thread Steve Dower

Steve Dower added the comment:

It's core Python, but it's specifically intended for producing redistributable 
installers containing Python packages. This is not something that the embedded 
distro is meant for, and it neatens things up to omit them.

There is very little information because it's considered an internal 
implementation detail (otherwise it would be thoroughly documented). That said, 
because of the narrower use case for the embedded distro, omitting even 
thoroughly documented modules would be okay if it didn't make sense in this 
context (e.g. the turtledemo module is documented, but also not in the embedded 
distro).

--

___
Python tracker 

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



Re: FW: error in python IDLE

2016-07-26 Thread Terry Reedy

On 7/26/2016 1:51 PM, Nakirekanti Jahnavi wrote:

Sent from Mail for Windows 10

From: Nakirekanti Jahnavi


The above is all I see.
This is a text-only, no-attachment list.

--
Terry Jan Reedy

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


[issue27346] Implement os.readv() / os.writev() in Windows port

2016-07-26 Thread Марк Коренберг

Changes by Марк Коренберг :


--
title: Implement os.readv() / os.writev() -> Implement os.readv() / os.writev() 
in Windows port

___
Python tracker 

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



[issue27617] Compiled bdist_wininst missing from embedded distribution

2016-07-26 Thread Michael Smith

Michael Smith added the comment:

Thanks so much Steve I got it working right away!

I peeked into the bdist_wininst.py and saw that it also depended on some local 
exe files.  Copied both of those to the embedded and everything worked like a 
charm.  I did read the documentation previously so I thought the only real 
dependency was the C Runtime.  Working on a network without any net access I 
have to bring in libraries we version, so basically what you describe 
"vendoring".

If you have time to answer I would like to understand why this particular item 
is not part of the embedded.  Or why is it in the regular install by default?  
When I look at the distutils documentation there is very little information 
about this file.  Is this particular item a 3rd party not core python or?  In 
any case thanks for the help again.

--

___
Python tracker 

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



[issue27624] unclear documentation on Queue.qsize()

2016-07-26 Thread Doug Hoskisson

Doug Hoskisson added the comment:

The way that this whole page of documentation is written does not suggest that 
this class is ONLY for use in a multi-threaded setting.

This class can be used without multi-threading, right?

Wouldn't it be useful to know whether this function does give the exact size of 
the queue in a single-threaded setting?

Right now, it doesn't contain that information.

--

___
Python tracker 

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



[issue27628] ipaddress incompatibility with ipaddr: __contains__ between networks

2016-07-26 Thread Berker Peksag

Berker Peksag added the comment:

See also issue 25431.

--

___
Python tracker 

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



[issue25431] implement address in network in ipaddress module

2016-07-26 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the report and for the patch, Aleksandr. This is a duplicate of 
issue 20825. See also issue 27628 for a similar report.

--
dependencies:  -speed up ipaddress __contain__ method
nosy: +berker.peksag
resolution:  -> duplicate
stage: patch review -> resolved
status: open -> closed
superseder:  -> containment test for "ip_network in ip_network"

___
Python tracker 

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



[issue27624] unclear documentation on Queue.qsize()

2016-07-26 Thread R. David Murray

R. David Murray added the comment:

What if we just replaced the period with a colon?  That is, the definition of 
"approximate" is the two rules in the second sentence.

--
nosy: +rhettinger

___
Python tracker 

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



Re: making executables smaller

2016-07-26 Thread Wildman via Python-list
On Tue, 26 Jul 2016 12:22:16 -0500, Carter Temm wrote:

> Hi,
> I’m writing a couple different projects at the moment, and when I
> compile it into a single executable using pyinstaller, it becomes
> extremely large. I’m guessing this is because of the modules used.
> Because I’m not that skilled at python, I put stuff like for example,
> import sys. I imagine the final project could be made smaller by
> specifying from something import something_else. but the thing is,
> I don’t know what smaller I could import with these set of modules.
> Is there a program that could tell me this. Sorry if this question
> is really basic, but it’d be helpful.

Try importing only the modules you actually use.
For example, instead of:

import os

Try using:

import os.path
import os.environ
import os.whatever

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27624] unclear documentation on Queue.qsize()

2016-07-26 Thread Doug Hoskisson

Doug Hoskisson added the comment:

Some strategies for approximating might report a size the the queue has never 
been and never will be. For example, a strategy could gather data and find the 
size is increasing at some rate, and approximate based on that rate, but then 
the rate of increase changes before it reaches the approximated size. That's 
the kind of thing that "approximate" would suggest to some people.

--

___
Python tracker 

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



[issue27619] getopt should strip whitespace from long arguments

2016-07-26 Thread R. David Murray

R. David Murray added the comment:

I realized some time after I posted that my comment about it emulating C getopt 
needed a gloss.  What I meant was that C getopt is the model, so there should 
be a sufficient argument that adding a feature is worthwhile.  You are making 
that argument, but Serhiy and I disagree that it is worthwhile, or consistent 
with the fact that Python is a programming language and not a shell.

We may be in the minority, though, for all we know.

--

___
Python tracker 

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



Re: NumPy frombuffer giving nonsense values when reading C float array on Windows

2016-07-26 Thread sth
On Tuesday, 26 July 2016 19:10:46 UTC+1, eryk sun  wrote:
> On Tue, Jul 26, 2016 at 12:06 PM,  sth wrote:
> > I'm using ctypes to interface with a binary which returns a void pointer 
> > (ctypes c_void_p) to a nested 64-bit float array:
> 
> If this comes from a function result, are you certain that its restype
> is ctypes.c_void_p? I commonly see typos here such as setting
> "restypes" instead of "restype".
> 
> > [[1.0, 2.0], [3.0, 4.0], … ]
> > then return the pointer so it can be freed
> >
> > I'm using the following code to de-reference it:
> >
> > # a 10-element array
> > shape = (10, 2)
> > array_size = np.prod(shape)
> > mem_size = 8 * array_size
> > array_str = ctypes.string_at(ptr, mem_size)
> > # convert to NumPy array,and copy to a list
> > ls = np.frombuffer(array_str, dtype="float64", 
> > count=array_size).reshape(shape).tolist()
> > # return pointer so it can be freed
> > drop_array(ptr)
> > return ls
> >
> > This works correctly and consistently on Linux and OSX using NumPy 1.11.0, 
> > but fails on
> > Windows 32 bit and 64-bit about 50% of the time, returning nonsense values. 
> > Am I doing
> > something wrong? Is there a better way to do this?
> 
> numpy.ctypeslib facilitates working with ctypes functions, pointers
> and arrays via the factory functions as_array, as_ctypes, and
> ndpointer.
> 
> ndpointer creates a c_void_p subclass that overrides the default
> from_param method to allow passing arrays as arguments to ctypes
> functions and also implements the _check_retval_ hook to automatically
> convert a pointer result to a numpy array.
> 
> The from_param method validates an array argument to ensure it has the
> proper data type, shape, and memory layout. For example:
> 
> g = ctypes.CDLL(None) # Unix only
> Base = np.ctypeslib.ndpointer(dtype='B', shape=(4,))
> 
> # strchr example
> g.strchr.argtypes = (Base, ctypes.c_char)
> g.strchr.restype = ctypes.c_char_p
> 
> d = np.array(list(b'012\0'), dtype='B')
> e = np.array(list(b'0123\0'), dtype='B') # wrong shape
> 
> >>> g.strchr(d, b'0'[0])
> b'012'
> >>> g.strchr(e, b'0'[0])
> Traceback (most recent call last):
>   File "", line 1, in 
> ctypes.ArgumentError: argument 1: :
> array must have shape (4,)
> 
> The _check_retval_ hook of an ndpointer calls numpy.array on the
> result of a function. Its __array_interface__ property is used to
> create a copy with the defined data type and shape. For example:
> 
> g.strchr.restype = Base
> 
> >>> d.ctypes._as_parameter_ # source address
> c_void_p(24657952)
> >>> a = g.strchr(d, b'0'[0])
> >>> a
> array([48, 49, 50,  0], dtype=uint8)
> >>> a.ctypes._as_parameter_ # it's a copy
> c_void_p(19303504)
> 
> As a copy, the array owns its data:
> 
> >>> a.flags
>   C_CONTIGUOUS : True
>   F_CONTIGUOUS : True
>   OWNDATA : True
>   WRITEABLE : True
>   ALIGNED : True
>   UPDATEIFCOPY : False
> 
> You can subclass the ndpointer type to have _check_retval_ instead
> return a view of the result (i.e. copy=False), which may be desirable
> for a large result array but probably isn't worth it for small arrays.
> For example:
> 
> class Result(Base):
> @classmethod
> def _check_retval_(cls, result):
> return np.array(result, copy=False)
> 
> g.strchr.restype = Result
> 
> >>> a = g.strchr(d, b'0'[0])
> >>> a.ctypes._as_parameter_ # it's NOT a copy
> c_void_p(24657952)
> 
> Because it's not a copy, the array view doesn't own the data, but note
> that it's not a read-only view:
> 
> >>> a.flags
>   C_CONTIGUOUS : True
>   F_CONTIGUOUS : True
>   OWNDATA : False
>   WRITEABLE : True
>   ALIGNED : True
>   UPDATEIFCOPY : False

The restype is a ctypes Structure instance with a single __fields__ entry 
(coords), which is a Structure with two fields (len and data) which are the FFI 
array's length and the void pointer to its memory:
https://github.com/urschrei/pypolyline/blob/master/pypolyline/util.py#L109-L117

I'm only half-following your explanation of how ctypeslib works, but it seems 
clear that I'm doing something wrong.

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


[issue27622] int.to_bytes(): docstring is not precise

2016-07-26 Thread Марк Коренберг

Марк Коренберг added the comment:

Ok. This is minor fix, I will not fight for my point of view :)

--
resolution:  -> rejected
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: NumPy frombuffer giving nonsense values when reading C float array on Windows

2016-07-26 Thread eryk sun
 On Tue, Jul 26, 2016 at 12:06 PM,   wrote:
> I'm using ctypes to interface with a binary which returns a void pointer 
> (ctypes c_void_p) to a nested 64-bit float array:

If this comes from a function result, are you certain that its restype
is ctypes.c_void_p? I commonly see typos here such as setting
"restypes" instead of "restype".

> [[1.0, 2.0], [3.0, 4.0], … ]
> then return the pointer so it can be freed
>
> I'm using the following code to de-reference it:
>
> # a 10-element array
> shape = (10, 2)
> array_size = np.prod(shape)
> mem_size = 8 * array_size
> array_str = ctypes.string_at(ptr, mem_size)
> # convert to NumPy array,and copy to a list
> ls = np.frombuffer(array_str, dtype="float64", 
> count=array_size).reshape(shape).tolist()
> # return pointer so it can be freed
> drop_array(ptr)
> return ls
>
> This works correctly and consistently on Linux and OSX using NumPy 1.11.0, 
> but fails on
> Windows 32 bit and 64-bit about 50% of the time, returning nonsense values. 
> Am I doing
> something wrong? Is there a better way to do this?

numpy.ctypeslib facilitates working with ctypes functions, pointers
and arrays via the factory functions as_array, as_ctypes, and
ndpointer.

ndpointer creates a c_void_p subclass that overrides the default
from_param method to allow passing arrays as arguments to ctypes
functions and also implements the _check_retval_ hook to automatically
convert a pointer result to a numpy array.

The from_param method validates an array argument to ensure it has the
proper data type, shape, and memory layout. For example:

g = ctypes.CDLL(None) # Unix only
Base = np.ctypeslib.ndpointer(dtype='B', shape=(4,))

# strchr example
g.strchr.argtypes = (Base, ctypes.c_char)
g.strchr.restype = ctypes.c_char_p

d = np.array(list(b'012\0'), dtype='B')
e = np.array(list(b'0123\0'), dtype='B') # wrong shape

>>> g.strchr(d, b'0'[0])
b'012'
>>> g.strchr(e, b'0'[0])
Traceback (most recent call last):
  File "", line 1, in 
ctypes.ArgumentError: argument 1: :
array must have shape (4,)

The _check_retval_ hook of an ndpointer calls numpy.array on the
result of a function. Its __array_interface__ property is used to
create a copy with the defined data type and shape. For example:

g.strchr.restype = Base

>>> d.ctypes._as_parameter_ # source address
c_void_p(24657952)
>>> a = g.strchr(d, b'0'[0])
>>> a
array([48, 49, 50,  0], dtype=uint8)
>>> a.ctypes._as_parameter_ # it's a copy
c_void_p(19303504)

As a copy, the array owns its data:

>>> a.flags
  C_CONTIGUOUS : True
  F_CONTIGUOUS : True
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

You can subclass the ndpointer type to have _check_retval_ instead
return a view of the result (i.e. copy=False), which may be desirable
for a large result array but probably isn't worth it for small arrays.
For example:

class Result(Base):
@classmethod
def _check_retval_(cls, result):
return np.array(result, copy=False)

g.strchr.restype = Result

>>> a = g.strchr(d, b'0'[0])
>>> a.ctypes._as_parameter_ # it's NOT a copy
c_void_p(24657952)

Because it's not a copy, the array view doesn't own the data, but note
that it's not a read-only view:

>>> a.flags
  C_CONTIGUOUS : True
  F_CONTIGUOUS : True
  OWNDATA : False
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False
-- 
https://mail.python.org/mailman/listinfo/python-list


FW: error in python IDLE

2016-07-26 Thread Nakirekanti Jahnavi


Sent from Mail for Windows 10

From: Nakirekanti Jahnavi
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27628] ipaddress incompatibility with ipaddr: __contains__ between networks

2016-07-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This issue looks as a duplicate of issue20825.

I think that if consider a network as a set of addresses, the operation 
"address in network" has the same meaning as for sets, but the operation 
"network in network" doesn't make a sense. Instead you should use the same 
operation as for testing a subset of a set: "network <= network". But this 
operation is ambiguous, because "<=" usually is ordering operation.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue27619] getopt should strip whitespace from long arguments

2016-07-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

C getopt doesn't strip trailing spaces. What you mistook for stripping trailing 
spaces is actually a feature of GNU getopt that allows you to use shortened 
variant of long option.

$ ./getopdemo "--  sp" 1 --eg 2 "--  ch" 3
option   spam   with arg 1
option eggs   with arg 2
option   cheese with arg 3

--

___
Python tracker 

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



[issue27628] ipaddress incompatibility with ipaddr: __contains__ between networks

2016-07-26 Thread pmoody

Changes by pmoody :


--
assignee: pmoody -> 

___
Python tracker 

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



[issue27628] ipaddress incompatibility with ipaddr: __contains__ between networks

2016-07-26 Thread Łukasz Langa

New submission from Łukasz Langa:

ipaddr historically let users compare if one network is within another network:
https://github.com/google/ipaddr-py/blob/master/ipaddr.py#L643

ipaddress specifically prohibits this comparison:
https://hg.python.org/cpython/file/tip/Lib/ipaddress.py#l675

What is the reason behind this change? I propose we restore this functionality 
for 3.6. It's a behavior change but arguably backwards compatible in the sense 
that between 3.3 and 3.5 this __contains__ comparison always returns False. 
It's also more on par with what ipaddr did in the past. Thoughts?

--
assignee: pmoody
components: Library (Lib)
messages: 271399
nosy: berker.peksag, lukasz.langa, ncoghlan, pmoody
priority: normal
severity: normal
stage: needs patch
status: open
title: ipaddress incompatibility with ipaddr: __contains__ between networks
type: behavior
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



making executables smaller

2016-07-26 Thread Carter Temm
Hi,
I’m writing a couple different projects at the moment, and when I compile it 
into a single executable using pyinstaller, it becomes extremely large. I’m 
guessing this is because of the modules used. Because I’m not that skilled at 
python, I put stuff like for example, import sys. I imagine the final project 
could be made smaller by specifying from something import something_else. but 
the thing is, I don’t know what smaller I could import with these set of 
modules. Is there a program that could tell me this. Sorry if this question is 
really basic, but it’d be helpful.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27546] Integrate tkinter and asyncio (and async)

2016-07-26 Thread Terry J. Reedy

Terry J. Reedy added the comment:

This afternoon, I realized that I would replace the async for loops with while 
loops with await sleep and eliminate the Timer class.  I presume the tutorial 
will have other examples of how to write an async iterator.  (If not, I would 
put is back in.)  I also notices that the updater could also be turned into a 
coroutine, but decided to leave it as it is.

--
Added file: http://bugs.python.org/file43899/loop_tk3.py

___
Python tracker 

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



[issue26226] Test failures with non-ascii character in hostname on Windows

2016-07-26 Thread STINNER Victor

STINNER Victor added the comment:

Please keep it ok. I don't say that we are going to fix all issues, but it's 
good to have an issue which collects as much as possible information about the 
bug and how we can fix it.

--

___
Python tracker 

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



[issue24773] Implement PEP 495 (Local Time Disambiguation)

2016-07-26 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

It looks like PPC64 Fedora 3.x builder [1] also has a problem with a transition 
in 2037.

[1]: http://buildbot.python.org/all/builders/PPC64%20Fedora%203.x

--

___
Python tracker 

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



[issue27619] getopt should strip whitespace from long arguments

2016-07-26 Thread Steven D'Aprano

Steven D'Aprano added the comment:

On Tue, Jul 26, 2016 at 03:27:29PM +, R. David Murray wrote:
[...]
> getopt is explicitly emulating the C getopt

There are lots of differences between the C getopt and the Python 
version, and the Python version is described as offering an API 
"designed to be familiar" to uses of the C version, not to emulate all 
the idiosyncrasies of the C version. For instance, the Python version 
raises an exception on errors, rather than returning -1; the C version 
requires argc ("argument count"), but the Python version doesn't.

But most critically, the C version DOES strip whitespace from long 
arguments. On my Centos box, it only strips *trailing* spaces, not 
leading spaces, but it does strip them. So if your argument is that we 
must do what the C getopt does, then we must likewise at least strip 
trailing spaces.

Attached is a demo, adapted from the code given by `man 3 getopt`.

[steve@ando ~]$ gcc getopdemo.c
[steve@ando ~]$ ./a.out "--  spam" 1 --eggs 2 "--  cheese" 3
option   spam   with arg 1
option eggs   with arg 2
option   cheese with arg 3

If Serhiy is going to insist that getopt.py must follow the C getopt 
precisely, then the failure to strip trailing spaces is certainly a bug.

--
Added file: http://bugs.python.org/file43898/getopdemo.c

___
Python tracker 

___   #include  /* for printf */
   #include /* for exit */
   #include 

   int
   main (int argc, char **argv) {
   int c;
   int digit_optind = 0;

   while (1) {
   int this_option_optind = optind ? optind : 1;
   int option_index = 0;
   static struct option long_options[] = {
   {"  spam  ", 1, 0, 0},
   {"eggs  ", 1, 0, 0},
   {"  cheese", 1, 0, 0},
   {0, 0, 0, 0}
   };

   c = getopt_long (argc, argv, "",
long_options, _index);
   if (c == -1)
   break;

   switch (c) {
   case 0:
   printf ("option %s", long_options[option_index].name);
   if (optarg)
   printf (" with arg %s", optarg);
   printf ("\n");
   break;

   case '?':
   break;

   default:
   printf ("?? getopt returned character code 0%o ??\n", c);
   }
   }
   exit (0);
   }
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27626] Spelling fixes

2016-07-26 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +martin.panter, r.david.murray

___
Python tracker 

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



[issue3119] pickle.py is limited by python's call stack

2016-07-26 Thread Tomas Gavenciak

Tomas Gavenciak added the comment:

The issue is still present in Python 2.7.12 and Python 3.5.2, and the 
implementation has not been changed in the master branch either.
You can test it with the attached program constructing a graph (simplified, but 
a realistic application), or with the following obviously deep construction:

import pickle, _pickle
a=()
for i in range(1000): a = (a,)
pickle.dumps(a) # or _pickle.dumps(a)

Any further comments or thoughts on the solution?

--
versions: +Python 3.6 -Python 3.1
Added file: http://bugs.python.org/file43897/graphtest.py

___
Python tracker 

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



Re: Python 3.5 glob.glob() 2nd param (*) and how to detect files/folders beginning with "."?

2016-07-26 Thread Malcolm Greene
Hi Jussi,

You answered my questions - thank you!
Malcolm


> 1. The signature for glob.glob() is "glob.glob(pathname, *,
>recursive=False)". What is the meaning of the 2nd parameter listed
>with an asterisk?

It's not a parameter. It's special syntax to indicate that the remaining
parameters are keyword-only.

>  2. Is there a technique for using glob.glob() to recognize files and
>folders that begin with a period, eg. ".profile"? The documentation
>states: "If the directory contains files starting with . they won’t
>be matched by default.". Any suggestions on what the non-default
>approach is to match these type of files?

Glob with a pattern that starts with a dot. Glob twice if you want both
kinds. Or look into that fnmatch that is referenced from glob
documentation and said not to consider leading dots special.

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


Re: NumPy frombuffer giving nonsense values when reading C float array on Windows

2016-07-26 Thread sth
On Tuesday, 26 July 2016 16:36:33 UTC+1, Christian Gollwitzer  wrote:
> Am 26.07.16 um 17:09 schrieb sth:
> > it's difficult to test a .dylib / .so using valgrind
> 
> Why is it difficult? If you have a python script such that
> 
>   python mytests.py
> 
> loads the .so and runs the tests, then
> 
>   valgrind --tool=memcheck python mytests.py
> 
> should work. This should immediately spit out an error in case that 
> numpy accesses deleted memory.
> 
> Of course debug information should be enabled when compiling the .so for 
> more useful output, and it could be helpful to have it for numpy/python, 
> too, but that's not a requirement.
> 
>   Christian

Valgrind isn't giving me any errors; it's reporting possibly-lost memory, but 
this is constant -- if I call the foreign functions once or 10^6 times, the 
number of bytes it reports possibly lost (and the number of bytes it reports 
still reachable) remain the same.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.5 glob.glob() 2nd param (*) and how to detect files/folders beginning with "."?

2016-07-26 Thread Peter Otten
Malcolm Greene wrote:

> 2. Is there a technique for using glob.glob() to recognize files and
>folders that begin with a period, eg. ".profile"? The documentation
>states: "If the directory contains files starting with . they won’t
>be matched by default.". Any suggestions on what the non-default
>approach is to match these type of files?

I don't think there is a clean way. You can monkey-patch if you don't need 
the default behaviour elsewhere in your application:


$ touch foo .bar baz
$ python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import glob
>>> glob.glob("*")
['foo', 'baz']
>>> glob._ishidden = lambda path: False
>>> glob.glob("*")
['.bar', 'foo', 'baz']


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


Re: Python 3.5 glob.glob() 2nd param (*) and how to detect files/folders beginning with "."?

2016-07-26 Thread Jussi Piitulainen
Malcolm Greene  writes:

> In reading Python 3.5.1's glob.glob documentation[1] I'm puzzled by the
> following:
>  
> 1. The signature for glob.glob() is "glob.glob(pathname, *,
>recursive=False)". What is the meaning of the 2nd parameter listed
>with an asterisk?

It's not a parameter. It's special syntax to indicate that the remaining
parameters are keyword-only.

> 2. Is there a technique for using glob.glob() to recognize files and
>folders that begin with a period, eg. ".profile"? The documentation
>states: "If the directory contains files starting with . they won’t
>be matched by default.". Any suggestions on what the non-default
>approach is to match these type of files?

Glob with a pattern that starts with a dot. Glob twice if you want both
kinds. Or look into that fnmatch that is referenced from glob
documentation and said not to consider leading dots special.

> [1] https://docs.python.org/3/library/glob.html

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


[issue24773] Implement PEP 495 (Local Time Disambiguation)

2016-07-26 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 95df96aa2f5a by Alexander Belopolsky in branch 'default':
Issue #24773: Fixed tests failures on systems with 32-bit time_t.
https://hg.python.org/cpython/rev/95df96aa2f5a

--

___
Python tracker 

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



[issue26942] android: test_ctypes crashes on armv7

2016-07-26 Thread Xavier de Gaye

Xavier de Gaye added the comment:

Nice, the patch fixes the problem when python is built with gcc :)
Running test_ctypes on the Android emulator when python is built for the arm 
architecture or the armv7 architecture gives in both cases the same successfull 
result:

Ran 456 tests in 30.424s

OK (skipped=92)
test.test_ctypes passed in 41 sec
1 test OK.
Total duration: 0:00:43

I did not try with clang, stopped by the problem in issue 27627 for armv7 and 
in issue 27606 for arm.

--

___
Python tracker 

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



Python 3.5 glob.glob() 2nd param (*) and how to detect files/folders beginning with "."?

2016-07-26 Thread Malcolm Greene
In reading Python 3.5.1's glob.glob documentation[1] I'm puzzled by the
following:
 
1. The signature for glob.glob() is "glob.glob(pathname, *,
   recursive=False)". What is the meaning of the 2nd parameter listed
   with an asterisk?
 
2. Is there a technique for using glob.glob() to recognize files and
   folders that begin with a period, eg. ".profile"? The documentation
   states: "If the directory contains files starting with . they won’t
   be matched by default.". Any suggestions on what the non-default
   approach is to match these type of files?
 
Thank you,
Malcolm
 
[1] https://docs.python.org/3/library/glob.html
 
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26226] Test failures with non-ascii character in hostname on Windows

2016-07-26 Thread Emanuel Barry

Emanuel Barry added the comment:

Since non-ASCII characters are not really supported in hostnames, I changed 
mine to a saner alternative. This issue can be closed then, since any test 
failure I encounter can no longer be because of this.

One last thing: is it safe to say "Don't use non-ASCII in hostnames" and not 
bother supporting such edge cases? Whichever way we end up going, I think this 
should be documented somewhere (although I don't really have an idea of where). 
I can submit a doc patch for this.

--

___
Python tracker 

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



[issue23085] update internal libffi copy to 3.2.1

2016-07-26 Thread Xavier de Gaye

Xavier de Gaye added the comment:

> Cross-compile CPython for ARM with clang fails in _ctypes due to 
> https://llvm.org/bugs/show_bug.cgi?id=20595. This bug is already fixed in 
> libffi.

I have entered issue 27627 for this problem.

--
nosy: +xdegaye

___
Python tracker 

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



[issue27627] clang fails to build ctypes on Android armv7

2016-07-26 Thread Xavier de Gaye

Xavier de Gaye added the comment:

See also msg 269907 and msg269908.

--

___
Python tracker 

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



[issue27627] clang fails to build ctypes on Android armv7

2016-07-26 Thread Xavier de Gaye

New submission from Xavier de Gaye:

The build is done with:
clang --sysroot=/opt/android-ndk/platforms/android-21/arch-arm -target 
armv7-none-linux-androideabi -gcc-toolchain 
/opt/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64


The error message:
clang --sysroot=/opt/android-ndk/platforms/android-21/arch-arm -target 
armv7-none-linux-androideabi -gcc-toolchain 
/opt/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 
-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -Wno-unused-result 
-Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall 
-Wstrict-prototypes -Wno-unused-value -Wno-empty-body -Qunused-arguments 
-Wno-parentheses-equality -Werror=declaration-after-statement 
-Ibuild/temp.linux-arm-3.6/libffi/include -Ibuild/temp.linux-arm-3.6/libffi 
-I./Modules/_ctypes/libffi/src -IInclude -I/sdcard/org.bitbucket.pyona/include 
-I. 
-I/home/xavier/src/android/pyona/build/python3.6-install-android-21-armv7/org.bitbucket.pyona/include
 -I/opt/android-ndk/platforms/android-21/arch-arm/usr/include -I./Include 
-I/home/xavier/src/android/pyona/build/python3.6-android-21-armv7 -c 
./Modules/_ctypes/libffi/src/arm/sysv.S -o 
build/temp.linux-arm-3.6./Modules/_ctypes/libffi/src/arm/sysv.o -Wall 
-fexceptions

./Modules/_ctypes/libffi/src/arm/sysv.S:399:2: error: invalid instruction
 stmeqia r2, {r0, r1}
 ^

--
components: Cross-Build
messages: 271385
nosy: Alex.Willmer, Chi Hsuan Yen, xdegaye
priority: normal
severity: normal
stage: needs patch
status: open
title: clang fails to build ctypes on Android armv7
type: compile error
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



[issue27612] socket.gethostbyname resolving octal IP addresses incorrectly

2016-07-26 Thread R. David Murray

R. David Murray added the comment:

koobs' results are also interesting, since they indicate that *something* 
changed on the python side that affected this for freebsd.

--

___
Python tracker 

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



[issue26865] Meta-issue: support of the android platform

2016-07-26 Thread Xavier de Gaye

Xavier de Gaye added the comment:

issue #27627: clang fails to build ctypes on Android armv7

--
dependencies: +clang fails to build ctypes on Android armv7

___
Python tracker 

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



[issue27624] unclear documentation on Queue.qsize()

2016-07-26 Thread R. David Murray

R. David Murray added the comment:

Since we're talking about multi-threaded operations, the concept of "exact size 
at an arbitrary time" isn't operationally different from "a strategy used for 
approximating".  The subsequent text clarifies what "approximately" means 
operationally.  Specifying it further would be, I think, overspecification.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue27612] socket.gethostbyname resolving octal IP addresses incorrectly

2016-07-26 Thread R. David Murray

R. David Murray added the comment:

There's also the fact that Eryk pointed out that there are different ways to 
implement this on Windows, so there might be something we want to "fix" there.  
It seems like we're not consistent in how we handle addresses in the various 
socket module functions.

--

___
Python tracker 

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



Re: Possible to capture cgitb style output in a try/except section?

2016-07-26 Thread Malcolm Greene
Hi Steven and Peter,

Steven: Interestingly (oddly???) enough, the output captured by hooking
the cgitb handler on my system appears to be shorter than the default
cgitb output. You can see this yourself via this tiny script:

import cgitb
cgitb.enable(format='text')
x = 1/0

The solution I came up with (Python 3.5.1) was to use your StringIO
technique with the Hook's 'file=' parameter.

import io

cgitb_buffer = io.StringIO()
cgitb.Hook(file=cgitb_buffer, format='text)
return cgitb_buffer.getvalue()

Peter:  Your output was helpful in seeing the difference I mentioned
above.

Thank you both for your help!

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


[issue27626] Spelling fixes

2016-07-26 Thread Emanuel Barry

New submission from Emanuel Barry:

LGTM.

--
nosy: +ebarry
stage: patch review -> commit review

___
Python tracker 

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



[issue27622] int.to_bytes(): docstring is not precise

2016-07-26 Thread R. David Murray

Changes by R. David Murray :


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

___
Python tracker 

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



[issue27622] int.to_bytes(): docstring is not precise

2016-07-26 Thread R. David Murray

R. David Murray added the comment:

Looks correct to me as well.  If you can think of a wording that would be 
clearer, Марк, that would be great, but it shouldn't make the docstring much 
wordier (we strive for conciseness in docstrings).  That last phrase can't be 
just removed without omitting an important piece of information (an 
*additional* time OverflowError can be raised).

--

___
Python tracker 

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



[issue27622] int.to_bytes(): docstring is not precise

2016-07-26 Thread R. David Murray

R. David Murray added the comment:

Looks correct to me as well.  If you can think of a wording that would be 
clearer, Марк, that would be great, but it shouldn't make the docstring much 
wordier (we strive for conciseness in docstrings).  That the last phrase can't 
be just removed without omitting an important piece of information (an 
*additional* time OverflowError can be raised).

--
nosy: +r.david.murray

___
Python tracker 

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



[issue27546] Integrate tkinter and asyncio (and async)

2016-07-26 Thread Guido van Rossum

Guido van Rossum added the comment:

Isn't this going to busy-wait, esp. with the loop.call_soon() version?

Even with loop.call_later(0.1, tk_update) you're wasting battery power
even if no network activity and no UI activity is happening. I'm not
eager to document this as the right way to do things, even if it
unblocks some apps in the short term.

A proper solution IMO should somehow merge the selectors so that a
single select() or whatever wakes up when either network I/O happens
or a UI event comes in (which could be something that Tk transparently
handles but it still needs to be given the chance, through
root.update()).

--

___
Python tracker 

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



Re: NumPy frombuffer giving nonsense values when reading C float array on Windows

2016-07-26 Thread Christian Gollwitzer

Am 26.07.16 um 17:09 schrieb sth:

it's difficult to test a .dylib / .so using valgrind


Why is it difficult? If you have a python script such that

python mytests.py

loads the .so and runs the tests, then

valgrind --tool=memcheck python mytests.py

should work. This should immediately spit out an error in case that 
numpy accesses deleted memory.


Of course debug information should be enabled when compiling the .so for 
more useful output, and it could be helpful to have it for numpy/python, 
too, but that's not a requirement.


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


Re: Python environment on mac

2016-07-26 Thread CFK
There are two variables you will need to set; PATH and PYTHONPATH. You set
your PYTHONPATH correctly, but for executables like pip, you need to set
the PATH as well. You MUST do that for each account! The reason it didn't
work as root is because once you su to root, it replaces your PYTHONPATH
and PATH (and all other environment variables) with root's. sudo shouldn't
have that problem.

BE VERY CAREFUL CHANGING THESE VARIABLES FOR ROOT! I managed to wedge a
system until I reverted my environment.

Thanks,
Cem Karan

On Jul 26, 2016 9:58 AM, "Crane Ugly"  wrote:

> Mac OS X comes with its own version of python and structure to support it.
> So far it was good enough for me. Then I started to use modules that
> distributed through MacPorts and this is where I get lost.
> I do not quite understand how Python environment is set. Or how to set it
> in a way of using, say MacPorts distribution alone.
> For example: standard location for pip utility is /usr/local/bin/pip.
> MacPorts structure has it too but as a link
> lrwxr-xr-x 1 root admin 67 May 23 22:32 /opt/local/bin/pip-2.7 ->
> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/pip
> Which means that the standard utility will be used.
> The things is that depending on a way I run pip I get different results:
> $ pip list|grep pep8
> pep8 (1.7.0)
> $ sudo pip list|grep pep8
> $
> pep8 was installed through macports.
> In second case pip is using stripped environment and pointing to standard
> Mac OS Python repository.
> But in a way to install anything with pip I have to use sudo.
> In my profile I have variable PYTHONPATH:
>
> PYTHONPATH=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
> It is pointing to macports structure. But when I use sudo (in case of
> using pip) it get stripped.
> How to setup and maintain python environment in a trustful way? So it is
> clear where all installed modules are?
>
> Leonid
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27604] More details about `-O` flag

2016-07-26 Thread R. David Murray

R. David Murray added the comment:

It might be better to reduce redundancy (ie: minimize the places that would 
need changing) by creating a cross link from the option description to the 
technical details in veryhigh.rst.  You could make the existing words 'basic 
optimizations' the link text.

Doc changes will be made to 3.5 and 3.6.  I've adjusted the versions 
accordingly.  A single patch against 3.5 will be merged into 3.6 by the 
committer.

--
versions:  -Python 3.3, Python 3.4

___
Python tracker 

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



[issue27619] getopt should strip whitespace from long arguments

2016-07-26 Thread R. David Murray

R. David Murray added the comment:

I agree with Serhiy.  Python is a programming language, not a shell.  It seems 
to me that it should not be second guessing a constant specified by the 
programmer.  If the programmer puts spaces in the specification string, Python 
should respect that.  I have no idea why one would do that, but such an option 
*can* be specified in the command line invocation, even using the shell.  And 
yes, misspecifying a constant is a common source of program bugs, but I think, 
as Serhiy pointed out, it would be worse to have some "obvious nonsense" fixed 
but not others.

Now, would we want to enhance getopt to validate the longopts in a more general 
way and raise an error?  I'm not sure it is worth the effort, especially since 
getopt is explicitly emulating the C getopt, and it does not do so.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue27461] Optimize PNGs

2016-07-26 Thread Ville Skyttä

Changes by Ville Skyttä :


Removed file: http://bugs.python.org/file43653/pngs.patch

___
Python tracker 

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



[issue27461] Optimize PNGs

2016-07-26 Thread Ville Skyttä

Ville Skyttä added the comment:

Updated patch against tip.

Before: 289426  total
After:  194638  total

--
Added file: http://bugs.python.org/file43896/pngs.patch

___
Python tracker 

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



[issue27626] Spelling fixes

2016-07-26 Thread SilentGhost

Changes by SilentGhost :


--
assignee:  -> docs@python
components: +Documentation
nosy: +SilentGhost, docs@python
stage:  -> patch review
type: enhancement -> 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



Re: NumPy frombuffer giving nonsense values when reading C float array on Windows

2016-07-26 Thread sth
On Tuesday, 26 July 2016 15:21:14 UTC+1, Peter Otten  wrote:
> 
> > I'm using ctypes to interface with a binary which returns a void pointer
> > (ctypes c_void_p) to a nested 64-bit float array:
> > [[1.0, 2.0], [3.0, 4.0], … ]
> > then return the pointer so it can be freed
> > 
> > I'm using the following code to de-reference it:
> > 
> > # a 10-element array
> > shape = (10, 2)
> > array_size = np.prod(shape)
> > mem_size = 8 * array_size
> > array_str = ctypes.string_at(ptr, mem_size)
> > # convert to NumPy array,and copy to a list
> > ls = np.frombuffer(array_str, dtype="float64",
> > count=array_size).reshape(shape).tolist()
> > # return pointer so it can be freed
> > drop_array(ptr)
> > return ls
> > 
> > This works correctly and consistently on Linux and OSX using NumPy 1.11.0,
> > but fails on Windows 32 bit and 64-bit about 50% of the time, returning
> > nonsense values. Am I doing something wrong? Is there a better way to do
> > this?
> 
> I'd verify that the underlying memory has not been freed by the "binary" 
> when you are doing the ctypes/numpy processing. You might get the correct 
> values only when you are "lucky" and the memory has not yet been reused for 
> something else, and you are "lucky" on Linux/OSX more often than on 
> Windows...

I'm pretty sure the binary isn't freeing the memory prematurely; I wrote it and 
I'm testing it, and the Python tests run 10^6 loops of:
array retrieval -> numpy array allocation + copying to list -> passing original 
array back to be freed.

I'm not completely ruling it out (it's difficult to test a .dylib / .so using 
valgrind), but getting the ctypes / numpy side right would at least allow me to 
eliminate one potential source of problems.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27626] Spelling fixes

2016-07-26 Thread Ville Skyttä

Changes by Ville Skyttä :


--
files: spelling.patch
keywords: patch
nosy: scop
priority: normal
severity: normal
status: open
title: Spelling fixes
type: enhancement
versions: Python 3.6
Added file: http://bugs.python.org/file43895/spelling.patch

___
Python tracker 

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



Re: reshape with xyz ordering

2016-07-26 Thread Peter Otten
Heli wrote:

> I sort a file with 4 columns (x,y,z, somevalue) and I sort it using
> numpy.lexsort.
> 
> ind=np.lexsort((val,z,y,x))
> 
> myval=val[ind]
> 
> myval is a 1d numpy array sorted by x,then y, then z and finally val.
> 
> how can I reshape correctly myval so that I get a 3d numpy array
> maintaining the xyz ordering of the data?
> 
> 
> my val looks like the following:
> 
> x,y,z, val
> 0,0,0,val1
> 0,0,1,val2
> 0,0,2,val3
> ...
> 
> Thanks a lot for your help,

I'm not sure I understand the question. Does

shape = [max(t) + 1 for t in [x, y, z]]
cube = myval.reshape(shape)

give what you want?

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


[issue27614] Race in test_docxmlrpc.py

2016-07-26 Thread R. David Murray

R. David Murray added the comment:

OK, that's a good point.  So I don't know the answer to your question.  In some 
cases it may be mostly that the tests are old and written when the tooling was 
not as good.

--

___
Python tracker 

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



[issue27625] "make install" fails when no zlib support available

2016-07-26 Thread Ned Deily

Ned Deily added the comment:

Building python without zlib is support is pretty unusual today and certainly 
not recommended. I agree that it is not worth adding more complexity to the 
Python configure script or Makefile to cover this edge case dependency in pip.  
There are other potential ensurepip failures, for instance if ssl support is 
missing.

--
nosy: +ned.deily
resolution: not a bug -> wont fix

___
Python tracker 

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



[issue27625] "make install" fails when no zlib support available

2016-07-26 Thread SilentGhost

SilentGhost added the comment:

Well, there isn't anything to build in case of pip. I presume that was the 
decision made during the PEP implementation, so I'm adding the two core 
developers responsible.

--
nosy: +dstufft, ncoghlan

___
Python tracker 

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



Re: Why not allow empty code blocks?

2016-07-26 Thread Antoon Pardon
Op 24-07-16 om 21:00 schreef Chris Angelico:
> A skilled craftsman in any field will choose to use quality tools.
> They save time, and time is money.[/quote]

Sure, but sometimes there is a flaw somewhere. A flaw whose
consequences can be reduced by using an extra tool. If that
is the case the real solution seems to get rid of the flaw
and not to use the tool.

So if someone argues there is a flaw somewhere, pointing to
tools doesn't contradict that.

-- 
Antoon.

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


  1   2   >