[issue29877] compileall hangs when accessing urandom even if number of workers is 1

2017-03-21 Thread Dustin Spicuzza

Changes by Dustin Spicuzza :


--
title: compileall fails with urandom error even if number of workers is 1 -> 
compileall hangs when accessing urandom even if number of workers is 1

___
Python tracker 

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



[issue29877] compileall fails with urandom error even if number of workers is 1

2017-03-21 Thread Dustin Spicuzza

New submission from Dustin Spicuzza:

Found on Python 3.6 on a low-resource platform (NI RoboRIO), it seems that this 
occurs only because the ProcessPoolExecutor is being imported. A proposed fix 
would only import ProcessPoolExecutor if -j > 1. Stacktrace follows:

 /usr/local/bin/python3 -m compileall -j 1 /home/lvuser/py
^CTraceback (most recent call last):
  File "/usr/local/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
  File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
  File "/usr/local/lib/python3.6/compileall.py", line 20, in 
from concurrent.futures import ProcessPoolExecutor
  File "/usr/local/lib/python3.6/concurrent/futures/__init__.py", line 17, in 

from concurrent.futures.process import ProcessPoolExecutor
  File "/usr/local/lib/python3.6/concurrent/futures/process.py", line 53, in 

import multiprocessing
  File "/usr/local/lib/python3.6/multiprocessing/__init__.py", line 16, in 

from . import context
  File "/usr/local/lib/python3.6/multiprocessing/context.py", line 5, in 

from . import process
  File "/usr/local/lib/python3.6/multiprocessing/process.py", line 311, in 

_current_process = _MainProcess()
  File "/usr/local/lib/python3.6/multiprocessing/process.py", line 298, in 
