[issue34864] In Idle, Mac tabs make editor status line disappear.

2018-12-14 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

PR 6665, for #33397 (add font resizing to text view and help viewer) got listed 
because I discovered that increasing and decreasing font size with control 
wheel/+/- can cause the [close] button to disappear and reappear. (I hope to 
use FontSizer for editor texts as well, and don't want it to affect the status 
bar.)  I speculated that there might be some connection to this issue.

--

___
Python tracker 

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



[issue35507] multiprocessing: seg fault when creating RawArray from numpy ctypes

2018-12-14 Thread sh37211


New submission from sh37211 :

After creating this post on StackOverflow...
https://stackoverflow.com/questions/53757856/segmentation-fault-when-creating-multiprocessing-array
...it was suggested by one of the respondents that I file a bug report.


The following code produces segmentation faults on certain OSes (Linux: Ubuntu 
16.04, 18.04 and Debian) but not others (Mac 10.13.4):

import numpy as np
from multiprocessing import sharedctypes

a = np.ctypeslib.as_ctypes(np.zeros((224,224,3)))
b = sharedctypes.RawArray(a._type_, a)

The segmentation fault occurs upon the creation of the 
multiprocessing.sharedctypes.RawArray. 

As a workaround, one can declare an intermediate variable, e.g. "a2", and write

a = np.zeros((224,224,3))
a2 = np.ctypeslib.as_ctypes(a)
b = sharedctypes.RawArray(a2._type_, a2)

User kabanus seemed to think it was more likely to be an error with 
multiprocessing than with numpy. 

Using Anaconda python distribution, Python 3.5 and 3.6.  Have not tried 3.7 or 
3.8 yet.

--
components: Library (Lib), ctypes
messages: 331888
nosy: sh37211
priority: normal
severity: normal
status: open
title: multiprocessing: seg fault when creating RawArray from numpy ctypes
type: crash
versions: Python 3.5, Python 3.6

___
Python tracker 

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



[issue35482] can't open python368rc1.chm and python372rc1.chm

2018-12-14 Thread Ma Lin


Ma Lin  added the comment:

These first bad commits come from issue35054

--

___
Python tracker 

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



[issue34864] In Idle, Mac tabs make editor status line disappear.

2018-12-14 Thread Cheryl Sabella


Change by Cheryl Sabella :


--
pull_requests: +10414

___
Python tracker 

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



[issue35482] can't open python368rc1.chm and python372rc1.chm

2018-12-14 Thread Ma Lin


Ma Lin  added the comment:

python368rc1.chm has the same problem.

I did a git bisect.
On 3.6 branch, e825b4e1a9bbe1d4c561f4cbbe6857653ef13a15 is the first bad commit
On 3.7 branch, 9a75b8470a2e0de5406edcabba140f023c99c6a9 is the first bad commit

--
title: python372rc1.chm is ill -> can't open python368rc1.chm and 
python372rc1.chm
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



[issue35208] IDLE: Squeezed lines count ignores window width

2018-12-14 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

My suggest simple rule would sqeeze it.  With n = 50 and k = 75,

if len(s) > n*k or s.count('\n') > n: squeeze(s)

would squeeze at 3750.  With k = 50, as 2500.

I am not sure yet what to do about wrapping.  For development, a count of 
actual lines might be more helpful than a variable number of wrapped lines.

--

___
Python tracker 

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



[issue35402] Upgrade macOS and Windows installers to Tcl 8.6.9 and Tk 8.6.9.1

2018-12-14 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Thank you both for the updates.  After I wrote my previous message, I realized 
that there is a difference between updating tcl/tk to take advantage of bug 
fixes (after testing for regressions), and enhancing tkinter to give directly 
access to new tk features from Python.  The latter can still be deferred to the 
next version.

--

___
Python tracker 

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



[issue35488] pathlib Path.match does not behave as described

2018-12-14 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue35506] Doc: fix keyword `as` link from `import` and `try`

2018-12-14 Thread Cheryl Sabella


Change by Cheryl Sabella :


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

___
Python tracker 

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



[issue35506] Doc: fix keyword `as` link from `import` and `try`

2018-12-14 Thread Cheryl Sabella


New submission from Cheryl Sabella :

In the documentation, using the :keyword:`as` role links to the `as` defined 
for the `with` statement, which could be confusing when it was used in the 
`import` or `try` section of the docs.

https://docs.python.org/3/reference/simple_stmts.html#the-import-statement

--
assignee: docs@python
components: Documentation
messages: 331883
nosy: cheryl.sabella, docs@python
priority: normal
severity: normal
status: open
title: Doc: fix keyword `as` link from `import` and `try`
type: enhancement
versions: Python 3.8

___
Python tracker 

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



[issue35504] `del OSError().characters_written` raises `SystemError`

2018-12-14 Thread Bachsau


Bachsau  added the comment:

Why is it using -1 instead of NULL as the "not-set-indicator"? -1 is a valid 
python integer, that can be assigned, even if it doesn't make sense in the 
context, while `None` can not, because it's missing an `__index__` method.

--

___
Python tracker 

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



[issue35505] Test test_imaplib fail in test_imap4_host_default_value

2018-12-14 Thread Petr Stupka


New submission from Petr Stupka :

OS: CentOS Linux release 7.6.1810 (Core)

==
FAIL: test_imap4_host_default_value (test.test_imaplib.TestImaplib)
--
Traceback (most recent call last):
  File "/home/stupka/build/Python-3.7.1/Lib/test/test_imaplib.py", line 83, in 
test_imap4_host_default_value
imaplib.IMAP4()
AssertionError: OSError not raised

Stderr:
/home/stupka/build/Python-3.7.1/Lib/socket.py:660: ResourceWarning: unclosed 

  self._sock = None

--

This test fails when there is (in my case) dovecot running and listening
on ::1, port 143 - expected exception is not raised.
With dovecot stopped and nothing listening on port 143 the test passes.

It should probably check if there is something listening on ::1:143 and if so 
then the test can be skipped?

--
components: Tests
messages: 331881
nosy: Petr Stupka
priority: normal
severity: normal
status: open
title: Test test_imaplib fail in test_imap4_host_default_value
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



[issue35502] Memory leak in xml.etree.ElementTree.iterparse

2018-12-14 Thread Jess Johnson


Change by Jess Johnson :


--
versions: +Python 3.6

___
Python tracker 

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



RE: Smarter algo, was Re: 03 digression by brute force

2018-12-14 Thread Avi Gross
REAL SUBJECT: Analysis of alternate algorithms.

Peter & Jach and anyone interested,

As Peter said in his altered subject line, Jack changed directions from 
tweaking an algorithm to trying something quite different.

Reminder of the problem. 

Horizontal View:
SEND + MORE = MONEY

Vertical View:
  SEND
+MORE
...
MONEY

