[issue31298] Error when calling numpy.astype

2017-10-31 Thread Berker Peksag

Berker Peksag  added the comment:

Chris is right. Please report this to numpy developers. We can always reopen 
this issue if they decide that this is an issue in Python. Thank you.

By the way, I cannot reproduce the crash with numpy 1.13.3.

--
nosy: +berker.peksag
resolution:  -> third party
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue30824] Add mimetype for extension .json

2017-10-31 Thread Berker Peksag

Berker Peksag  added the comment:

3.5 is now in security-fix-only mode so I'm closing this one as 'fixed'. Thank 
you, all.

--
nosy: +berker.peksag
resolution:  -> fixed
stage: backport needed -> resolved
status: open -> closed
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



[issue31916] ensurepip not honoring value of $(DESTDIR) - pip not installed

2017-10-31 Thread Chi Hsuan Yen

Chi Hsuan Yen  added the comment:

This is a pip bug https://github.com/pypa/pip/issues/3063

--
nosy: +Chi Hsuan Yen

___
Python tracker 

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



[issue31908] trace module cli does not write cover files

2017-10-31 Thread Raymond Hettinger

Change by Raymond Hettinger :


--
nosy: +belopolsky

___
Python tracker 

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



Re: matplot plot hangs

2017-10-31 Thread Andrew Z
Stefan,
I intentionally tried to use the qt backend that i do not have. I wanted to
check i the switch was working (or not).

All i want at this point is to use (seemed to be default) tkagg.

On Oct 31, 2017 20:15, "Stefan Ram"  wrote:

> Andrew Z  writes:
> >ImportError: *No module named 'PyQt4'*
>
>   Matplotlib requires a large number of dependencies,
>   like »NumPy«, »dateutil«, »libpng«, or »pytz«.
>
>   There are also some capabilities provided by optional
>   backends which have their own dependencies.
>
>   If one would like to use the »Qt4Agg« backend, one would
>   also need to have »PyQt4« installed.
>
>   Some Python distributions might already contain many
>   dependencies.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue31454] Include "import as" in tutorial

2017-10-31 Thread Berker Peksag

Berker Peksag  added the comment:

I just reviewed Mario's pull request. Should we mention the "from fibo import 
fib as fibonacci" syntax too?

--
nosy: +berker.peksag

___
Python tracker 

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



[issue31915] (list).insert() not working

2017-10-31 Thread Steven D'Aprano

Change by Steven D'Aprano :


--
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue31915] (list).insert() not working

2017-10-31 Thread Steven D'Aprano

Steven D'Aprano  added the comment:

Thank you for taking the time to report what you thought was a bug, but your 
example is way too complicated for a bug report. We shouldn't have to study 
your entire program to understand what the problem is.

I can see at least one bug in your code:

tbles = tables2.copy

sets the variable "tbles" as an alias to the "tables2.copy" method, and of 
course methods don't have an insert method themselves. So I'm closing this as 
"Not a bug". If you disagree, feel free to re-open the ticket with more 
information.

In future, please always report the SIMPLEST example of the bug that you can 
write. Tell us what you expected to happen, and COPY AND PASTE (no screenshots) 
the error message that you get, or other unexpected result.

You might also find it useful to read this page:

http://sscce.org/

It is written in terms of Java, but the principles apply equally to every 
programming language.

Thank you.

--
nosy: +steven.daprano
resolution:  -> not a bug

___
Python tracker 

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



[issue18534] State clearly that open() 'file' param is "name" attr of the result

2017-10-31 Thread Guido van Rossum

Guido van Rossum  added the comment:

Agreed it's too subtle to change the behavior.

> We may also want to explicitly point out that using os.fsdecode(name) before 
> passing it to open() will ensure that the name attribute is set to a string 
> rather than a bytes object.

Not sure. Are there cases where os.fsdecode() fails even if the binary syscall 
would succeed? (The docs claim that on Windows it uses 'strict'.)

If it doesn't, maybe we can add a new attribute that gives the name as Text? It 
could be '' if name is an int.

--
nosy: +gvanrossum
status: pending -> open

___
Python tracker 

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



[issue31910] test_socket.test_create_connection() failed with EADDRNOTAVAIL (err 99)

2017-10-31 Thread Roundup Robot

Change by Roundup Robot :


--
pull_requests: +4178

___
Python tracker 

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



[issue31910] test_socket.test_create_connection() failed with EADDRNOTAVAIL (err 99)

2017-10-31 Thread Roundup Robot

Change by Roundup Robot :


--
pull_requests: +4177

___
Python tracker 

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



[issue31910] test_socket.test_create_connection() failed with EADDRNOTAVAIL (err 99)

2017-10-31 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset 280c22a82a6756e9caffef031c564fd98f1b50e7 by Victor Stinner in 
branch 'master':
Fix test_socket.test_create_connection() (#4206)
https://github.com/python/cpython/commit/280c22a82a6756e9caffef031c564fd98f1b50e7


--

___
Python tracker 

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



Re: Invoking return through a function?

2017-10-31 Thread Alberto Riva

On 10/31/2017 11:01 AM, Rhodri James wrote:

On 31/10/17 02:06, Alberto Riva wrote:

Steve D'Aprano gave you a pretty full answer, I just wanted to add:


 The kind of
statement I was trying to add would at least have made that explicit: 
return-if-so-and-so-happens.


That's only obvious in the function that's doing the returning.  The 
function that's doing the calling that gets its expectation of flow 
control broken has no clue, and that's my problem.


Sorry, I wasn't clear: I meant that the function that's doing the 
returning should be called "return-if-so-and-so-happens", literally ;) 
So when it appears in the body of another function, it's clear that it 
*may* invoke a return. Not saying it's a good idea, but just that when 
you read something like that you can expect evaluation flow to be disrupted.


Again: I'm not saying it's a good idea, please don't take this as a 
serious feature request :)


Alberto