__init__
self._config = {'authkey': AuthenticationString(os.urandom(32)),

--
components: Library (Lib)
messages: 289973
nosy: virtuald
priority: normal
severity: normal
status: open
title: compileall fails with urandom error even if number of workers is 1
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



[issue29876] Check for null return value [_elementtree.c : subelement]

2017-03-21 Thread Alex CHEN

New submission from Alex CHEN:

In file _elementtree.c

our static code scanner has reported this case, I think there is a bit similar 
to http://bugs.python.org/issue29874 (returns NULL when NoMemory)

static PyObject*
subelement(PyObject* self, PyObject* args, PyObject* kw)
{
PyObject* elem;

ElementObject* parent;
PyObject* tag;
PyObject* attrib = NULL;
if (!PyArg_ParseTuple(args, "O!O|O!:SubElement",
  _Type, , ,
  _Type, ))
return NULL;

if (attrib || kw) {
attrib = (attrib) ? PyDict_Copy(attrib) : PyDict_New();
if (!attrib)
return NULL;
if (kw)
PyDict_Update(attrib, kw);
} else {
Py_INCREF(Py_None);
attrib = Py_None;
}

elem = element_new(tag, attrib);  // <== element_new could 
returns a NULL pointer, the followed Py_DECREF(elem) would dereference NULL 
pointer.

Py_DECREF(attrib);

if (element_add_subelement(parent, elem) < 0) {
Py_DECREF(elem);
return NULL;
}

--
components: XML
messages: 289972
nosy: alexc
priority: normal
severity: normal
status: open
title: Check for null return value [_elementtree.c : subelement]
type: crash
versions: Python 2.7

___
Python tracker 

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



[issue29868] multiprocessing.dummy missing cpu_count

2017-03-21 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +davin, flox

___
Python tracker 

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



[issue29875] IDLE quit unexpectedly

2017-03-21 Thread Ned Deily

Ned Deily added the comment:

Welcome to the world of Python! You most likely saw a message similar to this 
when the IDLE shell window opened:

WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable.
Visit http://www.python.org/download/mac/tcltk/ for current information.

If you follow that link, you'll see that you need to install a newer version of 
Tcl/Tk 8.5.x to avoid bugs in Tcl/Tk; the easiest solution is to download and 
install ActiveTcl 8.5 from ActiveState as described.

--
nosy: +ned.deily
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



[issue29875] IDLE quit unexpectedly

2017-03-21 Thread Igor

New submission from Igor:

Hi! I'm a newbie, both in this community and with Python. I downloaded Python 
today (March 22, 2017, version 3.6.1) and as I was following a tutorial on how 
to build my first program (the classical Hello World) with Python, the IDLE 
window closed and my Mac showed the following message: "IDLE quit 
unexpectedly". It happens every time I type the ' (single quotation mark).I've 
tried 10 times so far and it keeps happening. 
Thank you!

--
assignee: terry.reedy
components: IDLE
messages: 289970
nosy: igorafm, terry.reedy
priority: normal
severity: normal
status: open
title: IDLE quit unexpectedly
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



[issue29874] Need a look for return value checking [selectmodule.c]

2017-03-21 Thread Xiang Zhang

Changes by Xiang Zhang :


--
resolution:  -> fixed
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



[issue29874] Need a look for return value checking [selectmodule.c]

2017-03-21 Thread Xiang Zhang

Changes by Xiang Zhang :


--
pull_requests: +672

___
Python tracker 

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



[issue29873] Need a look for return value checking [_elementtree.c]

2017-03-21 Thread Xiang Zhang

Xiang Zhang added the comment:

Fixed. Thanks for your report Alex.

--
nosy: +xiang.zhang
resolution:  -> fixed
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



[issue29874] Need a look for return value checking [selectmodule.c]

2017-03-21 Thread Xiang Zhang

Xiang Zhang added the comment:

This has been fixed for 3.x in #18408 but not backported to 2.7.

--
nosy: +xiang.zhang

___
Python tracker 

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



[issue29874] Need a look for return value checking [selectmodule.c]

2017-03-21 Thread Xiang Zhang

Changes by Xiang Zhang :


--
versions: +Python 2.7

___
Python tracker 

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



[issue29874] Need a look for return value checking [selectmodule.c]

2017-03-21 Thread Alex CHEN

Changes by Alex CHEN :


--
type:  -> crash

___
Python tracker 

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



[issue29874] Need a look for return value checking [selectmodule.c]

2017-03-21 Thread Alex CHEN

New submission from Alex CHEN:

In file selectmodule.c

our static code scanner has reported the following case, function set2list is 
liable to return NULL (if PyTuple_New failed),  would any chance the NULL 
pointer be dereferenced (Py_DECREF(fdlist) after set2list) or it would just 
raise python exception to handle PyTuple_New error ?

static PyObject *
select_select(PyObject *self, PyObject *args)
{
..
if (n < 0) {
PyErr_SetFromErrno(SelectError);
}
#endif
else {
/* any of these three calls can raise an exception.  it's more
   convenient to test for this after all three calls... but
   is that acceptable?
*/
ifdlist = set2list(, rfd2obj);  //   || <=
ofdlist = set2list(, wfd2obj);  //   ||
efdlist = set2list(, efd2obj);  //   ||
if (PyErr_Occurred())
ret = NULL;
else
ret = PyTuple_Pack(3, ifdlist, ofdlist, efdlist);

Py_DECREF(ifdlist);
Py_DECREF(ofdlist);
Py_DECREF(efdlist);

--
messages: 289967
nosy: alexc
priority: normal
severity: normal
status: open
title: Need a look for return value checking [selectmodule.c]

___
Python tracker 

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



[issue29873] Need a look for return value checking [_elementtree.c]

2017-03-21 Thread Xiang Zhang

Changes by Xiang Zhang :


--
pull_requests: +671

___
Python tracker 

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



[issue29871] Enable optimized locks on Windows

2017-03-21 Thread Josh Rosenberg

Josh Rosenberg added the comment:

Hmm... I was only running the threading related tests originally, and they 
passed, but it looks like this causes problems with multiprocessing 
(test_multiprocessing_spawn and test_concurrent_futures both stall out forever 
with this change, with or without my fix to the PyCOND_TIMEDWAIT function). 
I'll investigate further, don't bother to review yet.

--

___
Python tracker 

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



[issue29873] Need a look for return value checking [_elementtree.c]

2017-03-21 Thread Alex CHEN

New submission from Alex CHEN:

In file _elementtree.c

our static code scanner has reported this case, but I don't sure that could be 
any problem, may you have a look?

static PyObject*  
element_getattr(ElementObject* self, char* name)
{
PyObject* res;

/* handle common attributes first */
if (strcmp(name, "tag") == 0) {
res = self->tag;
Py_INCREF(res);
return res;
} else if (strcmp(name, "text") == 0) {
res = element_get_text(self); // is it possible that 
element_get_text could return NULL here?
Py_INCREF(res);
return res;
}

--
components: XML
messages: 289965
nosy: alexc
priority: normal
severity: normal
status: open
title: Need a look for return value checking [_elementtree.c]
type: crash
versions: Python 2.7

___
Python tracker 

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



[issue21895] signal.pause() and signal handlers don't react to SIGCHLD in non-main thread

2017-03-21 Thread Nathaniel Smith

Nathaniel Smith added the comment:

@haypo: okay, looked over things over for a third time and this time I found my 
very silly error :-). So I'm now able to use set_wakeup_fd on Windows 
(https://github.com/python-trio/trio/pull/108), but not on Unix 
(https://github.com/python-trio/trio/issues/109).

In any case, the issue here remains that one shouldn't have to use 
set_wakeup_fd for a signal to interrupt time.sleep etc.

--

___
Python tracker 

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



[issue29504] blake2: compile error with -march=bdver2

2017-03-21 Thread Ned Deily

Ned Deily added the comment:

This didn't make it in time for 3.6.1; deferred to 3.6.2.

--

___
Python tracker 

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



[issue29872] spam

2017-03-21 Thread Xiang Zhang

Changes by Xiang Zhang :


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

___
Python tracker 

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



[issue29872] spam

2017-03-21 Thread Xiang Zhang

Changes by Xiang Zhang :


--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
title: My reply -> spam

___
Python tracker 

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



[issue29872] My reply

2017-03-21 Thread James Triveri

New submission from James Triveri:

reply from james.triv...@gmail.com

--
messages: 289962
nosy: jtrive84
priority: normal
severity: normal
status: open
title: My reply

___
Python tracker 

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



[issue29870] ssl socket leak

2017-03-21 Thread Alexander Mohr

Alexander Mohr added the comment:

interestingly the valgrind run doesn't show a leak in the profile

--

___
Python tracker 

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



[issue29870] ssl socket leak

2017-03-21 Thread Alexander Mohr

Alexander Mohr added the comment:

adding valgrind log of 3.5.3 on debian: jessie

--
Added file: http://bugs.python.org/file46750/valgrind.log.gz

___
Python tracker 

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



[issue29869] Underscores in numeric literals not supported in lib2to3.

2017-03-21 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
stage:  -> patch review
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



[issue28767] Readd __index__ support on ipaddress objects

2017-03-21 Thread Josh Rosenberg

Josh Rosenberg added the comment:

>From the original bugs, it looks like people liked being able to directly 
>produce the hex of the IP addresses using hex(). I'll admit I'm only +0.5 on 
>restoring __index__; having them be equivalent to int, not just convertable, 
>doesn't seem critical. I just noticed the original bugs (don't even remember 
>why I found them) and figured the functionality should be restored, per the 
>comments on those bugs.

--

___
Python tracker 

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



[issue29871] Enable optimized locks on Windows

2017-03-21 Thread Josh Rosenberg

Josh Rosenberg added the comment:

Note: Beyond turning on the new primitives by default, I also made a change to 
PyCOND_TIMEDWAIT. The original code looked wrong, in that:

1. It assumed that when SleepConditionVariableSRW returned non-zero, you didn't 
know if the wait had timed out or not, so it returned 2 to indicate "Might have 
timed out, act as if it timed out"
2. It assumed that when SleepConditionVariableSRW returned zero, it had 
suffered a critical failure, and returned -1 to indicate that.

Neither of these things is true AFAICT. SleepConditionVariableSRW returns 
non-zero when it's alerted prior to timing out. Otherwise, it returns 0, and 
you have to check GetLastError to distinguish timeout from critical failures. 
Documentation is here: 
https://msdn.microsoft.com/en-us/library/windows/desktop/ms686304(v=vs.85).aspx

It's subject to "spurious" wake-ups, but so is pthread_cond_timedwait and the 
pthreads code doesn't use an "all timedwaits time out".

--

___
Python tracker 

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



[issue29871] Enable optimized locks on Windows

2017-03-21 Thread Josh Rosenberg

Changes by Josh Rosenberg :


--
pull_requests: +670

___
Python tracker 

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



[issue21895] signal.pause() and signal handlers don't react to SIGCHLD in non-main thread

2017-03-21 Thread Nathaniel Smith

Nathaniel Smith added the comment:

@haypo: It's a socketpair. It works fine when I set up a toy test case using 
set_wakeup_fd + select, and it works fine in my real code when I use CFFI 
cleverness to register a signal handler that manually writes a byte to my 
wakeup socket, but when I pass that exact same socket to set_wakeup_fd in my 
real code, it doesn't work. It's pretty mysterious, and I have no particular 
reason to think that the problem is in CPython as opposed to some stupid 
mistake I'm making.

--

___
Python tracker 

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



[issue29870] ssl socket leak

2017-03-21 Thread Alexander Mohr

Alexander Mohr added the comment:

validated 3.6 in fedora is affected as well, see github bug for charts.  So it 
seems all 3.5.3+ versions are affected.  I'm guessing it was introduced in one 
of the SSL changes in 3.5.3: 
https://docs.python.org/3.5/whatsnew/changelog.html#python-3-5-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



[issue29871] Enable optimized locks on Windows

2017-03-21 Thread Josh Rosenberg

New submission from Josh Rosenberg:

Kristjan wrote improved locking primitives in #15038 that use the new (in 
Vista) SRWLock and Condition Variable APIs. SRWLocks (used in exclusive mode 
only) replace Critical Sections, which is slower than SRWLock and provides no 
features we use that might justify it. Condition Variables replace Semaphores, 
where the former is user mode (cheap) and the latter kernel mode (expensive).

These changes remain disabled by default.

Given that CPython dropped support for pre-Vista OSes in 3.5, I propose 
enabling the faster locking primitives by default. The PR I'll submit leaves 
the condition variable emulation code in the source so it's available to people 
who might try to build XP/WS03 compatible code, it just tweaks the define so it 
defaults to using the Vista+ APIs.

Based on the numbers from #15038, we should expect to see a significant 
improvement in speed.

--
components: Interpreter Core, Windows
messages: 289955
nosy: josh.r, kristjan.jonsson, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Enable optimized locks on Windows
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



[issue29870] ssl socket leak

2017-03-21 Thread Alexander Mohr

New submission from Alexander Mohr:

When upgrading to 3.5.3 we noticed that the requests module was leaking memory 
rather quickly.  This led to me logging the issue: 
https://github.com/kennethreitz/requests/issues/3933.  After more investigation 
I've found that the leak is caused by the raw python SSL sockets.  I've created 
a test file here: 
https://gist.github.com/thehesiod/ef79dd77e2df7a0a7893dfea6325d30a which allows 
you to reproduce the leak with raw python ssl socket (CLIENT_TYPE = 
ClientType.RAW), aiohttp or requests.  They all leak in a similar way due to 
their use of the python SSL socket objects.  I tried tracing the memory usage 
with tracemalloc but nothing interesting popped up so I believe this is a leak 
in the native code.

A docker cloud image is available here: amohr/testing:stretch_request_leak 
based on:
```
FROM debian:stretch

COPY request_https_leak.py /tmp/request_https_leak.py

RUN apt-get update && \
apt-get install -y python3.5 python3-pip git

RUN python3 -m pip install requests 
git+git://github.com/thehesiod/pyca.git@fix-py3#egg=calib setproctitle requests 
psutil
```

I believe this issue was introduced in python 3.5.3 as we're not seeing the 
leak with 3.5.2.  Also I haven't verified yet if this happens on non-debian 
systems.  I'll update if I have any more info.  I believe 3.6 is similarly 
impacted but am not 100% certain yet.

--
assignee: christian.heimes
components: SSL
messages: 289954
nosy: christian.heimes, thehesiod
priority: normal
severity: normal
status: open
title: ssl socket leak
type: resource usage
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



[issue21895] signal.pause() and signal handlers don't react to SIGCHLD in non-main thread

2017-03-21 Thread STINNER Victor

STINNER Victor added the comment:

2017-03-22 1:55 GMT+01:00 Nathaniel Smith :
> + for some reason set_wakeup_fd doesn't work for me on Windows (no idea why, 
> can't reproduce in simplified tests, might be my fault, need to debug),

I modified signal.set_wakeup_fd() to accept a socket handle on
Windows. Are you using socket.socketpair() on Windows? Or do you pass
a pipe?

--

___
Python tracker 

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



[issue21895] signal.pause() and signal handlers don't react to SIGCHLD in non-main thread

2017-03-21 Thread Nathaniel Smith

Nathaniel Smith added the comment:

I don't really have a specific use case personally -- for trio, I haven't found 
a way to make use of set_wakeup_fd because of various issues[1], but I'm also 
not planning to use SIGCHLD, so this isn't very urgent.

In general set_wakeup_fd can be a workaround, but I wanted to note this 
upstream because it's a bug in Python's signal handler logic. Note that Python 
already goes to great lengths to make e.g. signal handlers run during 
time.sleep on Windows; they ought to just work on Unix too.

--

[1] (Off-topic but in case you're curious: I register actual signal handlers 
anyway because I follow the philosophy that the wakeup pipe should only be used 
for wakeups rather than transmitting information, so as long as signal handlers 
work I can do my own wakeups, + for some reason set_wakeup_fd doesn't work for 
me on Windows (no idea why, can't reproduce in simplified tests, might be my 
fault, need to debug), + set_wakeup_fd's handling of buffer overflow is broken 
for my purposes.)

--

___
Python tracker 

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



[issue29869] Underscores in numeric literals not supported in lib2to3.

2017-03-21 Thread Nevada Sanchez

Changes by Nevada Sanchez :


--
pull_requests: +668

___
Python tracker 

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



[issue29869] Underscores in numeric literals not supported in lib2to3.

2017-03-21 Thread Nevada Sanchez

New submission from Nevada Sanchez:

The following should work in Python 3.6

```
from lib2to3.pgen2 import driver
from lib2to3 import pytree
from lib2to3 import pygram

_GRAMMAR_FOR_PY3 = pygram.python_grammar_no_print_statement.copy()
parser_driver = driver.Driver(_GRAMMAR_FOR_PY3, convert=pytree.convert)
tree = parser_driver.parse_string('100_1\n', debug=False)
```

--
components: 2to3 (2.x to 3.x conversion tool)
messages: 289951
nosy: nevsan
priority: normal
severity: normal
status: open
title: Underscores in numeric literals not supported in lib2to3.
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



[issue29868] multiprocessing.dummy missing cpu_count

2017-03-21 Thread John Wiseman

New submission from John Wiseman:

The documentation for the multiprocessing.dummy module says that it "replicates 
the API of multiprocessing."  In Python 2.7, I can import multiprocessing.dummy 
and use the cpu_count function:

$ python2
Python 2.7.12 (default, Oct 29 2016, 19:21:06)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing.dummy as mp
>>> mp.cpu_count()
8

But in Python 3.6, multiprocessing.dummy is missing cpu_count:

$ python3
Python 3.6.0 (default, Mar 21 2017, 13:27:21)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing.dummy as mp
>>> mp.cpu_count()
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: module 'multiprocessing.dummy' has no attribute 'cpu_count'

I would expect that multiprocessing.dummy would have cpu_count, since that 
function is available in multiprocessing, and it's there in Python 2.7.

It looks like it was removed in commit 04842a8, "Remove unused or redundant 
imports in concurrent.futures and multiprocessing" (Florent Xicluna 5 years 
ago).  Maybe the removal was inadvertent?

I realize there are several workarounds, but based on the documentation and the 
behavior of previous versions, I wouldn't have expected this breaking change.

--
components: Library (Lib)
messages: 289950
nosy: johnwiseman
priority: normal
severity: normal
status: open
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



[issue24796] Deleting names referencing from enclosed and enclosing scopes

2017-03-21 Thread Ivan Levkivskyi

Changes by Ivan Levkivskyi :


--
pull_requests: +667

___
Python tracker 

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



[issue29866] Added datetime_diff to datetime.py.

2017-03-21 Thread Decorater

Decorater added the comment:

I plan to also have it to where if it is the last unit in the thing that it 
appends an and to the end as well.

--

___
Python tracker 

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



[issue29866] Added datetime_diff to datetime.py.

2017-03-21 Thread Decorater

Decorater added the comment:

Alright I revised it a bit locally too

>>> import datetime
>>> datetime.datetime_diff(datetime.datetime(2017, 1, 31), 
>>> datetime.datetime(2017, 1, 31))
''
>>> datetime.datetime_diff(datetime.datetime(2016, 12, 31, 23, 59, 59), 
>>> datetime.datetime(2017, 1, 1))
'1 year ago.'
>>> datetime.datetime_diff(datetime.datetime(2016, 1, 31), 
>>> datetime.datetime(2017, 1, 31, 1))
'1 year, 1 hour ago.'
>>>

--

___
Python tracker 

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



[issue29866] Added datetime_diff to datetime.py.

2017-03-21 Thread Decorater

Decorater added the comment:

Oh, I just realized I forgot to add other if's to each block in case certain 
parts was 0 but others was not. I also realized I tried to do 
datetime.datetime.new instead of datetime.datetime.now on the tests.

--

___
Python tracker 

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



[issue29859] Return code of pthread_* in thread_pthread.h is not used for perror

2017-03-21 Thread INADA Naoki

Changes by INADA Naoki :


--
pull_requests: +666

___
Python tracker 

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



[issue29847] Path takes and ignores **kwargs

2017-03-21 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> The support of **kwargs in Path.__new__ is needed if you want to implement a 
> subclass of Path with __init__ accepting keyword arguments

I don't remember exactly, but I think this was the intention indeed.  There was 
originally an openat-using subclass, and IIRC it took additional parameters 
(such as the directory fd). That got scrapped quite early in the process, so we 
can remove the **kwargs thing now.

--

___
Python tracker 

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



[issue29847] Path takes and ignores **kwargs

2017-03-21 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I don't know whether it was the intension of Antoine or just an oversight. I 
don't know whether it is used in the wild. But we can at least raise a 
TypeError for concrete classes PosixPath and WindowsPath if ignoring keyword 
arguments is a problem. Many extension types don't take keyword arguments, but 
their subclasses accept and ignore keyword arguments. For example:

>>> filter(None, [], foo=123)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: filter() does not take keyword arguments
>>> class X(filter): pass
... 
>>> X(None, [], foo=123)
<__main__.X object at 0xb6fdcacc>

--

___
Python tracker 

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



[issue29847] Path takes and ignores **kwargs

2017-03-21 Thread Brett Cannon

Brett Cannon added the comment:

Shoot, that's too bad. I guess we should document it then so people are aware 
that keyword arguments are ignored, else we will break subclasses. There's also 
an unfortunate difference between PurePath and Path as PurePath doesn't have 
this quirk.

--

___
Python tracker 

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



[issue29862] Fix grammar typo in importlib.reload() exception

2017-03-21 Thread Brett Cannon

Changes by Brett Cannon :


--
title: Fix grammar in importlib.reload() exception -> Fix grammar typo in 
importlib.reload() exception

___
Python tracker 

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



[issue27593] Deprecate sys._mercurial and create sys._git

2017-03-21 Thread Brett Cannon

Brett Cannon added the comment:

The output LGTM.

--

___
Python tracker 

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



[issue29863] Add a COMPACT constant to the json module

2017-03-21 Thread Bob Ippolito

Bob Ippolito added the comment:

I suppose I'm +0. I don't think this is particularly useful, but this is closer 
to the ideal of just having a boolean option. We should probably also plan to 
remove the documentation for what the type of separators is to give the 
impression that COMPACT and the default are the only valid options.

--

___
Python tracker 

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



[issue29857] Provide `sys._raw_argv` for host application's command line arguments

2017-03-21 Thread STINNER Victor

STINNER Victor added the comment:

> If the embedding application doesn't call PySys_SetArgv or PySys_SetArgvEx, 
> then there is no `argv` attribute defined in the sys module (I wasn't 
> actually sure what happened in that case, so I went and checked the code).

Ok, so just don't define sys._raw_argv in that case. But it doesn't seem enough 
to me to justify to make the attribute private.

https://docs.python.org/dev/library/sys.html#sys.getallocatedblocks can be seen 
as an implementation detail.The method name has no underscore prefix, but a 
simple fallback: return 0 if the feature is is not implemented.

--

___
Python tracker 

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



[issue29857] Provide `sys._raw_argv` for host application's command line arguments

2017-03-21 Thread Nick Coghlan

Nick Coghlan added the comment:

If the embedding application doesn't call PySys_SetArgv or PySys_SetArgvEx, 
then there is no `argv` attribute defined in the sys module (I wasn't actually 
sure what happened in that case, so I went and checked the code).

For the reference CLI, the relevant call happens in Py_Main() after all the 
interpreter level arguments have been processed.

--

___
Python tracker 

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



[issue29857] Provide `sys._raw_argv` for host application's command line arguments

2017-03-21 Thread STINNER Victor

STINNER Victor added the comment:

> For example, if Py_Main() is never called (for CPython), it would still be 
> None,

What is the content of sys.argv in that case? Can't we use the same value for 
sys._raw_argv?

--

___
Python tracker 

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



[issue29857] Provide `sys._raw_argv` for host application's command line arguments

2017-03-21 Thread Nick Coghlan

Nick Coghlan added the comment:

@Steven This is an implementation detail in the same sense that sys._getframe() 
is: it's not something that's actually going to make sense in all contexts. For 
example, if Py_Main() is never called (for CPython), it would still be None, 
and other implementations may not define it at all. And even when it's set for 
CPython, the exact details of what it contains are going to be at least 
somewhat platform dependent.

@Barry On Windows we define `mainw` rather than `main`, so it's the UTF-16-LE 
encoded text that is the "raw" form. That means the "raw" here refers to 
"before the Python interpreter CLI processing" - the normalization step to get 
the command line to wchar_t regardless of platform isn't going to be skipped 
(since the interpreter runtime itself never even sees the raw bytes in Python 
3).

One option would be to use a longer name like `sys._executable_argv`, since in 
the typical case, `sys.executable` and `sys._executable_argv[0]` will be the 
same.

@Victor It wouldn't be exactly the same as Py_GetArgcArgv, as I'd propose 
making a pristine copy *before* Py_Main() mutates anything - we do some 
in-place editing of entries while figuring out what "sys.argv[0]" should look 
like at the Python level.

--

___
Python tracker 

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



[issue29857] Provide `sys._raw_argv` for host application's command line arguments

2017-03-21 Thread STINNER Victor

STINNER Victor added the comment:

There is already an existing public C API get retrieve original program 
arguments *as text*:

/* Make the *original* argc/argv available to other modules.
   This is rare, but it is needed by the secureware extension. */

void
Py_GetArgcArgv(int *argc, wchar_t ***argv)
{
*argc = orig_argc;
*argv = orig_argv;
}

Are you talking about exposing these arguments at the Python level?

--

___
Python tracker 

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



[issue29857] Provide `sys._raw_argv` for host application's command line arguments

2017-03-21 Thread STINNER Victor

STINNER Victor added the comment:

> Well, "raw args" implies minimal or no processing,

Ok, so call it "original", sys.orig_arv, in that case ;-)

--

___
Python tracker 

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



[issue29857] Provide `sys._raw_argv` for host application's command line arguments

2017-03-21 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

On Mar 21, 2017, at 11:47 AM, STINNER Victor wrote:

>No, text please. Text is just more convenient in Python, and it's trivial to
>retrieve original bytes:
>
>raw_args_bytes = [os.fsencode(arg) for arg in sys._raw_args]

Well, "raw args" implies minimal or no processing, so bytes would make the
most sense.  It doesn't bother me that it's inconvenient; this won't be an oft
used API and the conversion to strings should be just as easy.

--

___
Python tracker 

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



[issue17792] Unhelpful UnboundLocalError due to del'ing of exception target

2017-03-21 Thread Ivan Levkivskyi

Changes 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



[issue29593] Improve UnboundLocalError message for deleted names

2017-03-21 Thread Ivan Levkivskyi

Changes 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



[issue29859] Return code of pthread_* in thread_pthread.h is not used for perror

2017-03-21 Thread Daniel Birnstiel

Changes by Daniel Birnstiel :


--
resolution:  -> fixed
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



[issue29857] Provide `sys._raw_argv` for host application's command line arguments

2017-03-21 Thread STINNER Victor

STINNER Victor added the comment:

> As bytes?

No, text please. Text is just more convenient in Python, and it's trivial to 
retrieve original bytes:

raw_args_bytes = [os.fsencode(arg) for arg in sys._raw_args]

--
nosy: +haypo

___
Python tracker 

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



[issue29857] Provide `sys._raw_argv` for host application's command line arguments

2017-03-21 Thread Steven D'Aprano

Steven D'Aprano added the comment:

Why is the name flagged as a private implementation detail? I.e. a single 
leading underscore. I'd be reluctant to rely on this in production code, given 
how strong the _private convention is.

Suggest just `sys.raw_args` instead.

--
nosy: +steven.daprano

___
Python tracker 

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



[issue29859] Return code of pthread_* in thread_pthread.h is not used for perror

2017-03-21 Thread INADA Naoki

INADA Naoki added the comment:

OK, perror() writes to stderr too.  fair enough.

--

___
Python tracker 

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



[issue29736] Optimize builtin types constructor

2017-03-21 Thread STINNER Victor

STINNER Victor added the comment:

The following types were patched to use Argument Clinic (use now 
_PyArg_ParseTupleAndKeywordsFast or don't accept keyword arguments anymore):

* complex
* float (don't accept keywords anymore)
* list
* tuple

The following types still uses PyArg_ParseTupleAndKeywords:

* bytes
* bytearray
* int (PyLong)
* str (unicode_new)

bool doesn't accept keywords anymore and uses now PyArg_UnpackTuple().

--

___
Python tracker 

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



[issue29859] Return code of pthread_* in thread_pthread.h is not used for perror

2017-03-21 Thread Daniel Birnstiel

Daniel Birnstiel added the comment:

While I agree, fprintf it not really nice, I looked through other parts of the 
python source where information is printed to stderr and fprintf was used there 
as well, so I fell back to it myself.

% grep -rnw . -e "fprintf(stderr," | wc -l  

   178

Using threading and multiprocessing is insane, I know that. Nevertheless the 
error codes returned by the pthread_* calls are processed incorrectly, so I 
would consider this a bug worth fixing.

--

___
Python tracker 

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



[issue29867] Add asserts in PyXXX_GET_SIZE macros

2017-03-21 Thread STINNER Victor

STINNER Victor added the comment:

We should test to run popular C extensions like numpy, PyQt, cython, pillow, 
etc. with a patched Python to see if it's common to use a "GET" macro to "set" 
a size. Maybe test also Django see it probably uses many C extensions. I don't 
ask to test all these modules, but at least a few of them. By "testing", I mean 
run the test suite of these projects.

--

___
Python tracker 

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



[issue29866] Added datetime_diff to datetime.py.

2017-03-21 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

In that case you can publish your code as a receipt or as a module on PyPI. If 
it will be popular enough we can consider including it in the stdlib.

Currently your code is just broken.

>>> datetime.datetime_diff(datetime.datetime(2017, 1, 31), 
>>> datetime.datetime(2017, 1, 31))
' ago.'
>>> datetime.datetime_diff(datetime.datetime(2016, 12, 31, 23, 59, 59), 
>>> datetime.datetime(2017, 1, 1))
'1 years ago.'
>>> datetime.datetime_diff(datetime.datetime(2016, 1, 31), 
>>> datetime.datetime(2017, 1, 31, 1))
'1 years1 hours ago.'

--
resolution:  -> rejected
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



[issue28749] Fixed the documentation of the mapping codec APIs

2017-03-21 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


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

___
Python tracker 

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



[issue29867] Add asserts in PyXXX_GET_SIZE macros

2017-03-21 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +665

___
Python tracker 

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



[issue29867] Add asserts in PyXXX_GET_SIZE macros

2017-03-21 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Proposed patch adds asserts for checking the type in macros PyTuple_GET_SIZE, 
PyList_GET_SIZE and PySet_GET_SIZE. This can help to find the misuse of these 
macros. Asserts already are used in macros PyBytes_GET_SIZE, 
PyByteArray_GET_SIZE, PyUnicode_GET_SIZE and PyDict_GET_SIZE. See also the 
discussion on Python-Dev: 
https://mail.python.org/pipermail/python-dev/2017-March/147628.html .

This change can break the code that uses these macros for setting the size. For 
example one place in odictobject.c. But I expect that such cases are rare. And 
all these macros are not in the limited API.

--
components: Interpreter Core
messages: 289927
nosy: haypo, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Add asserts in PyXXX_GET_SIZE macros
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



[issue26418] multiprocessing.pool.ThreadPool eats up memories

2017-03-21 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Thanks for the feedback!  I'm closing the issue then.

--
resolution:  -> fixed
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



[issue29864] Misuse of Py_SIZE in dict.fromkey()

2017-03-21 Thread Xiang Zhang

Xiang Zhang added the comment:

I think 3.6 is enough.

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



[issue29864] Misuse of Py_SIZE in dict.fromkey()

2017-03-21 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Yes, I treat this as a bugfix but I hesitated about backporting it. Py_SIZE 
works "by accident" and we can't change the layout of PyDictObject structure in 
maintain branches.

I have backported the fix to 3.6, but not to other branches since 
PyDict_GET_SIZE was added in 3.6 and other branches would need modifying the 
patch.

--

___
Python tracker 

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



[issue29864] Misuse of Py_SIZE in dict.fromkey()

2017-03-21 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +664

___
Python tracker 

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



[issue29863] Add a COMPACT constant to the json module

2017-03-21 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

-0 too. This complicates the module API without a need.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue29864] Misuse of Py_SIZE in dict.fromkey()

2017-03-21 Thread Xiang Zhang

Xiang Zhang added the comment:

How about 3.6, Serhiy? I see you treat this as a bugfix on the PR.

--
nosy: +xiang.zhang

___
Python tracker 

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



[issue29863] Add a COMPACT constant to the json module

2017-03-21 Thread INADA Naoki

INADA Naoki added the comment:

-0.  COMPACT_SEPARATOR make more sense to me.
Because `ensure_ascii=False` may make JSON more compact too.

--
nosy: +inada.naoki

___
Python tracker 

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



[issue21895] signal.pause() and signal handlers don't react to SIGCHLD in non-main thread

2017-03-21 Thread STINNER Victor

STINNER Victor added the comment:

If the main thread waits on select() and uses a pipe with
signal.set_wakeup_fd(), it should be fine. Is that your case?

Asyncio requires to have an event loop running in the main thread to spawn
child processes, to get SIGCHLD signals to get notified of child
completions. Or you can ignore these signals and use the "safe" child
waiter using waitall() and then iterate on all children.

--

___
Python tracker 

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



[issue29865] Use PyXXX_GET_SIZE macros rather than Py_SIZE for concrete types

2017-03-21 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


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

___
Python tracker 

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



[issue29864] Misuse of Py_SIZE in dict.fromkey()

2017-03-21 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


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

___
Python tracker 

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



[issue29866] Added datetime_diff to datetime.py.

2017-03-21 Thread Decorater

Decorater added the comment:

I have people who would use it and there are use cases for it as well. Also it 
works perfectly fine the other one I added to it's docstring is an example 
datetime object of my very own discord account from when I created it.

--

___
Python tracker 

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



[issue29866] Added datetime_diff to datetime.py.

2017-03-21 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

In most cases you needed localized version. And I doubt that it makes much 
sense to output seconds seconds when the difference is larger than a year. 
Often you need to use other units for quantizations, e.g. "1 1/4 hours ago" as 
on this tracker.

This function doesn't look enough general for including in the stdlib.

--
nosy: +belopolsky, serhiy.storchaka
stage:  -> patch review
type:  -> enhancement

___
Python tracker 

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



[issue29866] Added datetime_diff to datetime.py.

2017-03-21 Thread Decorater

New submission from Decorater:

The datetime_diff function compares two datetime objects and returns the time 
since the prior datetime objects (based on the current datetime object) in a 
what that is readable by humans.

This is useful when one might need to compare two datetime objects, keeping 
ones codebase as small as possible (to ensure fast Python code), and to reduce 
'hacks' in their code to make the comparison more readable by humans

the github pull request comes with changes to datetime.rst as well

Note: This is currently targeting 3.7, however if you guys desire you guys 
could backport it into 3.5 and 3.6.

--
assignee: docs@python
components: Documentation, Library (Lib)
messages: 289917
nosy: Decorater, docs@python
priority: normal
severity: normal
status: open
title: Added datetime_diff to datetime.py.
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



[issue29866] Added datetime_diff to datetime.py.

2017-03-21 Thread Decorater

Changes by Decorater :


--
pull_requests: +663

___
Python tracker 

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



[issue29865] Use PyXXX_GET_SIZE macros rather than Py_SIZE for concrete types

2017-03-21 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +662

___
Python tracker 

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



[issue29865] Use PyXXX_GET_SIZE macros rather than Py_SIZE for concrete types

2017-03-21 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Proposed patch replaces Py_SIZE with PyXXX_GET_SIZE macros for concrete types. 
For details see 
https://mail.python.org/pipermail/python-dev/2017-March/147628.html .

Py_SIZE still is used in concrete type implementations and when set the new 
size: `Py_SIZE(obj) = newsize`.

--
components: Extension Modules, Interpreter Core
messages: 289916
nosy: serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Use PyXXX_GET_SIZE macros rather than Py_SIZE for concrete types
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



[issue29864] Misuse of Py_SIZE in dict.fromkey()

2017-03-21 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +661

___
Python tracker 

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



[issue29864] Misuse of Py_SIZE in dict.fromkey()

2017-03-21 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

In dict.fromkeys() implementation when a dict is passed its size is determined 
by using the Py_SIZE macro. This is not correct since PyDictObject is not a 
PyVarObject (but see issue28988).

--
components: Interpreter Core
messages: 289915
nosy: inada.naoki, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Misuse of Py_SIZE in dict.fromkey()
type: behavior
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