Hard to be precise as I am sticking to plain text in my message. The three 
words above are meant to be right adjusted.

When solving it horizontally, Jach and I used variants of a brute force 
approach. Substitute all possible combinations. He did it in-line and used 
eval. I did it by making lists of items on both sides and summing the int() of 
each component and comparing. We tried both our algorithms and his was slower 
and he profiled that the cause was that eval() was much more expensive as were 
his use of regular expression functions. For comparison, mine used int() and 
string manipulation functions and sets and dictionaries.

But the real puzzle is meant to be solved in a more vertical way by humans 
using logic. I won't do that here but note we have 4 equations going down but 8 
unknowns. And the equations are not unique.

The rightmost column (I will call it the first as our arithmetic proceeds from 
right to left) is meant to represent ONES and provides the equation:

(D+E== Y) or (D+E == Y + 10)

Worse, for the next column, you either get a "1" carried from the previous 
addition or not and either pass a "1" along to the next column or not. 4 
Possibilities.

(N+R==E) or (N+R+1==E) or (N+R==E+10) or (N+R+1==E+10)

Getting a headache yet?

For a human, they need a way to come up with additional info in terms of 
constraints.

There is a guiding inequality that looks like this:

S is not the same as any of the others. Anytime you solve for another, the list 
of possible values for S shrinks.
Ditto for each other variable.
Or, since anything plus 0 is itself, then D and E adding up to Y (with no 
possible carry) cannot be 0.

But getting a computer to do this might be a bit harder than blunt-force 
searches. So let's see why Jach's new algorithm was faster.

The code I am analyzing can be viewed in the archives and will not be entered 
again:

https://mail.python.org/pipermail/python-list/2018-December/738454.html

So what did Jach try in his newer version? It is what I call a vertical 
approach but one a computer can do easier than a human can or would. I see it 
is a very specific algorithm that hard codes in these variables as global 
entities that are altered by a set of nested functions. S, E, N, D, M, O, R, Y. 
There are approaches that might be better such as passing a dictionary 
partially filled out from one function to the next as the only one that prints 
the solution is the final function call.

So his is not a general solution.

What interests me as a probable reason this is faster is the number of 
situations it tries. The earlier versions asked itertools.permutations() to 
provide all unique combinations of ten tokens in eight positions. So there were 
10 choices for the first and 9 for the second and so on adding up to 10!/2! or 
1,814,400  different combinations tried. That approaches 2 million.

Jack broke the problem down into evaluating the units column with a loop like 
this:

itertools.permutations(range(10), 3)

That is 720 possibilities. He then doubled that to 1,440 to consider a carry. 
Only if the selected values for the three variables in contention (plus a 
carry) does he go on to call to evaluate the tens column.

It then shrinks a bit more as he no longer gets the permutations of all 10 
digits. He subtracts the three values that might work for the units, so he is 
asking for permutations of 7 digits, two at a time. That is 42, doubled again 
to 84 for carry purposes. And this function is not called 1,440 times, but 
quite a bit fewer. 

So, similarly, of those 84 loops for tens, he only sometimes calls to evaluate 
hundreds. As mentioned, the set of 10 digits shrinks some more and this 
continues upward to functions that evaluate hundreds and thousands  and finally 
the one evaluating ten thousands pretty much prints out an answer it finds. 

So overall iterations can be shown to drop. We could add code to measure how 
many times each function is called and come up with an exact value for this 
built-in problem. I did and the functions were called this many times:

>>> counting
{'unit': 1, 'ten': 72, 'hundred': 290, 'thou': 183, '10thou': 196}
>>> sum(counting.values())
742

But I also see the permutation function was called 542 times. Most of those 
runs though were fairly trivial as the combined number of items issued back 
were only 7,390 as compared to nearly two million in the earlier version. 
Overall, this is much faster.

Range() is probably a highly efficient built-in written in C, but it can 
totally be eliminated in this code as it is a constant. You can write 
{1,2,2,3,4,5,6,7,8,9} or [0,1] instead of calculating ranges.


[issue35482] python372rc1.chm is ill

2018-12-14 Thread Steve Dower


Steve Dower  added the comment:

You're right, this is doing something weird on master as well.

I'll take a look when I get a chance, but if anyone else wants to dive in feel 
free.

In both cases, the doc file cannot be opened. Marking this as a release blocker 
and adding RM to the bug for awareness.

--
nosy: +ned.deily
priority: normal -> release blocker
versions: +Python 3.8

___
Python tracker 

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



[issue35504] `del OSError().characters_written` raises `SystemError`

2018-12-14 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

PR 11172 makes deleting characters_written to be as for other non-special 
attributes. Deleting it will be successful only if it was set before, and will 
raise an AttributeError otherwise.

>>> e = OSError()
>>> e.characters_written = 1
>>> del e.characters_written
>>> del e.characters_written
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: characters_written

--
versions: +Python 3.8

___
Python tracker 

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



[issue35504] `del OSError().characters_written` raises `SystemError`

2018-12-14 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue35488] pathlib Path.match does not behave as described

2018-12-14 Thread anthony shaw


anthony shaw  added the comment:

Raised a PR for the test. Will look into doc PR

--

___
Python tracker 

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



[issue35488] pathlib Path.match does not behave as described

2018-12-14 Thread anthony shaw


Change by anthony shaw :


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

___
Python tracker 

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



[issue35450] venv module doesn't create a copy of python binary by default

2018-12-14 Thread Marcin


Marcin  added the comment:

Actually the documentation hasn't been regenerated yet. I hope it will over 
night?

--

___
Python tracker 

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



[issue35504] `del OSError().characters_written` raises `SystemError`

2018-12-14 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue35504] `del OSError().characters_written` raises `SystemError`

2018-12-14 Thread Bachsau


Change by Bachsau :


--
title: `del OSError().characters_written` raises SystemError -> `del 
OSError().characters_written` raises `SystemError`

___
Python tracker 

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



[issue35504] `del OSError().characters_written` raises SystemError

2018-12-14 Thread Bachsau


New submission from Bachsau :

`del OSError().characters_written` raises `SystemError`:
"null argument to internal routine"

I don't know why anyone should try this in productive code, but since the 
documentation says, that every `SystemError` should be reported, I'm doing 
that. My suggestion would be to make that attribute behave like the other ones 
of `OSError`, e.g. defaulting to `None` and returning to that value on deletion.

--
components: Interpreter Core
messages: 331876
nosy: Bachsau
priority: normal
severity: normal
status: open
title: `del OSError().characters_written` raises SystemError
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



[issue35502] Memory leak in xml.etree.ElementTree.iterparse

2018-12-14 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +10408

___
Python tracker 

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



[issue25638] Verify the etree_parse and etree_iterparse benchmarks are working appropriately

2018-12-14 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +10409

___
Python tracker 

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



[issue35502] Memory leak in xml.etree.ElementTree.iterparse