--
E-mail address:
((lambda (s a b c) (map 'string #'code-char (mapcar (lambda (v)
(setq s (+ a (mod (+ s v (- a)) b (map 'list (lambda (v)
(- (char-code v) c)) " 1`-THUZ&+Wh1" 97 46 73 32)
--
https://mail.python.org/mailman/listinfo/python-list


[issue31917] Add time.CLOCK_PROF constant

2017-10-31 Thread STINNER Victor

Change by STINNER Victor :


--
keywords: +patch
pull_requests: +4176
stage:  -> patch review

___
Python tracker 

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



[issue31917] Add time.CLOCK_PROF constant

2017-10-31 Thread STINNER Victor

New submission from STINNER Victor :

The CLOCK_PROF clock is used internally by time.process_time(). It may be 
interesting to expose this constant if available.

--
components: FreeBSD, Library (Lib)
messages: 305352
nosy: haypo, koobs
priority: normal
severity: normal
status: open
title: Add time.CLOCK_PROF constant
type: enhancement
versions: Python 3.7

___
Python tracker 

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



[issue31916] ensurepip not honoring value of $(DESTDIR) - pip not installed

2017-10-31 Thread multimiler

New submission from multimiler :

I am building python from source for installation at /opt/python-3.6.3.  The 
result of the build will be installed in /somewhere/deb-pkg-build-dir.  I 
configure, build, and install, the package as follows:

./configure --prefix=/opt/python-$VER --enable-optimizations 
--with-ensurepip=install
make
make install DESTDIR=/somewhere/deb-pkg-build-dir

At the very end of the build log I find:

Requirement already satisfied: setuptools in 
/opt/python-3.6.3/lib/python3.6/site-packages

As a result PIP is not installed.  This is an error.  The pip installation 
process should be looking in $(DESTDIR)/opt/python-3.6.3.  Instead it is 
looking at /opt/python-3.6.3/... which is the python installation on the 
current build host -- NOT INSTALLED BY THIS BUILD.

In the top-level Makefile.pre I find the following that runs ensurepip to 
install pip:

install:  commoninstall bininstall maninstall
if test "x$(ENSUREPIP)" != "xno"  ; then \
case $(ENSUREPIP) in \
upgrade) ensurepip="--upgrade" ;; \
install|*) ensurepip="" ;; \
esac; \
$(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \
$$ensurepip --root=$(DESTDIR)/ ; \
fi

As you can see $(DESTDIR) is passed into ensurepip, but it is never used when 
checking for pip existence.

--
components: Installation
messages: 305351
nosy: multimiler
priority: normal
severity: normal
status: open
title: ensurepip not honoring value of $(DESTDIR) - pip not installed
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



[issue31915] (list).insert() not working

2017-10-31 Thread Michael Selik

New submission from Michael Selik :

What behavior did you expect from your code?
What behavior did you get instead?

It looks like you're not calling the list copy method correctly. Try writing 
"tables2.copy()" instead of "tables2.copy". It also looks like you have other 
bugs in your code.

This forum is for reporting bugs in the Python language. If you'd like help 
with bugs in your own code, try asking on StackOverflow 
(https://stackoverflow.com/) or on the Python Help mailing list 
(https://mail.python.org/mailman/listinfo/python-help).

--
nosy: +Michael Selik

___
Python tracker 

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



[issue31626] Writing in freed memory in _PyMem_DebugRawRealloc() after shrinking a memory block

2017-10-31 Thread STINNER Victor

STINNER Victor  added the comment:

While the commit b484d5606ca76f9bbd0f5de7a6ef753400213e94 fixes a crash on 
OpenBSD and makes the code "correct" on any platforms, I still see it as a 
feature regression. Detecting buffer overflow and using freed memory are 
feature of debug hooks.

https://docs.python.org/dev/c-api/memory.html#c.PyMem_SetupDebugHooks

So yes, debug-realloc.diff is interesting.

--

___
Python tracker 

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



[issue31890] Please define the flag METH_STACKLESS for Stackless Python

2017-10-31 Thread STINNER Victor

STINNER Victor  added the comment:

Hi Anselm,

What is the status of Stackless Python? I didn't hear about Stackless for 5 
years. Is the project still alive?

I see some activity on https://bitbucket.org/stackless-dev/stackless/wiki/Home 
and http://www.stackless.com/pipermail/stackless/

--

___
Python tracker 

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



[issue31908] trace module cli does not write cover files

2017-10-31 Thread Michael Selik

Michael Selik  added the comment:

Ok, pull request submitted:
https://github.com/python/cpython/pull/4205

--

___
Python tracker 

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



[issue31910] test_socket.test_create_connection() failed with EADDRNOTAVAIL (err 99)

2017-10-31 Thread STINNER Victor

STINNER Victor  added the comment:

> Or maybe just repeat the test if EADDRNOTAVAIL is raised?

I don't think that it's worth it.

--

___
Python tracker 

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



[issue31910] test_socket.test_create_connection() failed with EADDRNOTAVAIL (err 99)

2017-10-31 Thread STINNER Victor

Change by STINNER Victor :


--
keywords: +patch
pull_requests: +4175
stage:  -> patch review

___
Python tracker 

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



[issue31908] trace module cli does not write cover files

2017-10-31 Thread Michael Selik

Change by Michael Selik :


--
keywords: +patch
pull_requests: +4174
stage:  -> patch review

___
Python tracker 

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



[issue31915] (list).insert() not working

2017-10-31 Thread Chance Parsons

Change by Chance Parsons :


--
files: Times Tables.py
nosy: Chance Parsons
priority: normal
severity: normal
status: open
title: (list).insert() not working
type: behavior
versions: Python 3.6
Added file: https://bugs.python.org/file47250/Times Tables.py

___
Python tracker 

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



[issue18835] Add PyMem_AlignedAlloc()

2017-10-31 Thread STINNER Victor

STINNER Victor  added the comment:

msg196194: Antoine Pitrou: "Note that the current small object allocator, if 
not disabled, *should* already return you aligned memory, by construction (each 
allocation size has dedicated pools from which memory blocks are carved)."

In my current implementation of _PyObject_AlignedAlloc(), I only call 
pymalloc_alloc() for alignment <= pymalloc ALIGNMENT. Maybe we can do better?

--

___
Python tracker 

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



[issue18835] Add aligned memory variants to the suite of PyMem functions/macros

2017-10-31 Thread STINNER Victor

STINNER Victor  added the comment:

I merged my PR 4199 (Document PyObject_Malloc()) and PR 4200 (Cleanup pymalloc) 
to prepare PR 4089.

PR 4089 should now be completed and well tested.

The real question is now if we need PyMem_AlignedAlloc()?

Stefan Krah and Nathaniel Smith are interested by aligned memory allocations, 
but both wrote that they don't plan to use PyMem_AlignedAlloc() if I understood 
correctly. What's the point of adding PyMem_AlignedAlloc() in that case?

--

___
Python tracker 

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



[issue18835] Add PyMem_AlignedAlloc()

2017-10-31 Thread STINNER Victor

Change by STINNER Victor :


--
title: Add aligned memory variants to the suite of PyMem functions/macros -> 
Add PyMem_AlignedAlloc()

___
Python tracker 

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



[issue31908] trace module cli does not write cover files

2017-10-31 Thread Michael Selik

Michael Selik  added the comment:

While writing a patch for this, I noticed the ``lnotab`` parameter seems nearly 
unused. It's a dict, but is only used for its keys.

https://github.com/python/cpython/blob/master/Lib/trace.py#L333

Further, the choice to count unreached lines only when ``show_missing`` was set 
seems inconsistent.

https://github.com/python/cpython/blob/master/Lib/trace.py#L335

https://github.com/python/cpython/blob/master/Lib/trace.py#L280

--

___
Python tracker 

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



Re: The syntax of replacement fields in format strings

2017-10-31 Thread Rick Johnson
On Tuesday, October 31, 2017 at 1:35:33 PM UTC-5, John Smith wrote:
> If we keep the current implementation as is, perhaps the
> documentation should at least be altered ?

You should supply a concise code example that showcases why
_you_ feel the docs are not satisfactory. It would help.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue14574] SocketServer doesn't handle client disconnects properly

2017-10-31 Thread Matej Cepl

Matej Cepl  added the comment:

The last patch (clear_buffer_on_error.patch) has still not been applied 
(looking at 2.7 and master branches).

--
nosy: +mcepl

___
Python tracker 

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



matplot plot hangs

2017-10-31 Thread Andrew Z
hello,
 learning python's plotting by using matplotlib with python35 on fedora 24
x86.

Installed matplotlib into user's directory.
tk, seemed to work -
http://www.tkdocs.com/tutorial/install.html#installlinux - the window shows
up just fine.
but when trying to run the simple plot (
https://matplotlib.org/examples/pylab_examples/simple_plot.html) the script
is hanging on;

plt.plot(t, s)

attempts to
matplotlib.interactive(True) didn't bring anything,

I do get an error while trying to switch the backend ( which is fine with me) :
plt.switch_backend('Qt4Agg')
>>> plt.switch_backend('Qt4Agg')
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/az/.local/lib/python3.5/site-packages/matplotlib/pyplot.py",
line 231, in switch_backend
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File 
"/home/az/.local/lib/python3.5/site-packages/matplotlib/backends/__init__.py",
line 60, in pylab_setup
[backend_name], 0)
  File 
"/home/az/.local/lib/python3.5/site-packages/matplotlib/backends/backend_qt4agg.py",
line 10, in 
from .backend_qt4 import (
  File 
"/home/az/.local/lib/python3.5/site-packages/matplotlib/backends/backend_qt4.py",
line 18, in 
from .qt_compat import QtCore, QtWidgets, _getSaveFileName, __version__
  File 
"/home/az/.local/lib/python3.5/site-packages/matplotlib/backends/qt_compat.py",
line 150, in 
from PyQt4 import QtCore, QtGui
ImportError: *No module named 'PyQt4'*
>>> plt.switch_backend('Agg')
>>> plt.switch_backend('TkAgg')


summary:

 why i can't use tkAgg, and how can i troubleshoot the issue?

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


[issue23551] IDLE to provide menu link to PIP gui.

2017-10-31 Thread Ivan Levkivskyi

Change by Ivan Levkivskyi :


--
nosy: +levkivskyi

___
Python tracker 

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



[issue27051] Create PIP gui

2017-10-31 Thread Ivan Levkivskyi

Change by Ivan Levkivskyi :


--
nosy: +levkivskyi

___
Python tracker 

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



[issue31908] trace module cli does not write cover files

2017-10-31 Thread Michael Selik

Michael Selik  added the comment:

The problem appears to be a mistake in commit 
f026dae130bf6f9015c4b212f16852ba4a3f3dec

https://github.com/python/cpython/commit/f026dae130bf6f9015c4b212f16852ba4a3f3dec

This made the writing of cover files conditional on ``show_missing`` which is 
the option to mark lines which weren't executed with several angle brackets 
">".

https://github.com/python/cpython/blob/3.5/Lib/trace.py#L326

mike on mac in ~/
$ python -m trace --count foo.py
hello

mike on mac in ~/
$ ls *.cover
ls: *.cover: No such file or directory

mike on mac in ~/
$ python -m trace --count -m foo.py
hello

mike on mac in ~/
$ ls *.cover
-rw-r--r--  1 mike  staff22B Oct 31 15:40 foo.cover

--

___
Python tracker 

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



Re: Report on non-breaking spaces in posts

2017-10-31 Thread Ben Bacarisse
Rhodri James  writes:

> On 31/10/17 17:23, Stefan Ram wrote:
>> Ned Batchelder  writes:
>>>     def wrapped_join(values, sep):
>>
>>Ok, here's a report on me seing non-breaking spaces in
>>posts in this NG. I have written this report so that you
>>can see that it's not my newsreader that is converting
>>something, because there is no newsreader involved.
>>
>>Here are some relevant lines from Ned's above post:
>>
>> |From: Ned Batchelder 
>> |Newsgroups: comp.lang.python
>> |Subject: Re: How to join elements at the beginning and end of the list
>> |Message-ID: 
>
> Hm.  That suggests the mail-to-news gateway has a hand in things.
>
>> |Content-Type: text/plain; charset=utf-8; format=flowed
>> |Content-Transfer-Encoding: 8bit
>> |     def wrapped_join(values, sep):
>
> [snippety snip]
>
>> |od -c tmp.txt
>> |...
>> |0012620   s   u   l   a   t   e   i   t   :  \n  \n   Â       Â
>> |0012640       Â       d   e   f   w   r   a   p   p   e   d   _
>> |...
>> |
>> |od -x tmp.txt
>> |...
>> |0012620 7573 616c 6574 6920 3a74 0a0a c220 c2a0
>> |0012640 c2a0 20a0 6564 2066 7277 7061 6570 5f64
>> |...
>>
>>And you can see, there are two octet pairs »c220« and
>>»c2a0« in the post (directly preceding »def wrapped«).
>>(Compare with the Content-Type and Content-Transfer-Encoding
>>given above.) (Read table with a monospaced font:)
>>
>>  corresponding
>> Codepoint  UTF-8ISO-8859-1  interpretation
>>
>> U+0020?c2 2020? SPACE?
>> U+00A0 c2 a0a0  NON-BREAKING SPACE
>>
>>This makes it clear that there really are codepoints
>>U+00A0 in what I get from the server, i.e., non-breaking
>>spaces directly in front of »def wrapped«.
>
> And?  Why does that bother you?  A non-breaking space is a perfectly
> valid thing to put into a UTF-8 encoded message.

But it's an odd thing to put into Python code (at least there).  If the
Usenet client is doing it that's surely bad as the code won't run
without editing.

> The 0xc2 0x20 byte
> pair that you misidentify as a space is another matter entirely.
>
> 0xc2 0x20 is not a space in UTF-8.  It is an invalid code sequence.  I
> don't know how or where it was generated, but it really shouldn't have
> been.

It wasn't there.  It was down to a misreading of the byte-order in the
hex dump.


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


[issue23551] IDLE to provide menu link to PIP gui.

2017-10-31 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

For this idea to be revived, someone should write a PEP and open a new issue.

--

___
Python tracker 

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



[issue18835] Add aligned memory variants to the suite of PyMem functions/macros

2017-10-31 Thread Stefan Krah

Stefan Krah  added the comment:

> For large allocations, you'll probably be better off implementing your own 
> aligned allocator on top of calloc than implementing your own calloc on top 
> of an aligned allocator. (It's O(1) overhead versus O(n).) And once you're 
> doing that you might want to use the same code for regular allocations too, 
> so that you don't need to keep track of whether each memory block used 
> aligned_calloc or aligned_malloc and can treat them the same... Depends on 
> your exact circumstances.

Yes, but if the whole array is initialized with actual values, then
the memset() overhead is not very large (something like 16% here).

If uninitialized (or very sparse), the overhead is of course gigantic.

What is more, in some crude tests the posix_memalign() performance isn't
that great compared to malloc()/calloc().

C11 aligned_alloc() is also quite a bit faster than posix_memalign() here.

I think you're right that a hand-rolled solution on top of calloc() is
best for my use case.

--

___
Python tracker 

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



[issue31914] Document Pool.(star)map return type

2017-10-31 Thread Дилян Палаузов

Дилян Палаузов  added the comment:

Pool.starmap is not like map from the standard library, as the hyperlinking on 
the word map() suggests, but like Pool.map().  The latter talks about the 
chunksize parameter, but the former and Pool.starmap don't.

--

___
Python tracker 

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



[issue31914] Document Pool.(star)map return type

2017-10-31 Thread Дилян Палаузов

New submission from Дилян Палаузов :

https://docs.python.org/3/library/multiprocessing.html#multiprocessing.pool.Pool.starmap
 says:

starmap(func, iterable[, chunksize])
Like map() except that the elements of the iterable are expected to be 
iterables that are unpacked as arguments.

Hence an iterable of [(1,2), (3, 4)] results in [func(1,2), func(3,4)].



If it was like map() then it would have returned an iterator.  Please clarify, 
that Pool.map and Pool.starmap return list.

--
assignee: docs@python
components: Documentation
messages: 305337
nosy: dilyan.palauzov, docs@python
priority: normal
severity: normal
status: open
title: Document Pool.(star)map return type
type: enhancement
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



[issue31891] Make curses compiling on NetBSD 7.1 and tests passing

2017-10-31 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue31844] HTMLParser: undocumented not implemented method

2017-10-31 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
components: +Library (Lib)
nosy: +ezio.melotti
type:  -> behavior

___
Python tracker 

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



[issue31910] test_socket.test_create_connection() failed with EADDRNOTAVAIL (err 99)

2017-10-31 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

I'm not a networking but it seems reasonable. If I understand correctly, 
EADDRNOTAVAIL can be raised on the Travis CI when a large number of network 
connections are created simultaneously by other CI tests.

Or maybe just repeat the test if EADDRNOTAVAIL is raised?

--

___
Python tracker 

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



[issue31630] math.tan has poor accuracy near pi/2 on OpenBSD and NetBSD

2017-10-31 Thread Stefan Krah

Stefan Krah  added the comment:

On Tue, Oct 31, 2017 at 07:32:00PM +, Serhiy Storchaka wrote:
> >>From 4 considered results the tests are failed on gcc 4.2.1, 4.7.2, 4.8.5, 
> >>but are passes on gcc 7.2.0. I suppose this is gcc or libc bug fixed in 
> >>recent versions.

4.7.3 passes here with -m32.

--

___
Python tracker 

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



[issue31626] Writing in freed memory in _PyMem_DebugRawRealloc() after shrinking a memory block

2017-10-31 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
priority: critical -> normal

___
Python tracker 

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



[issue31626] Writing in freed memory in _PyMem_DebugRawRealloc() after shrinking a memory block

2017-10-31 Thread Larry Hastings

Larry Hastings  added the comment:

> Most, if not all, calls to _PyMem_DebugRawRealloc() are protected by
> the GIL. If there is a single thread using the memory block,
> I think that it's perfectly fine to write after it's deallocated.

I don't quite follow where the write-after-free is happening, but: C's free() 
function is *not* protected by the GIL.  So if you're running in a 
multithreaded program where other threads aren't blocked by the GIL, one of 
these other threads could very easily allocate this freshly-freed memory.  And 
if you wrote to it after the memory was allocated to this other thread, 
congrats, your program is no longer correct.

--

___
Python tracker 

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



[issue31630] math.tan has poor accuracy near pi/2 on OpenBSD and NetBSD

2017-10-31 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

>From 4 considered results the tests are failed on gcc 4.2.1, 4.7.2, 4.8.5, but 
>are passes on gcc 7.2.0. I suppose this is gcc or libc bug fixed in recent 
>versions.

--

___
Python tracker 

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



[issue31626] Writing in freed memory in _PyMem_DebugRawRealloc() after shrinking a memory block

2017-10-31 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

I have removed the incorrect code in master and 3.6, this unblocks testing 
debug build on OpenBSD. I don't think it is worth to backport this change to 
3.5 and 3.4, since the bug affects only debug build.

Here is a patch which perhaps is an alternative to PR 4119, but without 
disturbing the heap allocator. It erases just few bytes at the begin and at the 
end of the allocated block (including the header and the trailer), and saves 
erased bytes in small local buffer. It does this even if the block is not 
reallocated in-place. Hence calling free() on reallocated block will be 
detected. Reading from the reallocated block will get erased bytes at the start 
and the end, this is likely will cause to loud failure too. I have tested in on 
OpenBSD.

But I'm not sure that it is worth to apply this patch. Left it on to you Victor.

--
versions:  -Python 3.4, Python 3.5
Added file: https://bugs.python.org/file47249/debug-realloc.diff

___
Python tracker 

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



[issue18835] Add aligned memory variants to the suite of PyMem functions/macros

2017-10-31 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset 9ed83c40855b57c10988f76770a4eb825e034cd8 by Victor Stinner in 
branch 'master':
bpo-18835: Cleanup pymalloc (#4200)
https://github.com/python/cpython/commit/9ed83c40855b57c10988f76770a4eb825e034cd8


--

___
Python tracker 

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



[issue31630] math.tan has poor accuracy near pi/2 on OpenBSD and NetBSD

2017-10-31 Thread Stefan Krah

Stefan Krah  added the comment:

So the big mystery is still:

   https://mail.python.org/pipermail/python-dev/2017-October/149880.html


Could be a Linux router with some alternative libc ...

--

___
Python tracker 

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



[issue31893] Issues with kqueue

2017-10-31 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Tests on all buildbots are passed.

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

___
Python tracker 

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



[issue31630] math.tan has poor accuracy near pi/2 on OpenBSD and NetBSD

2017-10-31 Thread Mark Dickinson

Mark Dickinson  added the comment:

> Seems the first result is calculated at compile time

Makes sense. Last time I looked, gcc uses MPFR for the compile-time calls, so 
I'd expect those to be correctly rounded.

--

___
Python tracker 

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



Re: The syntax of replacement fields in format strings

2017-10-31 Thread John Smith
If we keep the current implementation as is, perhaps the documentation
should at least be altered ?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue18835] Add aligned memory variants to the suite of PyMem functions/macros

2017-10-31 Thread Nathaniel Smith

Nathaniel Smith  added the comment:

> But since no fast (kernel-zeroed) aligned_calloc() exists, I must use 
> memset() anyway. 

For large allocations, you'll probably be better off implementing your own 
aligned allocator on top of calloc than implementing your own calloc on top of 
an aligned allocator. (It's O(1) overhead versus O(n).) And once you're doing 
that you might want to use the same code for regular allocations too, so that 
you don't need to keep track of whether each memory block used aligned_calloc 
or aligned_malloc and can treat them the same... Depends on your exact 
circumstances.

--

___
Python tracker 

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



Re: Report on non-breaking spaces in posts

2017-10-31 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes:

> r...@zedat.fu-berlin.de (Stefan Ram) writes:
>>|od -c tmp.txt
>>|...
>>|0012620   s   u   l   a   t   e   i   t   :  \n  \n   Â       Â
>>|0012640       Â       d   e   f   w   r   a   p   p   e   d   _
>>|...
>>|
>>|od -x tmp.txt
>>|...
>>|0012620 7573 616c 6574 6920 3a74 0a0a c220 c2a0
>>|0012640 c2a0 20a0 6564 2066 7277 7061 6570 5f64
>>|...
>
>   PS:
>
>   Oh, the byte order of »od -x« did not match my expectations!

You might like

  http://www.bsb.me.uk/software/utf-8-dump/

I use it all the time (but then I would!).


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


[issue31893] Issues with kqueue

2017-10-31 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset 84e252b79eed94bc9e9175f82191322c89e489ad by Serhiy Storchaka 
(Miss Islington (bot)) in branch '3.6':
bpo-31893: Fix errors in b9052a0f91d2e83bbc27267247a5920c82b242a3. (GH-4196) 
(#4201)
https://github.com/python/cpython/commit/84e252b79eed94bc9e9175f82191322c89e489ad


--

___
Python tracker 

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



[issue31893] Issues with kqueue

2017-10-31 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset e7531e54bf195b8d3ed35b4138901c82f7ed794c by Serhiy Storchaka 
(Miss Islington (bot)) in branch '2.7':
bpo-31893: Fix errors in b9052a0f91d2e83bbc27267247a5920c82b242a3. (GH-4196) 
(#4202)
https://github.com/python/cpython/commit/e7531e54bf195b8d3ed35b4138901c82f7ed794c


--

___
Python tracker 

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



[issue31912] PyMem_Malloc() should guarantee alignof(max_align_t)

2017-10-31 Thread Stefan Krah

Stefan Krah  added the comment:

> Do you mean the C++ std::max_align_t? Does C99 have something like that?
> 
> The Linux malloc() manual page says:
> 
> "The malloc() and calloc() functions return a pointer to  the  allocated 
> memory,  which  is  suitably  aligned for any built-in type."

C11 has max_align_t, but also for C99 "any builtin type" means 16 byte alignment
for long double on x64, so malloc() and calloc() are required to align 16 bytes
with -std=c99 (and earlier).

max_align_t is just a shorthand to express the concept.

--

___
Python tracker 

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



[issue31913] forkserver could warn if several threads are running

2017-10-31 Thread Antoine Pitrou

New submission from Antoine Pitrou :

I'm not sure this is worth handling, but I had an interaction with a user who 
had weird deadlock problems in a glibc function (getaddrinfo) in worker 
processes launched with the forkserver method.

The explanation turned out to be that a sitecustomize.py did some stuff that 
eventually launched a helper thread, and that made the forkserver process's 
forking fundamentally unsafe (fork() is guaranteed to be safe if there's only 
one thread running in the parent process).

It would be easy to check that threading.enumerate() returns only one thread, 
and otherwise warn the user about it.  Note this only handles Python threads 
and not C threads invisible to Python... (a more complete solution would 
involve psutil :-)).

--
components: Library (Lib)
messages: 305323
nosy: davin, gregory.p.smith, pitrou
priority: low
severity: normal
status: open
title: forkserver could warn if several threads are running
type: enhancement
versions: Python 3.7

___
Python tracker 

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



[issue31912] PyMem_Malloc() should guarantee alignof(max_align_t)

2017-10-31 Thread STINNER Victor

STINNER Victor  added the comment:

> I think PyMem_Malloc() should guarantee alignof(max_align_t).

Do you mean the C++ std::max_align_t? Does C99 have something like that?

The Linux malloc() manual page says:

"The malloc() and calloc() functions return a pointer to  the  allocated 
memory,  which  is  suitably  aligned for any built-in type."

But I don't know the list of C built-in types.

--

___
Python tracker 

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



[issue31909] Missing definition of HAVE_SYSCALL_GETRANDOM

2017-10-31 Thread Ilya Kulakov

Ilya Kulakov  added the comment:

Not a bug in Python.

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

___
Python tracker 

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



Re: Report on non-breaking spaces in posts

2017-10-31 Thread Rhodri James

On 31/10/17 17:23, Stefan Ram wrote:

Ned Batchelder  writes:

    def wrapped_join(values, sep):


   Ok, here's a report on me seing non-breaking spaces in
   posts in this NG. I have written this report so that you
   can see that it's not my newsreader that is converting
   something, because there is no newsreader involved.

   Here are some relevant lines from Ned's above post:

|From: Ned Batchelder 
|Newsgroups: comp.lang.python
|Subject: Re: How to join elements at the beginning and end of the list
|Message-ID: 


Hm.  That suggests the mail-to-news gateway has a hand in things.


|Content-Type: text/plain; charset=utf-8; format=flowed
|Content-Transfer-Encoding: 8bit
|     def wrapped_join(values, sep):


[snippety snip]


|od -c tmp.txt
|...
|0012620   s   u   l   a   t   e   i   t   :  \n  \n   Â       Â
|0012640       Â       d   e   f   w   r   a   p   p   e   d   _
|...
|
|od -x tmp.txt
|...
|0012620 7573 616c 6574 6920 3a74 0a0a c220 c2a0
|0012640 c2a0 20a0 6564 2066 7277 7061 6570 5f64
|...

   And you can see, there are two octet pairs »c220« and
   »c2a0« in the post (directly preceding »def wrapped«).
   (Compare with the Content-Type and Content-Transfer-Encoding
   given above.) (Read table with a monospaced font:)

 corresponding
Codepoint  UTF-8ISO-8859-1  interpretation

U+0020?c2 2020? SPACE?
U+00A0 c2 a0a0  NON-BREAKING SPACE

   This makes it clear that there really are codepoints
   U+00A0 in what I get from the server, i.e., non-breaking
   spaces directly in front of »def wrapped«.


And?  Why does that bother you?  A non-breaking space is a perfectly 
valid thing to put into a UTF-8 encoded message.  The 0xc2 0x20 byte 
pair that you misidentify as a space is another matter entirely.


0xc2 0x20 is not a space in UTF-8.  It is an invalid code sequence.  I 
don't know how or where it was generated, but it really shouldn't have 
been.  It might have been Ned's MUA, or some obscure bug in the 
mail-to-news gateway.  Does anyone in a position to know have any opinions?


--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


[issue31912] PyMem_Malloc() should guarantee alignof(max_align_t)

2017-10-31 Thread Stefan Krah

Change by Stefan Krah :


--
nosy: +haypo

___
Python tracker 

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



[issue31912] PyMem_Malloc() should guarantee alignof(max_align_t)

2017-10-31 Thread Stefan Krah

New submission from Stefan Krah :

This is related to #27987 and #20064 and perhaps the pymalloc patch
from #18835.

I think PyMem_Malloc() should guarantee alignof(max_align_t).

It actually did before the "#define PYMEM_FUNCS PYOBJ_FUNCS" optimization,
so we have a sort of regression here.

--
components: Interpreter Core
messages: 305320
nosy: skrah
priority: normal
severity: normal
stage: needs patch
status: open
title: PyMem_Malloc() should guarantee alignof(max_align_t)
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



Re: Report on non-breaking spaces in posts (was: How to join elements at the beginning and end of the list)

2017-10-31 Thread Jon Ribbens
On 2017-10-31, Stefan Ram  wrote:
> Ned Batchelder  writes:
>>     def wrapped_join(values, sep):
>
>   Ok, here's a report on me seing non-breaking spaces in 
>   posts in this NG. I have written this report so that you
>   can see that it's not my newsreader that is converting
>   something, because there is no newsreader involved.

Yes Ned's post definitely had non-breaking spaces in; it looks like
Thunderbird is turning strings of spaces into ' \xa0+ ', presumably
because things that expect HTML will squash runs of spaces (even
though the post is not HTML...)

By the way I would commend 'od -tx1z' to you as it is *far* easier to
read:

0012460 20 0a 65 6e 63 61 70 73 75 6c 61 74 65 20 69 74  > .encapsulate it<
0012500 3a 0a 0a 20 c2 a0 c2 a0 c2 a0 20 64 65 66 20 77  >:.. .. def w<
0012520 72 61 70 70 65 64 5f 6a 6f 69 6e 28 76 61 6c 75  >rapped_join(valu<
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue31911] Use malloc_usable_size() is pymalloc for realloc

2017-10-31 Thread STINNER Victor

New submission from STINNER Victor :

Objects/obmalloc.c contains an interesting comment:

if (!address_in_range(p, pool)) {
/* pymalloc is not managing this block.

   If nbytes <= SMALL_REQUEST_THRESHOLD, it's tempting to try to take
   over this block.  However, if we do, we need to copy the valid data
   from the C-managed block to one of our blocks, and there's no
   portable way to know how much of the memory space starting at p is
   valid.

   As bug 1185883 pointed out the hard way, it's possible that the
   C-managed block is "at the end" of allocated VM space, so that a
   memory fault can occur if we try to copy nbytes bytes starting at p.
   Instead we punt: let C continue to manage this block. */
return 0;
}

See also bpo-1185883.

We don't have to guess, it's possible to get the size of a memory block 
allocated by malloc() with:

* malloc_usable_size(ptr): available at least on Linux
* _msize(ptr): Windows

Maybe we could add a "msize" field to PyMemAllocatorEx? See also bpo-18835 whic 
adds PyMem_AlignedAlloc() and so already modify (and rename PyMemAllocatorEx).

See also bpo-31626, but I'm not sure that it would help for 
_PyMem_DebugRawRealloc().

--
components: Interpreter Core
messages: 305319
nosy: haypo, serhiy.storchaka, skrah
priority: normal
severity: normal
status: open
title: Use malloc_usable_size() is pymalloc for realloc
type: performance
versions: Python 3.7

___
Python tracker 

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



Thread safety issue (I think) with defaultdict

2017-10-31 Thread Israel Brewster
A question that has arisen before (for example, here: 
https://mail.python.org/pipermail/python-list/2010-January/565497.html 
) is 
the question of "is defaultdict thread safe", with the answer generally being a 
conditional "yes", with the condition being what is used as the default value: 
apparently default values of python types, such as list, are thread safe, 
whereas more complicated constructs, such as lambdas, make it not thread safe. 
In my situation, I'm using a lambda, specifically:

lambda: datetime.min

So presumably *not* thread safe.

My goal is to have a dictionary of aircraft and when they were last "seen", 
with datetime.min being effectively "never". When a data point comes in for a 
given aircraft, the data point will be compared with the value in the 
defaultdict for that aircraft, and if the timestamp on that data point is newer 
than what is in the defaultdict, the defaultdict will get updated with the 
value from the datapoint (not necessarily current timestamp, but rather the 
value from the datapoint). Note that data points do not necessarily arrive in 
chronological order (for various reasons not applicable here, it's just the way 
it is), thus the need for the comparison.

When the program first starts up, two things happen:

1) a thread is started that watches for incoming data points and updates the 
dictionary as per above, and
2) the dictionary should get an initial population (in the main thread) from 
hard storage.

The behavior I'm seeing, however, is that when step 2 happens (which generally 
happens before the thread gets any updates), the dictionary gets populated with 
56 entries, as expected. However, none of those entries are visible when the 
thread runs. It's as though the thread is getting a separate copy of the 
dictionary, although debugging says that is not the case - printing the 
variable from each location shows the same address for the object.

So my questions are:

1) Is this what it means to NOT be thread safe? I was thinking of race 
conditions where individual values may get updated wrong, but this apparently 
is overwriting the entire dictionary.
2) How can I fix this?

Note: I really don't care if the "initial" update happens after the thread 
receives a data point or two, and therefore overwrites one or two values. I 
just need the dictionary to be fully populated at some point early in 
execution. In usage, the dictionary is used to see of an aircraft has been seen 
"recently", so if the most recent datapoint gets overwritten with a slightly 
older one from disk storage, that's fine - it's just if it's still showing 
datetime.min because we haven't gotten in any datapoint since we launched the 
program, even though we have "recent" data in disk storage thats a problem. So 
I don't care about the obvious race condition between the two operations, just 
that the end result is a populated dictionary. Note also that as datapoint come 
in, they are being written to disk, so the disk storage doesn't lag 
significantly anyway.

The framework of my code is below:

File: watcher.py

last_points = defaultdict(lambda:datetime.min)

# This function is launched as a thread using the threading module when the 
first client connects
def watch():
while true:

pointtime= 
if last_points[] < pointtime:

last_points[]=pointtime
#DEBUGGING
print("At update:", len(last_points))


File: main.py:

from .watcher import last_points

# This function will be triggered by a web call from a client, so could happen 
at any time
# Client will call this function immediately after connecting, as well as in 
response to various user actions.
def getac():


for record in aclist:
last_points[]=record_timestamp
#DEBUGGING
print("At get AC:", len(last_points))


---
Israel Brewster
Systems Analyst II
Ravn Alaska
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7293
---




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


Re: enum

2017-10-31 Thread Cousin Stanley
ast wrote:

> https://docs.python.org/3.5/library/enum.html#planet
> 
> Documentation says that the value of the enum
> members will be passed to this method.
> 
> But in that case __init__ waits for two arguments, mass
> and radius, while enum member's value is a tuple.
> 
> It seems that there is a tuple unpacking, but it is
> not documented, that's not clear
>  
  
  
I added the following code to your example
to unpack  planet.value  into mass and radius 
after first importing Enum 

from enum import Enum
 

def test_01() :

print( '\n  planet   mass   radius  gravity \n' )

for planet in Planet : 

mass , radius = planet.value

print( '  {:8s}  {:9.4E}  {:9.4E}  {:9.4E} '.format( planet.name , mass 
, radius , 
  planet.surface_gravity ) )


if __name__ == '__main__' :

test_01()


A working copy  

http://csphx.net/python/planets_enum.txt


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Performance of map vs starmap.

2017-10-31 Thread Steve D'Aprano
On Mon, 30 Oct 2017 09:10 pm, Kirill Balunov wrote:

> Sometime ago I asked this question at SO [1], and among the responses
> received was paragraph:
> 
>  - `zip` re-uses the returned `tuple` if it has a reference count of 1 when
> the `__next__` call is made.
>  - `map` build a new `tuple` that is passed to the mapped function every
> time a `__next__` call is made.
> 
> Why can not `map` use the same approach as `zip`?


It possibly could, if somebody could be bothered to make that
micro-optimization.



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


[issue20064] PyObject_Malloc is not documented

2017-10-31 Thread STINNER Victor

STINNER Victor  added the comment:

It took a while, but PyObject_Malloc() & cie are now documented :-)

I even backported and *adapted* the doc to Python 2.7 ;-)

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.6, Python 3.7 -Python 3.4, Python 3.5

___
Python tracker 

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



[issue20064] PyObject_Malloc is not documented

2017-10-31 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset 52ba7b447f41dad2754ddbc50ed97413b557bbe1 by Victor Stinner in 
branch '2.7':
bpo-20064: Document PyObject_Malloc() (#4204)
https://github.com/python/cpython/commit/52ba7b447f41dad2754ddbc50ed97413b557bbe1


--

___
Python tracker 

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



[issue31910] test_socket.test_create_connection() failed with EADDRNOTAVAIL (err 99)

2017-10-31 Thread STINNER Victor

New submission from STINNER Victor :

On my PR 4200 which is unrelated to networking, the following test failed once.

FAIL: test_create_connection (test.test_socket.NetworkConnectionNoServer)
--
Traceback (most recent call last):
  File "/home/travis/build/python/cpython/Lib/test/test_socket.py", line 4537, 
in test_create_connection
self.assertIn(cm.exception.errno, expected_errnos)
AssertionError: 99 not found in [111, 101]


With error codes:

* 99: EADDRNOTAVAIL: Cannot assign requested address
* 111: ECONNREFUSED: Connection refused
* 101: ENETUNREACH: Network is unreachable

Maybe we shold include EADDRNOTAVAIL in the expected error codes?

--
components: Tests
messages: 305316
nosy: haypo, martin.panter, serhiy.storchaka
priority: normal
severity: normal
status: open
title: test_socket.test_create_connection() failed with EADDRNOTAVAIL (err 99)
versions: Python 3.7

___
Python tracker 

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



[issue20064] PyObject_Malloc is not documented

2017-10-31 Thread STINNER Victor

Change by STINNER Victor :


--
pull_requests:  -4170

___
Python tracker 

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



Re: How to join elements at the beginning and end of the list

2017-10-31 Thread Steve D'Aprano
On Wed, 1 Nov 2017 02:29 am, Neil Cerutti wrote:

> You can use the % operator instead of +, and a generator
> expression instead of map. It's a pretty small improvement,
> though.
> 
> values = '||%s||' % ('||'.join(str(s) for s in value_list))
> 
> At least... I THINK you can use that generator expression in 2.7.

Generator expressions are slightly slower when you call join. If join knows
how many items there are, it can allocate space more efficiently, which is
faster.

So even though it takes a bit of time to build, and throw away, a temporary
list, its actually faster to join a list comp than a generator expression.




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


[issue20064] PyObject_Malloc is not documented

2017-10-31 Thread STINNER Victor

Change by STINNER Victor :


--
pull_requests: +4173

___
Python tracker 

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



[issue20064] PyObject_Malloc is not documented

2017-10-31 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset 8543ce8ffd57d770b57fe653e0ab7fada1a4c343 by Victor Stinner (Miss 
Islington (bot)) in branch '3.6':
bpo-20064: Document PyObject_Malloc() (GH-4199) (#4203)
https://github.com/python/cpython/commit/8543ce8ffd57d770b57fe653e0ab7fada1a4c343


--

___
Python tracker 

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



Re: How to join elements at the beginning and end of the list

2017-10-31 Thread Ned Batchelder

On 10/31/17 12:29 PM, Stefan Ram wrote:

Ned Batchelder  writes:

However you solve it, do yourself a favor and write a function to
encapsulate it:

   It is always a good solution to encapsulate a pattern into
   a function. So I agree that this is a good suggestion. But
   just for the sole sake of information, I'd like to add that
   this is also the slowest solution so far (about 10.76 usec).

   This might be a case where macros would be fine. As readable
   as a function call, but no runtime-overhead. One can write

value_list =  [1, 2, 3, 4, 56, 's']

#define JOIN_WRAPPED(list,string) \
string + string.join(map(str,list)) + string

values = JOIN_WRAPPED(value_list,'||')

print( values )

   and save it as »source.c« and execute it using

gcc -E source.c -o source.py
python source.py

   . This is also not intended to be a recommendation.



I try to avoid micro-optimization.  My guess is that right after calling 
wrapped_join(), the result will be written to an I/O device of some 
kind.  If that is so, the time spent in wrapped_join will be irrelevant.


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


[issue31880] subprocess process interaction with IDLEX GUI causes pygnuplot silent failures

2017-10-31 Thread John Brearley

John Brearley  added the comment:

The owner of PyGnuplot figured out that for Python 3.4+ that a flush on stdin 
is needed. IDLEX GUI now runs example.py and my own test code correctly.

proc.stdin.flush()  # send the command in python 3.4+

This leaves the interesting behavior of IDLEX GUI. What is it doing differently 
re stdin from the command line terminal behavior? There is probably something 
to be learned here, if someone wants to dig into it.

--

___
Python tracker 

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



[issue20064] PyObject_Malloc is not documented

2017-10-31 Thread Roundup Robot

Change by Roundup Robot :


--
pull_requests: +4172

___
Python tracker 

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



[issue20064] PyObject_Malloc is not documented

2017-10-31 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset ec2cbdd1dff2c51788136480b2085e77506ebf34 by Victor Stinner in 
branch 'master':
bpo-20064: Document PyObject_Malloc() (#4199)
https://github.com/python/cpython/commit/ec2cbdd1dff2c51788136480b2085e77506ebf34


--

___
Python tracker 

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



Re: Cooperative class tree filtering

2017-10-31 Thread Alberto Berti
Thanks Ian,

> "Ian" == Ian Kelly  writes:

Ian> On Thu, Oct 12, 2017 at 5:07 PM, Alberto Berti 
 wrote:

Ian> My initial reaction is: is this really worth it? This seems like an
Ian> awful lot of code and added complexity in order to do away with two
Ian> lines. It's a lot easier to reason about "return
Ian> super().filter(element)" and verify that it does the right thing than
Ian> for the complicated descriptor above.


yes this was also my conclusion, that descriptor is sitting on a branch
of its own and I've yet to decide on it.  The fact is that i've many
cases where I need a coperative superclass-subclass method execution and
I was trying to find some other pattern that would fit in ;-)


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


[issue31893] Issues with kqueue

2017-10-31 Thread Roundup Robot

Change by Roundup Robot :


--
pull_requests: +4171

___
Python tracker 

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



[issue20064] PyObject_Malloc is not documented

2017-10-31 Thread STINNER Victor

Change by STINNER Victor :


--
pull_requests: +4170

___
Python tracker 

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



[issue31893] Issues with kqueue

2017-10-31 Thread Roundup Robot

Change by Roundup Robot :


--
pull_requests: +4169

___
Python tracker 

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



[issue31893] Issues with kqueue

2017-10-31 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset 2298fad5ff907dd48ea0fb5c71fa22334ef28c6b by Serhiy Storchaka in 
branch 'master':
bpo-31893: Fix errors in b9052a0f91d2e83bbc27267247a5920c82b242a3. (#4196)
https://github.com/python/cpython/commit/2298fad5ff907dd48ea0fb5c71fa22334ef28c6b


--

___
Python tracker 

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



[issue18835] Add aligned memory variants to the suite of PyMem functions/macros

2017-10-31 Thread STINNER Victor

Change by STINNER Victor :


--
pull_requests: +4168

___
Python tracker 

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



Re: How to join elements at the beginning and end of the list

2017-10-31 Thread Neil Cerutti
On 2017-10-31, Stefan Ram  wrote:
> Neil Cerutti  writes:
>>You can use the % operator instead of +, and a generator
>>expression instead of map. It's a pretty small improvement,
>>though.
>
>   "Improvement" in what sense?
>
> C:\>python -m timeit -s "value_list =  [1, 2, 3, 4, 56, 's']" "values = '||' 
> + '||'.join(map(str, value_list)) + '||'"
> 10 loops, best of 3: 4.86 usec per loop
>
> C:\>python -m timeit -s "value_list =  [1, 2, 3, 4, 56, 's']" "values = 
> '||%s||' % ('||'.join(str(s) for s in value_list))"
> 10 loops, best of 3: 7.46 usec per loop

Hmmm minty freshness?

-- 
Neil Cerutti

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


[issue20064] PyObject_Malloc is not documented

2017-10-31 Thread STINNER Victor

Change by STINNER Victor :


--
pull_requests: +4167

___
Python tracker 

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



Re: How to join elements at the beginning and end of the list

2017-10-31 Thread Ned Batchelder

On 10/31/17 11:29 AM, Neil Cerutti wrote:

On 2017-10-31, Ganesh Pal  wrote:

Here is my solution


values = '||' + '||'.join(map(str, value_list)) + '||'
values

'||1||2||3||4||56||s||'

I am joining the elements at the beginning and end of the list
using '+' operator any other solution, this is not looking
neater

I am a Linux user using python 2.7

You can use the % operator instead of +, and a generator
expression instead of map. It's a pretty small improvement,
though.

values = '||%s||' % ('||'.join(str(s) for s in value_list))

At least... I THINK you can use that generator expression in 2.7.



However you solve it, do yourself a favor and write a function to 
encapsulate it:


    def wrapped_join(values, sep):
    """Join values with sep, and also include sep at the ends."""
    return "{sep}{vals}{sep}".format(sep=sep, vals=sep.join(str(v) 
for v in values))


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


Re: How to join elements at the beginning and end of the list

2017-10-31 Thread Neil Cerutti
On 2017-10-31, Ganesh Pal  wrote:
> Here is my solution
>
 values = '||' + '||'.join(map(str, value_list)) + '||'
 values
>
> '||1||2||3||4||56||s||'
>
> I am joining the elements at the beginning and end of the list
> using '+' operator any other solution, this is not looking
> neater
>
> I am a Linux user using python 2.7

You can use the % operator instead of +, and a generator
expression instead of map. It's a pretty small improvement,
though.

values = '||%s||' % ('||'.join(str(s) for s in value_list))

At least... I THINK you can use that generator expression in 2.7.

-- 
Neil Cerutti

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


[issue18835] Add aligned memory variants to the suite of PyMem functions/macros

2017-10-31 Thread Stefan Krah

Stefan Krah  added the comment:

On Tue, Oct 31, 2017 at 02:55:04PM +, Nathaniel Smith wrote:
> 3) also it's not clear what the best approach will look like, given that we 
> care a lot about using calloc when possible, and have reason to prefer using 
> regular freeing functions whenever possible.

I actually have the same problems. But since no fast (kernel-zeroed)
aligned_calloc() exists, I must use memset() anyway.

So an emulated aligned_calloc() should probably not go into CPython
since it doesn't provide any performance advantages.

--

___
Python tracker 

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



Re: Invoking return through a function?

2017-10-31 Thread Rhodri James

On 31/10/17 02:06, Alberto Riva wrote:

Steve D'Aprano gave you a pretty full answer, I just wanted to add:


 The kind of
statement I was trying to add would at least have made that explicit: 
return-if-so-and-so-happens.


That's only obvious in the function that's doing the returning.  The 
function that's doing the calling that gets its expectation of flow 
control broken has no clue, and that's my problem.


--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


[issue18835] Add aligned memory variants to the suite of PyMem functions/macros

2017-10-31 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Le 31/10/2017 à 15:55, Nathaniel Smith a écrit :
> 
> 1) numpy hasn't actually come to a decision about whether to use aligned 
> allocation at all, or under what circumstances.

This isn't the Numpy bug tracker, but I can't help but mention that if
Numpy grew a facility for users to override the memory allocators it
invokes to allocate array data, Numpy may not have to come to a decision
about this at all... ;-) And it would also help specialized
accelerators, which may want to direct Numpy arrays to e.g. memory
that's cheaply shared with the GPU.

(see https://github.com/numpy/numpy/pull/5470)

> I wasn't making a criticism of your API; "it's not you, it's us" :-). But 
> this is a complicated and subtle area that's not really part of CPython's 
> core competency, and coming at a time when people are fretting about how to 
> shrink the C APIs surface area. E.g. I can think of more interesting ways for 
> the PyPy folks to spend their time than implementing an aligned_alloc 
> wrapper...

The same argument can be made for any part of the stdlib or core
language that PyPy has to reproduce.  Besides, I don't think
implementing an aligned_alloc wrapper is very difficult.  The hard part
is getting an agreement over the exposed APIs, and that's CPython's job,
not PyPy ;-)

--

___
Python tracker 

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



[issue18835] Add aligned memory variants to the suite of PyMem functions/macros

2017-10-31 Thread Nathaniel Smith

Nathaniel Smith  added the comment:

> Can you elaborate why numpy wouldn't use this new API? I designed it with 
> numpy in mind :-)

The reasons I had in mind are:

1) numpy hasn't actually come to a decision about whether to use aligned 
allocation at all, or under what circumstances.

2) if we do use it, we'll probably need our own implementation anyway to 
support old pythons.