2018-12-14 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

The problem was with detecting a reference cycle containing a TreeBuilder.

--
nosy: +eli.bendersky, scoder
versions: +Python 3.8

___
Python tracker 

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



[issue35502] Memory leak in xml.etree.ElementTree.iterparse

2018-12-14 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue35495] argparse does not honor default argument for nargs=argparse.REMAINDER argument

2018-12-14 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
nosy: +bethard
stage:  -> test needed
versions: +Python 3.8 -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



[issue35492] Missing colon on func statement in library/sys doc

2018-12-14 Thread Terry J. Reedy


Change by Terry J. Reedy :


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



[issue35486] subprocess module import hooks breaks back compatibility

2018-12-14 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
nosy: +brett.cannon, eric.snow, ncoghlan
stage:  -> test needed
title: subprocess module breaks backwards compatibility with import hooks -> 
subprocess module import hooks breaks back compatibility
type:  -> behavior

___
Python tracker 

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



[issue35482] python372rc1.chm is ill

2018-12-14 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
components: +Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware

___
Python tracker 

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



[issue35480] argparse: add a full fledged parser as a subparser

2018-12-14 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I presume you mean to close this.

--
nosy: +terry.reedy
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



[issue35472] python 3.7.2 rc1 bumped the build requirements for no reason

2018-12-14 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Should we add '(subject to change in any release)' after
# Require Sphinx 1.7 for build.

Matthias, I presume you are on some Linux. Would a script to temporarily change 
conf.py to build the docs work for you?

To be reasonably sure that 1.6.6 is sufficient for all translations on all 
systems that care, I would think it should be part of a .rc release first.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue35502] Memory leak in xml.etree.ElementTree.iterparse

2018-12-14 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue35503] os.path.islink() works with cygwin installation but not python.org

2018-12-14 Thread pmpp


pmpp  added the comment:

afaik only cygwin and msys2 python flavours can handle *various* links and 
junctions. ( usefull tool 
http://schinagl.priv.at/nt/hardlinkshellext/linkshellextension.html )

and testing symlinks is may be disabled in MSVCRT paths 
https://github.com/python/cpython/pull/10245/files#diff-2b0d47b7b6809ae1bd1d7fd0c4e36e00R246
 as some comment suggest.

--
nosy: +pmpp

___
Python tracker 

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



[issue35503] os.path.islink() works with cygwin installation but not python.org

2018-12-14 Thread Benjamin Ward


New submission from Benjamin Ward :

I have python.org's Python27 installed on my laptop.  In my Documnets/tmp 
folder/directory I created three "directories" (see below) and performed 
os.path.islink() on all three.

in cmd window: (not dir output and prompt have be been shortened)

*\Documents\tmp>dir
 Volume in drive C is OS
 Volume Serial Number is B2BB-F7DA

 Directory of *\Documents\tmp
...
12/14/2018  12:37 PM  isDir
12/14/2018  12:37 PM isDirJunction 
[C:\Users\benjward\Documents\tmp\isDir]
12/14/2018  12:39 PM isDirSymbolicLink [isDir]
...

*** using system installed python.org python 2.7
*\Documents\tmp>where python
C:\Python27\python.exe

python
Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.islink('isDir')
False
>>> os.path.islink('isDirJunction')
False
>>> os.path.islink('isDirSymlink')
False
>>>

*** but ..., using cygwin64 installation of python 2.7
*\Documents\tmp>C:\cygwin64\bin\python2.7
Python 2.7.14 (default, Oct 31 2017, 21:12:13)
[GCC 6.4.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.islink('isDir')
False
>>> os.path.islink('isDirJunction')
True
>>> os.path.islink('isDirSymlink')
True
>>>

The latter result is what I was expecting.  Granted, my cygwin python is 2.7.14 
and system installation is 2.7.15, but is it likely that a capability was lost?

--
messages: 331871
nosy: bward
priority: normal
severity: normal
status: open
title: os.path.islink() works with cygwin installation but not python.org
type: behavior
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



[issue35457] robotparser reads empty robots.txt file as "all denied"

2018-12-14 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

https://docs.python.org/2.7/library/robotparser.html#module-robotparser
and
https://docs.python.org/3/library/urllib.robotparser.html#module-urllib.robotparser
refers users, for file structure, to http://www.robotstxt.org/orig.html.
This says nothing about the effect of an empty file, so I don't see this as a 
bug.  Even if it was, I would be dubious about reversing the effect without a 
deprecation notice first, and definitely not in 2.7.

I would propose instead that the doc be changed to refer to the new file, with 
more and better examples, but add a note that robotparser interprets empty 
files as 'block all' rather than 'allow all'.

Try bringing this up on python-ideas.

--
nosy: +terry.reedy
stage:  -> test needed
type: behavior -> enhancement
versions: +Python 3.8 -Python 2.7

___
Python tracker 

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



[issue35453] pathlib.Path: glob and rglob should accept PathLike patterns

2018-12-14 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
stage:  -> test needed
type:  -> enhancement
versions: +Python 3.8 -Python 3.7

___
Python tracker 

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



[issue35450] venv module doesn't create a copy of python binary by default

2018-12-14 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Close this?

--
nosy: +terry.reedy
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



[issue35449] documenting objects

2018-12-14 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The reason that modules, classes, and functions need a special rule for 
assigning the .__doc__ attribute is that one cannot get a reference to the 
module, class, or function within the body of its definition.  And putting the 
docstring at the top of a file or after a header is usually the best place.

For modules, the body is the file, leaving nowhere else to put the docstring.  
For classes and functions, the alternative of an assignment elsewhere, after 
the object is created, remains.

>>> def f(): pass

>>> f.__doc__ = 'Docstring outside f body'
>>> help(f)
Help on function f in module __main__:

f()
Docstring outside f body

This alternative is used in functools.partial and decorators that wrap 
functions with a function and then copy the original docstring to the wrapper.

I think object.doc = 'docstring' is sufficient for other objects and that PEP 
224 was wrong to propose otherwise and should have been rejected.

So I think that this issue should propose what Steven said:  pydoc/help() 
should be simplified to fetch object.__doc__ with normal lookup, instead of 
bypassing object if not one of the special types.  Stefan Seefeld, can you try 
patching pydoc to do this?

If one wants to add docstrings to builtins, a subclass can work.

>>> class Docint(int): pass

>>> i,j = Docint(1), Docint(2)
>>> i+j
3
>>> i.__doc__ = 'one'

We just need help to print i.__doc__ instead of int.__doc__.

--
nosy: +terry.reedy
stage:  -> test needed
versions: +Python 3.8

___
Python tracker 

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



[issue35257] Avoid leaking linker flags into distutils: add PY_LDFLAGS_NODIST

2018-12-14 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +10406

___
Python tracker 

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



[issue35450] venv module doesn't create a copy of python binary by default

2018-12-14 Thread Brett Cannon


Brett Cannon  added the comment:


New changeset d5176fe2bcd35dc8d70d13220b58fa7ccd05b47a by Brett Cannon (Miss 
Islington (bot)) in branch '3.7':
bpo-35450: reflect in docs that venv module is not always creating a copy of 
the Python binary (GH-11144) (GH-11167)
https://github.com/python/cpython/commit/d5176fe2bcd35dc8d70d13220b58fa7ccd05b47a


--

___
Python tracker 

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



[issue35450] venv module doesn't create a copy of python binary by default

2018-12-14 Thread Brett Cannon


Brett Cannon  added the comment:


New changeset 1fb312ce1f147ea84ecb6f5993a20d1a85c53dc3 by Brett Cannon (Miss 
Islington (bot)) in branch '3.6':
bpo-35450: reflect in docs that venv module is not always creating a copy of 
the Python binary (GH-11144) (GH-11168)
https://github.com/python/cpython/commit/1fb312ce1f147ea84ecb6f5993a20d1a85c53dc3


--

___
Python tracker 

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



[issue35450] venv module doesn't create a copy of python binary by default

2018-12-14 Thread miss-islington


Change by miss-islington :


--
pull_requests: +10405

___
Python tracker 

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



[issue35450] venv module doesn't create a copy of python binary by default

2018-12-14 Thread miss-islington


Change by miss-islington :


--
pull_requests: +10404

___
Python tracker 

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



[issue35450] venv module doesn't create a copy of python binary by default

2018-12-14 Thread miss-islington

miss-islington  added the comment:


New changeset f5107dfd42121ef40b13eb678705802f0ff02cf9 by Miss Islington (bot) 
(mkkot) in branch 'master':
bpo-35450: reflect in docs that venv module is not always creating a … 
(GH-11144)
https://github.com/python/cpython/commit/f5107dfd42121ef40b13eb678705802f0ff02cf9


--
nosy: +miss-islington

___
Python tracker 

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



[issue35502] Memory leak in xml.etree.ElementTree.iterparse

2018-12-14 Thread STINNER Victor


STINNER Victor  added the comment:

Oops, there was a typo, you should read kB:

1 calls: 15.3 kB / call (total: 15.3 kB)
100 calls: 15.3 kB / call (total: 1527.7 kB)
1000 calls: 15.3 kB / call (total: 15265.0 kB)

--
Added file: https://bugs.python.org/file47999/run2.py

___
Python tracker 

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



[issue35502] Memory leak in xml.etree.ElementTree.iterparse

2018-12-14 Thread STINNER Victor


Change by STINNER Victor :


Removed file: https://bugs.python.org/file47998/run.py

___
Python tracker 

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



[issue35502] Memory leak in xml.etree.ElementTree.iterparse

2018-12-14 Thread STINNER Victor


STINNER Victor  added the comment:

I wrote attached run.py which confirms a leak using tracemalloc:

$ python3 run.py 
1 calls: 15.3B / call (total: 15.3 kB)
100 calls: 15.3B / call (total: 1527.7 kB)
1000 calls: 15.3B / call (total: 15265.0 kB)

--
nosy: +vstinner
Added file: https://bugs.python.org/file47998/run.py

___
Python tracker 

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



[issue35448] ConfigParser .read() - handling of nonexistent files

2018-12-14 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Since the code and doc agree, and since the proposal is to add a call 
parameter, this would be an enhancement for next release only, not a bug fix.

The proposal seems reasonable.  I might use it for IDLE.

IDLE uses .read within this subclass method.

def Load(self):
"Load the configuration file from disk."
if self.file:  # '' for at least some tests
self.read(self.file) 

The default config files in idlelib should be present.  (I should see what 
happens if not.  Does every 'get' pass a seeming redundant and possibly 
inconsistent backup default?)  I might use the new parameter here.  

User override config files and even the config directory are optional, so the 
current behavior is fine.

--
nosy: +terry.reedy
stage:  -> test needed
type: behavior -> enhancement
versions: +Python 3.8

___
Python tracker 

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



[issue32810] Expose ags_gen and agt_gen in asynchronous generators

2018-12-14 Thread Zackery Spytz


Zackery Spytz  added the comment:

I've created a PR for this issue.

--
nosy: +ZackerySpytz
versions: +Python 3.8 -Python 3.7

___
Python tracker 

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



[issue35502] Memory leak in xml.etree.ElementTree.iterparse

2018-12-14 Thread Jess Johnson


New submission from Jess Johnson :

When given xml that that would raise a ParseError, but parsing is stopped 
before the ParseError is raised, xml.etree.ElementTree.iterparse leaks memory.

Example:


import gc
from io import StringIO
import xml.etree.ElementTree as etree

import objgraph


def parse_xml():
xml = """
  
  

"""
parser = etree.iterparse(StringIO(initial_value=xml))
for _, elem in parser:
if elem.tag == 'LEVEL1':
break


def run():
parse_xml()

gc.collect()
uncollected_elems = objgraph.by_type('Element')
print(uncollected_elems)
objgraph.show_backrefs(uncollected_elems, max_depth=15)


if __name__ == "__main__":
run()


Output:
[]

Also see this gist which has an image showing the objects that are retained in 
memory: https://gist.github.com/grokcode/f89d5c5f1831c6bc373be6494f843de3

--
components: XML
messages: 331861
nosy: jess.j
priority: normal
severity: normal
status: open
title: Memory leak in xml.etree.ElementTree.iterparse
type: resource usage
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



[issue32810] Expose ags_gen and agt_gen in asynchronous generators

2018-12-14 Thread Zackery Spytz


Change by Zackery Spytz :


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

___
Python tracker 

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



[issue35431] Add a function for computing binomial coefficients to the math module

2018-12-14 Thread Tim Peters


Tim Peters  added the comment:

Just for fun, here's a gonzo implementation (without arg-checking) using ideas 
from the sketch.  All factors of 2 are shifted out first, and all divisions are 
done before any multiplies.

For large arguments, this can run much faster than a dumb loop.  For example, 
combp(10**100, 400) takes about a quarter the time of a dumb-loop 
divide-each-time-thru implementation.

# Return number of trailing zeroes in `n`.
def tzc(n):
result = 0
if n:
mask = 1
while n & mask == 0:
result += 1
mask <<= 1
return result

# Return exponent of prime `p` in prime factorization of
# factorial(k).
def facexp(k, p):
result = 0
k //= p
while k:
result += k
k //= p
return result

def combp(n, k):
from heapq import heappop, heapify, heapreplace

if n-k < k:
k = n-k
if k == 0:
return 1
if k == 1:
return n
firstnum = n - k + 1
nums = list(range(firstnum, n+1))
assert len(nums) == k

# Shift all factors of 2 out of numerators.
shift2 = 0
for i in range(firstnum & 1, k, 2):
val = nums[i]
c = tzc(val)
assert c
nums[i] = val >> c
shift2 += c
shift2 -= facexp(k, 2) # cancel all 2's in factorial(k)
assert shift2 >= 0

# Any prime generator is fine here.  `k` can't be
# huge, and we only want the primes through `k`.
pgen = psieve()
p = next(pgen)
assert p == 2

for p in pgen:
if p > k:
break
pcount = facexp(k, p)
assert pcount
# Divide that many p's out of numerators.
i = firstnum % p
if i:
i = p - i
for i in range(i, k, p):
val, r = divmod(nums[i], p)
assert r == 0
pcount -= 1
while pcount:
val2, r = divmod(val, p)
if r:
break
else:
val = val2
pcount -= 1
nums[i] = val
if pcount == 0:
break
assert pcount == 0

heapify(nums)
while len(nums) > 1:
a = heappop(nums)
heapreplace(nums, a * nums[0])
return nums[0] << shift2

I'm NOT suggesting to adopt this.  Just for history in the unlikely case 
there's worldwide demand for faster `comb` of silly arguments ;-)

--

___
Python tracker 

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



[issue35441] Dead (and buggy) code due to mishandling of PyList_SetItem() errors

2018-12-14 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Needed to backport it to 2.7.

--

___
Python tracker 

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



[issue35442] Chain of several subcommands in argparse

2018-12-14 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

A better place to discuss format and API is python-ideas list.  Almost 
certainly will see responses there.

--
nosy: +terry.reedy
stage:  -> test needed
versions: +Python 3.8

___
Python tracker 

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



[issue35499] "make profile-opt" overrides CFLAGS_NODIST

2018-12-14 Thread STINNER Victor


STINNER Victor  added the comment:

I also tested CFLAGS, just in case.

Current behavior:

$ git clean -fdx
$ ./configure --with-pydebug
$ make profile-opt CFLAGS="-O1"
(...)
gcc -pthread -c -Wno-unused-result -Wsign-compare -g -Og -Wall  -O1  -std=c99 
-Wextra -Wno-unused-result -Wno-unused-parameter 
-Wno-missing-field-initializers -Werror=implicit-function-declaration 
-fprofile-generate -I./Include/internal  -I. -I./Include-DPy_BUILD_CORE -o 
Programs/python.o ./Programs/python.c
(...)

=> CFLAGS is respected: I see -O1 in the command line.


With PR 11164:

$ git clean -fdx
$ ./configure --with-pydebug
$ make profile-opt CFLAGS="-O1"
(...)
gcc -pthread -c -Wno-unused-result -Wsign-compare -g -Og -Wall  -O1  -std=c99 
-Wextra -Wno-unused-result -Wno-unused-parameter 
-Wno-missing-field-initializers -Werror=implicit-function-declaration 
-fprofile-generate -I./Include/internal  -I. -I./Include-DPy_BUILD_CORE -o 
Programs/python.o ./Programs/python.c
(...)

=> CFLAGS is respected: I see -O1 in the command line.

--

___
Python tracker 

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



[issue35441] Dead (and buggy) code due to mishandling of PyList_SetItem() errors

2018-12-14 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Can this be closed?

--
nosy: +terry.reedy

___
Python tracker 

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



[issue35498] Parents objects in pathlib.Path don't support slices as __getitem__ arguments

2018-12-14 Thread Joshua Cannon


Joshua Cannon  added the comment:

If it is deemed a bug which needs to be fixed, I've gone ahead and attached the 
PR to fix it.

CLA signage is pending approval at the company I work for, with most people out 
for the holidays (so it might be a day or two turnaround).

--

___
Python tracker 

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



[issue35498] Parents objects in pathlib.Path don't support slices as __getitem__ arguments

2018-12-14 Thread Joshua Cannon


Change by Joshua Cannon :


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

___
Python tracker 

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



[issue35257] Avoid leaking linker flags into distutils: add PY_LDFLAGS_NODIST

2018-12-14 Thread STINNER Victor


STINNER Victor  added the comment:

See also:

* bpo-35499: "make profile-opt" overrides CFLAGS_NODIST 
* bpo-35501: "make coverage" should use leak coverage flags to third party C 
extensions.

--

___
Python tracker 

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



[issue35499] "make profile-opt" overrides CFLAGS_NODIST

2018-12-14 Thread STINNER Victor


STINNER Victor  added the comment:

I wrote PR 11164 to fix the issue.

Example:

$ git clean -fdx
$ ./configure --with-pydebug
$ make profile-opt CFLAGS_NODIST="-O1"
(...)
gcc -pthread -c -Wno-unused-result -Wsign-compare -g -Og -Wall-std=c99 
-Wextra -Wno-unused-result -Wno-unused-parameter 
-Wno-missing-field-initializers -Werror=implicit-function-declaration 
-fprofile-generate -I./Include/internal  -I. -I./Include-DPy_BUILD_CORE -o 
Programs/python.o ./Programs/python.c
(...)

=> CFLAGS_NODIST is missing: I don't see -O1 in the command line.


With my change:

$ git clean -fdx
$ ./configure --with-pydebug
$ make profile-opt CFLAGS_NODIST="-O1"
(...)
gcc -pthread -c -Wno-unused-result -Wsign-compare -g -Og -Wall-std=c99 
-Wextra -Wno-unused-result -Wno-unused-parameter 
-Wno-missing-field-initializers -Werror=implicit-function-declaration -O1 
-fprofile-generate -I./Include/internal  -I. -I./Include-DPy_BUILD_CORE -o 
Programs/python.o ./Programs/python.c
(...)

=> CFLAGS_NODIST is used: I see "-O1" in the command line.

--

___
Python tracker 

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



[issue35501] "make coverage" should use leak coverage flags to third party C extensions

2018-12-14 Thread STINNER Victor


New submission from STINNER Victor :

"make coverage" modifies CFLAGS and LIBS, Makefile.pre.in:

coverage:
@echo "Building with support for coverage checking:"
$(MAKE) clean profile-removal
$(MAKE) @DEF_MAKE_RULE@ CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs 
-ftest-coverage" LIBS="$(LIBS) -lgcov"

CFLAGS_NODIST should be used instead here. I'm not sure about LIBS: do we need 
LIBS_NODIST, as we have CFLAGS_NODIST? LIBS_NODIST would be used for Python and 
C extensions of the stdlib, but not for third-party C extensions: not used by 
distutils.


See also bpo-35257: "Avoid leaking linker flags into distutils: add 
PY_LDFLAGS_NODIST".

--
components: Build
messages: 331850
nosy: vstinner
priority: normal
severity: normal
status: open
title: "make coverage" should use leak coverage flags to third party C 
extensions
versions: Python 3.8

___
Python tracker 

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



[issue35500] Align expected and actual calls on mock.assert_called_with error message

2018-12-14 Thread Karthikeyan Singaravelan


New submission from Karthikeyan Singaravelan :

Currently, assert_called_with has expected calls list in the same line with 
AssertionError that causes the visualizing the difference to be hard. It will 
be great if Expected call occurs on the next line so that the diff is improved. 
The change has to be made at 
https://github.com/python/cpython/blob/f8e9bd568adf85c1e4aea1dda542a96b027797e2/Lib/unittest/mock.py#L749
 .

from unittest import mock

m = mock.Mock()
m(1, 2)
m.assert_called_with(2, 3)

Current output : 

Traceback (most recent call last):
  File "/tmp/bar.py", line 5, in 
m.assert_called_with(2, 3)
  File 
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/mock.py",
 line 820, in assert_called_with
raise AssertionError(_error_message()) from cause
AssertionError: Expected call: mock(2, 3)
Actual call: mock(1, 2)

Proposed output : 

Traceback (most recent call last):
  File "/tmp/bar.py", line 5, in 
m.assert_called_with(2, 3)
  File 
"/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/unittest/mock.py", 
line 827, in assert_called_with
raise AssertionError(_error_message()) from cause
AssertionError:
Expected call: mock(2, 3)
Actual call: mock(1, 2)

Some more alignment with the call list starting in the same column

AssertionError:
Expected call: mock(2, 3)
Actual call:   mock(1, 2)


Originally reported in the GitHub repo at 
https://github.com/testing-cabal/mock/issues/424 . PR for this was closed since 
GitHub is used only for backporting 
(https://github.com/testing-cabal/mock/pull/425). I thought to report it here 
for discussion. Currently call list output is as per proposed output.

AssertionError: Calls not found.
Expected: [call(1, 2, 3)]
Actual: [call(1, 2)].

--
components: Library (Lib)
messages: 331849
nosy: cjw296, mariocj89, michael.foord, xtreak
priority: normal
severity: normal
status: open
title: Align expected and actual calls on mock.assert_called_with error message
type: enhancement
versions: Python 3.8

___
Python tracker 

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



[issue35499] "make profile-opt" overrides CFLAGS_NODIST

2018-12-14 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue26415] Excessive peak memory consumption by the Python parser

2018-12-14 Thread A. Skrobov


A. Skrobov  added the comment:

I've run pyperformance (0.7.0) with my updated patch, and posted results at the 
PR page. They look encouraging enough.

--

___
Python tracker 

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



[issue35499] "make profile-opt" overrides CFLAGS_NODIST

2018-12-14 Thread STINNER Victor


New submission from STINNER Victor :

Makefile.pre.in contains the rule:

build_all_generate_profile:
$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_GEN_FLAG)" 
LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG)" LIBS="$(LIBS)"

I'm not sure that CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_GEN_FLAG)" is correct: it 
overrides user $CFLAGS_NODIST variable. I suggest to replace it with 
CFLAGS_NODIST="$(CFLAGS_NODIST) $(PGO_PROF_GEN_FLAG)": add $(PGO_PROF_GEN_FLAG) 
to CFLAGS_NODIST, don't copy $CFLAGS to $CFLAGS_NODIST (and add 
$(PGO_PROF_GEN_FLAG)).

The code comes from bpo-23390:

commit 2f90aa63666308e7a9b2d0a89110e0be445a393a
Author: Gregory P. Smith 
Date:   Wed Feb 4 02:11:56 2015 -0800

Fixes issue23390: make profile-opt causes -fprofile-generate and related 
flags
to end up in distutils CFLAGS.

(...)
 build_all_generate_profile:
-   $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-generate" LIBS="$(LIBS) -lgcov"
+   $(MAKE) all CFLAGS_NODIST="$(CFLAGS) -fprofile-generate" 
LDFLAGS="-fprofile-generate" LIBS="$(LIBS) -lgcov"
(...)


CFLAGS_NODIST has been added by bpo-21121:

commit acb8c5234302f8057b331abaafb2cc8697daf58f
Author: Benjamin Peterson 
Date:   Sat Aug 9 20:01:49 2014 -0700