3) also it's not clear what the best approach will look like, given that we 
care a lot about using calloc when possible, and have reason to prefer using 
regular freeing functions whenever possible.

I wasn't making a criticism of your API; "it's not you, it's us" :-). But this 
is a complicated and subtle area that's not really part of CPython's core 
competency, and coming at a time when people are fretting about how to shrink 
the C APIs surface area. E.g. I can think of more interesting ways for the PyPy 
folks to spend their time than implementing an aligned_alloc wrapper...

--

___
Python tracker 

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



[issue31893] Issues with kqueue

2017-10-31 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Oh, I forgot that Mac OS X also in the BSD family.

Thank you Victor for signaling errors.

--

___
Python tracker 

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



How to join elements at the beginning and end of the list

2017-10-31 Thread Ganesh Pal
How to join each elements with a delimiter at (1) beginning and end of the
list and (2) connecting all elements  of the list

Example :

>>> value_list =  [1, 2, 3, 4, 56, 's']   I want this to be converted in
this  from '||1||2||3||4||56||s||'

Here is my solution

>>> values = '||' + '||'.join(map(str, value_list)) + '||'
>>> values

'||1||2||3||4||56||s||'


Iam joining the elements at the beginning and end of the list using '+'
operator any other solution, this is not looking neater


I am a Linux user using python 2.7