add -Werror=declaration-after-statement only to stdlib extension modules 
(closes #21121)

Patch from Stefan Krah.


This issue is related to bpo-35257: "Avoid leaking linker flags into distutils: 
add PY_LDFLAGS_NODIST".

--
components: Build
messages: 331847
nosy: vstinner
priority: normal
severity: normal
status: open
title: "make profile-opt" overrides CFLAGS_NODIST
versions: Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue27715] call-matcher breaks if a method is mocked with spec=True

2018-12-14 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

I think the original issue with patch.object reported by Carl is different from 
the one reported by David for autospec. Analyzed the report by David and When 
we call autospec on a class with instance=True then the spec is modeled on the 
signature of __call__ instead of __init__ where __call__ has the signature of 
(self, x) and self is  discarded with _eat_self passed as True. But mock also 
stores _spec_signature that is not aware of skipping self and has the signature 
as (self, x) and is used for checking signature in mock.assert_called_with. 
When instance=True then kwargs['_spec_as_instance']=True so does it makes sense 
to set kwargs['_eat_self'] = True at [0] ? I applied the change and there are 
no test failures so this deserves a test.

This makes __call__ to have a different signature when it's called from mock 
and when the call is checked with assert_called_with_once. But it's not the 
case for methods of the class where self is skipped both for mock and 
_spec_signature. Since __signature__ is set for mock with my PR this makes it 
little easy to debug. Can this be dealt as a separate issue?

I would also love to see if the assertion message can be improved since 
expected_call and actual_call are printed with repr version of the call object 
in spite of the signature failure. This has caused confusion here and in other 
places like issue26752 and issue25312.

Sample program to demonstrate difference in signatures :  

import inspect
from unittest import mock

class Foo:

def __call__(self, x):
return x

def bar(self, x):
pass

m = mock.create_autospec(Foo, instance=True)
m(7)
m.bar(7)
print(inspect.signature(m))
print(m._spec_signature)
print(inspect.signature(m.bar))
print(m.bar._spec_signature)
m.bar.assert_called_once_with(7) # 7 passed as self with no value for x
m.assert_called_once_with(7) # Fails due to self

(x)
(self, x) # self is not skipped in _spec_signature
(x)
(x)
TypeError: missing a required argument: 'x'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "../backups/bpo27715_1.py", line 20, in 
m.assert_called_once_with(7)
  File 
"/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/unittest/mock.py", 
line 840, in assert_called_once_with
return self.assert_called_with(*args, **kwargs)
  File 
"/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/unittest/mock.py", 
line 827, in assert_called_with
raise AssertionError(_error_message()) from cause
AssertionError: Expected call: mock(7)
Actual call: mock(7)


[0] 
https://github.com/python/cpython/blob/f8e9bd568adf85c1e4aea1dda542a96b027797e2/Lib/unittest/mock.py#L2199

--
nosy: +cjw296, mariocj89
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



[issue35257] Avoid leaking linker flags into distutils: add PY_LDFLAGS_NODIST

2018-12-14 Thread STINNER Victor


STINNER Victor  added the comment:

There are multiple ways to configure and build Python, we should try most 
combinations:

* ./configure --enable-shared
* ./configure --with-lto
* ./configure --enable-optimizations
* make profile-opt
* make
* Maybe also: make install

Test:

* Build Python and make sure that python binary and C extensions (of the 
stdlib) are compiled with LTO
* python-config --cflags and python-config --ldflags don't leak LTO flags
* Build a C extension (Pillow) and check that there is no LTO flag in the 
command lines

I'm not how to test cross-compilation :-(

--

___
Python tracker 

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



[issue35402] Upgrade macOS and Windows installers to Tcl 8.6.9 and Tk 8.6.9.1

2018-12-14 Thread Steve Dower


Steve Dower  added the comment:


New changeset 77824ef6e50e8a47a0b57df2d9f3b48bffd414ac by Steve Dower (Miss 
Islington (bot)) in branch '3.7':
bpo-35402: Update Windows build to use Tcl and Tk 8.6.9 (GH-11146)
https://github.com/python/cpython/commit/77824ef6e50e8a47a0b57df2d9f3b48bffd414ac


--

___
Python tracker 

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



[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread STINNER Victor


STINNER Victor  added the comment:

I don't understand the purpose of the 'linkage' information of 
platform.architecture(). Does anyone care if Python is an ELF program or a 
WindowsPE program? Maybe it was useful 20 years ago when there were COFF on 
Unix, but right now ELF is the defacto standard on Unix, and WindowsPE on 
Windows.

32-bit and 64-bit information should be enough, no?

I would suggest to just return ('%sbit' % bits, '') if executable is not set. 
Use struct.calcsize('P')*8 or sys.maxsize to get bits.

--

___
Python tracker 

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



[issue35402] Upgrade macOS and Windows installers to Tcl 8.6.9 and Tk 8.6.9.1

2018-12-14 Thread miss-islington


Change by miss-islington :


--
pull_requests: +10399

___
Python tracker 

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



[issue35402] Upgrade macOS and Windows installers to Tcl 8.6.9 and Tk 8.6.9.1

2018-12-14 Thread Steve Dower


Steve Dower  added the comment:


New changeset f8e9bd568adf85c1e4aea1dda542a96b027797e2 by Steve Dower in branch 
'master':
bpo-35402: Update Windows build to use Tcl and Tk 8.6.9 (GH-11146)
https://github.com/python/cpython/commit/f8e9bd568adf85c1e4aea1dda542a96b027797e2


--

___
Python tracker 

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



[issue35412] test_future4 ran no test

2018-12-14 Thread STINNER Victor


Change by STINNER Victor :


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



[issue35498] Parents objects in pathlib.Path don't support slices as __getitem__ arguments

2018-12-14 Thread Joshua Cannon


New submission from Joshua Cannon :

I would expect the following to work:
```
>>> import pathlib
>>> pathlib.Path.cwd().parents[0:1]
Traceback (most recent call last):
  File "", line 1, in 
  File "...\Python36\lib\pathlib.py", line 593, in __getitem__
if idx < 0 or idx >= len(self):
TypeError: '<' not supported between instances of 'slice' and 'int'
```

Since pathlib documents `parents` as a sequence-type, and slicing a sequence is 
pretty standard behavior.

--
components: Library (Lib)
messages: 331841
nosy: thejcannon
priority: normal
severity: normal
status: open
title: Parents objects in pathlib.Path don't support slices as __getitem__ 
arguments
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



[issue35497] Libary select docs enhance

2018-12-14 Thread Manjusaka


Change by Manjusaka :


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

___
Python tracker 

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



[issue35497] Libary select docs enhance

2018-12-14 Thread Manjusaka


New submission from Manjusaka :

Since Python 3.7, Python adds a mask variable named EPOLLEXCLUSIVE for 
select.epoll. The mask variable is supported by the Linux Kernel since Kernel 
4.5. So we can add a tip in this part of Python docs to notice the people the 
case.

--
components: Library (Lib)
messages: 331840
nosy: Manjusaka
priority: normal
severity: normal
status: open
title: Libary select docs enhance
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



[issue35494] Inaccurate error message for f-string

2018-12-14 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
type:  -> enhancement
versions: +Python 3.8 -Python 3.7

___
Python tracker 

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



[issue35494] Inaccurate error message for f-string

2018-12-14 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

PR 11161 uses an approach similar to issue33306.

--
dependencies: +Improving SyntaxError for unmatched parentheses

___
Python tracker 

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



[issue35494] Inaccurate error message for f-string

2018-12-14 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue35496] left-to-right violation in match order

2018-12-14 Thread Steve Newcomb


New submission from Steve Newcomb :

Documentation for the re module insists that matches are made left-to-right 
within the alternatives delimited by an "or* | group.  I seem to have found a 
case where the rightmost alternative is matched unless it (and only it) is 
commented out.  See attached script, which is self-explanatory.

--
files: left-to-right_violation_in_python3_re_match.py
messages: 331838
nosy: steve.newcomb
priority: normal
severity: normal
status: open
title: left-to-right violation in match order
type: behavior
versions: Python 3.6
Added file: 
https://bugs.python.org/file47997/left-to-right_violation_in_python3_re_match.py

___
Python tracker 

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



Smarter algo, was Re: 03 digression by brute force

2018-12-14 Thread Peter Otten
jf...@ms4.hinet.net wrote:

> Just for fun:-) On my ooold PC, it takes 0.047 seconds to run the
> following algorithm on the problem 'SNED + MORE == MONEY".

> def tenThousand(u, Cin):  # Cin == M
> global n
> if Cin == M:
> print(S, E, N, D, '+', M, O, R, E, '==', M, O, N, E, Y)
> n += 1

And it probably took under two minutes with the brute force approach.
So if you were only interested in the result the code below were efficient 
only if it took at most two more minutes to write it;)

But seriously, the next step is to generalize this to work with arbitrary 
additions...
More fun!


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


[issue35495] argparse does not honor default argument for nargs=argparse.REMAINDER argument

2018-12-14 Thread Ryan Govostes


Change by Ryan Govostes :


--
versions: +Python 2.7, 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



[issue35495] argparse does not honor default argument for nargs=argparse.REMAINDER argument

2018-12-14 Thread Ryan Govostes


New submission from Ryan Govostes :

import argparse
parser = argparse.ArgumentParser()
parser.add_argument('things', nargs=argparse.REMAINDER, default=['nothing'])
parser.parse_args([])
>>> Namespace(things=[])