Regards,
Ganesh
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue31880] subprocess process interaction with IDLEX GUI causes pygnuplot silent failures

2017-10-31 Thread John Brearley

John Brearley  added the comment:

Additonal testing shows that the subprocess.run command will reliably interact 
directly with gnuplot, either from the IDLEX GUI or the Python terminal window.

import subprocess
def run_cmd(cmd):
   print("run_cmd cmd:", cmd)
   # MUST explicitly ask for stdout, stderr. timeout is in seconds
   p1 = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, 
timeout=20)
   # print("run_cmd p1:", p1, type(p1))
   print("run_cmd p1.stdout:", p1.stdout, type(p1.stdout), 
p1.stdout.decode("utf-8"))
   print("run_cmd p1.stderr:", p1.stderr, type(p1.stderr), 
p1.stderr.decode("utf-8"))
   print("run_cmd p1.returncode:", p1.returncode, type(p1.returncode))

cmd = "gnuplot.exe "+self+"_candles.gnu"
run_cmd(cmd)

--

___
Python tracker 

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



[issue31893] Issues with kqueue

2017-10-31 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
pull_requests: +4166

___
Python tracker 

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



[issue31844] HTMLParser: undocumented not implemented method

2017-10-31 Thread William Ayd

William Ayd  added the comment:

And assuming that subclass requirement is intentional we could add an optional 
keyword argument to the HTMLParser that indicates what to do with errors, much 
like how encoding issues are handled within codecs. For backwards compatibility 
it can default to ignore, but fail and warn could be two alternate approaches 
that the error method could account for

--

___
Python tracker 

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



[issue31893] Issues with kqueue

2017-10-31 Thread STINNER Victor

STINNER Victor  added the comment:

Oh, the commit also broke the "x86 Tiger 3.x buildbot:

http://buildbot.python.org/all/#/builders/30/builds/93

==
FAIL: test_create_event (test.test_kqueue.TestKQueue)
--
Traceback (most recent call last):
  File "/Users/db3l/buildarea/3.x.bolen-tiger/build/Lib/test/test_kqueue.py", 
line 71, in test_create_event
self.assertEqual(ev.data, 5)
AssertionError: 25769803781 != 5

--

___
Python tracker 

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



[issue18835] Add aligned memory variants to the suite of PyMem functions/macros

2017-10-31 Thread STINNER Victor

STINNER Victor  added the comment:

Stefan Krah: "we care about the C11 restriction? (...) "size - number of bytes 
to allocate. An integral multiple of alignment" (...) posix_memalign and 
_aligned_malloc don't care about the multiple."

I prefer to ignore this restriction at this point.

I wouldn't be surprised if posix_memalign() and _aligned_malloc() already align 
the size for us internally.

We can add the restriction later, if needed.

--

___
Python tracker 

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



  1   2   >