Since there were no unparsed arguments remaining, the `default` setting for 
`things` should have been honored. However it silently ignores this setting.

If there's a reason why this wouldn't be desirable, it should raise an 
exception that the options aren't compatible.

--
components: Library (Lib)
messages: 331837
nosy: rgov
priority: normal
severity: normal
status: open
title: argparse does not honor default argument for nargs=argparse.REMAINDER 
argument
type: behavior

___
Python tracker 

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



[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

What result of platform.architecture() do you expect for an universal binary?

--

___
Python tracker 

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



[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

BTW. A related problem with platform.architecture() is that it doesn't know how 
to deal with fat binaries (such as those found on macOS).

As an example:

$  file /usr/bin/python
/usr/bin/python: Mach-O universal binary with 2 architectures: [i386:Mach-O 
executable i386] [x86_64:Mach-O 64-bit executable x86_64]
/usr/bin/python (for architecture i386):Mach-O executable i386
/usr/bin/python (for architecture x86_64):  Mach-O 64-bit executable x86_64

This will be reported as "64-bit" by platform.architecture() because there is 
'64-bit' in the output of file(1).

Using sizeof(void*) or sys.maxsize suffers from the a simular problem: this 
will only detect the pointer-size of the current proces and not that the binary 
is capable of running with a different pointer-size as well. 

P.S. platform.architecture() uses file(1) because you can specify different 
executables than sys.executable.

--
nosy: +ronaldoussoren

___
Python tracker 

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



[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

PR 11160 is an alternate solution which strips the filename in the output. It 
does not matter if the filename contains ":", because the format of the output 
in the POSIX locale is strictly specified.

--

___
Python tracker 

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



[issue35494] Inaccurate error message for f-string

2018-12-14 Thread Sebastian Linke


Sebastian Linke  added the comment:

The same behavior applies to f'{spam[}' and f'{spam(}'. Also to f'{spam{}', but 
that might be expected.

This message is more clear:
>>> f'{spam('
  File "", line 1
SyntaxError: f-string: mismatched '(', '{', or '['

Perhaps you want to apply that to the above error cases. Then you wouldn't have 
to catch any type of bracket. :-)

--

___
Python tracker 

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



[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +10396

___
Python tracker 

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



[issue35494] Inaccurate error message for f-string

2018-12-14 Thread Eric V. Smith


Eric V. Smith  added the comment:

Go ahead, Serhiy. Thanks!

--
assignee: eric.smith -> serhiy.storchaka

___
Python tracker 

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



[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread STINNER Victor


STINNER Victor  added the comment:

A convervative approach would be to leave stable branches unchanged and use -b 
in the master branch.

--

___
Python tracker 

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



[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread STINNER Victor


STINNER Victor  added the comment:

> We can also check that the output starts with executable+': ' and strip this 
> prefix.

Technically, on UNIX, ':' is valid in a filename. Filename examples which 
contain ':' on my Fedora 29:

/usr/share/man/man3/List::Util.3pm.gz
/usr/share/usb_modeswitch/0408:f000
/proc/irq/127/ahci[:00:17.0]
/proc/irq/131/snd_hda_intel:card0
/dev/block/259:3
/sys/kernel/slab/:0002632
/sys/module/psmouse/drivers/serio:psmouse

Note: I cannot find a program name which contains ':'.

--

___
Python tracker 

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



[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread STINNER Victor


STINNER Victor  added the comment:

In 2.7 branch, _syscmd_file() only used -b option during one day (no Python 
2.7.x release used -b):

* Oct 4, 2012: commit 95038fa526c8b93e42c59b0735edf1c80b7b6449 added -b: 
"Closes #16112: platform.architecture does not correctly escape argument to 
/usr/bin/file"
* Oct 5, 2012: commit 2699c9d24810196a07e0577215ec3beb7ecfb55b removed -b: 
"#16112: platform.architecture does not correctly escape argument to 
/usr/bin/file. Fix original patch"

Python 3.2.0 (Feb 2011) to 3.2.3 (Sep 2012) and Python 3.3.0 (Sep 2012) used -b:

* Aug 13, 2010: commit ddfb2c3a338a8c1550774648f816e96c41f59de1 added -b: "Omit 
the filename to avoid enconding issues, especially with non encodable 
characters in the Python full path."
* Oct 5, 2012: commit 685fffa8f427b3a768b232170752565d58c32112 removed -b: 
"#16112: platform.architecture does not correctly escape argument to 
/usr/bin/file. Fix original patch"

--

___
Python tracker 

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



[issue35494] Inaccurate error message for f-string

2018-12-14 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I can take this issue if you do not mind.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue35494] Inaccurate error message for f-string

2018-12-14 Thread Eric V. Smith


Change by Eric V. Smith :


--
assignee:  -> eric.smith
nosy: +eric.smith

___
Python tracker 

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



[issue35494] Inaccurate error message for f-string

2018-12-14 Thread Sebastian Linke


New submission from Sebastian Linke :

Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> spam = 'spam'
>>> f'{spam[0}'
  File "", line 1
SyntaxError: f-string: expecting '}'

The error message seems wrong because a "]" is missing rather than a "}".

--
components: Interpreter Core
messages: 331827
nosy: seblin
priority: normal
severity: normal
status: open
title: Inaccurate error message for f-string
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



[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I tested that the "-b" option is supported on Linux, *BSD and OpenIndiana. But 
it is not a part of POSIX. So perhaps we should fall back to "file" without 
"-b" if "file -b" failed.

We can also check that the output starts with executable+': ' and strip this 
prefix.

--

___
Python tracker 

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



[issue34279] RFC: issue a warning in regrtest when no tests have been executed?

2018-12-14 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 34b7c438b8dc0a1e7e23c9b2d7ce7f8a7c31b4f4 by Victor Stinner in 
branch '2.7':
bpo-34279: regrtest consider that skipped tests are ran (GH-11132) (GH-11158)
https://github.com/python/cpython/commit/34b7c438b8dc0a1e7e23c9b2d7ce7f8a7c31b4f4


--

___
Python tracker 

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



[issue35412] test_future4 ran no test

2018-12-14 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 34b7c438b8dc0a1e7e23c9b2d7ce7f8a7c31b4f4 by Victor Stinner in 
branch '2.7':
bpo-34279: regrtest consider that skipped tests are ran (GH-11132) (GH-11158)
https://github.com/python/cpython/commit/34b7c438b8dc0a1e7e23c9b2d7ce7f8a7c31b4f4


--

___
Python tracker 

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



[issue35424] multiprocessing.Pool: emit ResourceWarning

2018-12-14 Thread STINNER Victor


STINNER Victor  added the comment:

See this discussion:
[Python-Dev] Usage of the multiprocessing API and object lifetime
https://mail.python.org/pipermail/python-dev/2018-December/155946.html

--

___
Python tracker 

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



  1   2   >