Re: Where is the documentation for ','?

2016-09-16 Thread eryk sun
On Sat, Sep 17, 2016 at 2:05 AM, Peng Yu  wrote:
>
> I'm wondering where is the documentation for ',' as in the following usage.
>
> x = 1
> y = 2
> x, y = y, x
>
> I tried help(','). But there are too many ',' in it and I don't see in
> which section ',' is documented. Could anybody let me know? Thanks.

See help('ASSIGNMENT') where the "target list is a comma-separated
list of targets". See also help('TUPLELITERALS') and
help('SEQUENCES').
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28184] Trailing whitespace in C source code

2016-09-16 Thread Francisco Couzo

Changes by Francisco Couzo :


Added file: http://bugs.python.org/file44706/trailing_whitespace2.patch

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-09-16 Thread Tim Peters

Tim Peters added the comment:

Let me give complete code for the last idea, also forcing the scaling 
multiplication to use the correct context:

import decimal
c = decimal.DefaultContext.copy()
c.prec = 25
c.Emax = decimal.MAX_EMAX
c.Emin = decimal.MIN_EMIN

def erootn(x, e, n,
  D=decimal.Decimal,
  D2=decimal.Decimal(2),
  pow=c.power,
  sub=c.subtract,
  mul=c.multiply,
  div=c.divide):
g = x**(1.0/n) * 2.0**(e/n)
Dg = D(g)
return g - float(sub(Dg, div(mul(D(x), pow(D2, e)),
 pow(Dg, n-1 / n

del decimal, c

Both pow() instances use an integer exponent, so the C implementation of 
decimal still avoids expensive exp() and ln() computations - it's all just 
basic - * / under the covers.

On a 32-bit box, the scaled input (x*2**e) must be <= 9.999...999E42500, 
which is about 2**1411819443 (an exponent of about 1.4 billion).  On the 
close-to-0 side, approximately the reciprocals of those giant numbers.

The range is much wider on a 64-bit box (because Emax and Emin have much larger 
absolute values).

Then, e.g.,

>>> erootn(1, 1411819443, 1411819443)
2.0
>>> erootn(1, -1411819443, 1411819443)
0.5

So it's obviously perfect ;-)  Except that, because it reduces to the previous 
algorithm when e=0, Mark's counterexample (to correct rounding) still holds:

>>> erootn(1 + 2**-52, 0, 2)
1.0002

Boosting precision to 28 (from 25) is enough to repair that, but it doesn't 
bother me (there was never a claim that it was always correctly rounded - but 
at prec=25 it went through hours & hours of testing randomish inputs and `n` 
values without finding a less-than-perfect case - but those tests effectively 
always used e=0 too).

Basic error analysis for Newton's method usually goes like this:  suppose the 
true root is `t` and the current guess is `g = t*(1+e)` for some small `|e|`.  
Then plug `t*(1+e)` into the equation and do a Taylor expansion around e=0.  In 
this case, dropping terms at or above cubic in `e` leaves that the new guess is 
about

t*(1 + (n-1)/2 * e**2)

That the relative error goes from `e` to (about) `e**2` (which is typical of 
Newton's method) is the source of the claim that the number of good bits 
approximately doubles on each iteration.  In this specific case, it's not quite 
that good:  the (n-1)/2 factor means convergence becomes slower the larger `n` 
is.  But `e` in this case is perhaps on the order of 2**-50, and `(n-1)/2` 
times 2**-100 (e**2) remains tiny for any plausible value of `n`.

Good enough for me ;-)

--

___
Python tracker 

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



Re: Where is the documentation for ','?

2016-09-16 Thread Terry Reedy

On 9/16/2016 10:05 PM, Peng Yu wrote:

Hi,

I'm wondering where is the documentation for ',' as in the following usage.

x = 1
y = 2
x, y = y, x

I tried help(','). But there are too many ',' in it and I don't see in
which section ',' is documented. Could anybody let me know? Thanks.


It should be indexed on
https://docs.python.org/3/genindex-Symbols.html
but is not.  I will try to remember to fix it.


--
Terry Jan Reedy

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


[issue28184] Trailing whitespace in C source code

2016-09-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Modules/expat/expat.h and Modules/expat/expat_external.h are external files. 
They should left unchanged.

--
nosy: +ned.deily, serhiy.storchaka

___
Python tracker 

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



[issue28145] Fix whitespace in C source code

2016-09-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

See also issue15550 and issue8912.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue28185] Tabs in C source code

2016-09-16 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
dependencies: +Misleading Indentation in C source code
nosy: +serhiy.storchaka

___
Python tracker 

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



array.itemsize: Documentation Versus Reality

2016-09-16 Thread Lawrence D’Oliveiro
>>> a = array.array("I", (0,))
>>> a.itemsize
4
>>> a = array.array("L", (0,))
>>> a.itemsize
8

According to , the “minimum size” 
should be 2 and 4 respectively. It further says:

The actual representation of values is determined by the machine
architecture (strictly speaking, by the C implementation).
The actual size can be accessed through the itemsize attribute.

Are there any C compilers still in common use where the values will not be 4 
and 8, as above?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where is the documentation for ','?

2016-09-16 Thread Ben Finney
Peng Yu  writes:

> help(tuple) gives me this

Yes. That's the API definition for the ‘tuple’ type.

You were advised to search the documentation, not the interactive
help. You'll find the descriptions of “tuple” and even “tuple unpacking”
are what you want.

-- 
 \ “When I turned two I was really anxious, because I'd doubled my |
  `\   age in a year. I thought, if this keeps up, by the time I'm six |
_o__)  I'll be ninety.” —Steven Wright |
Ben Finney

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


[issue27806] 2.7 32-bit builds fail on macOS 10.12 Sierra due to dependency on deleted header file QuickTime/QuickTime.h

2016-09-16 Thread Ned Deily

Ned Deily added the comment:

Thanks, Alexander and especially Jeremy, for the reviews and suggestions.  
Thanks again sashk for the patches.  Committed for release in 2.7.13.

--
resolution:  -> fixed
stage: needs patch -> resolved
status: open -> closed
title: 2.7 32-bit builds fail on future releases of OS X due to dependency on 
deleted header file -> 2.7 32-bit builds fail on macOS 10.12 Sierra due to 
dependency on deleted header file QuickTime/QuickTime.h

___
Python tracker 

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



[issue26149] Suggest PyCharm Community as an editor for Unix platforms

2016-09-16 Thread Guido van Rossum

Guido van Rossum added the comment:

You did the right thing. Check out the "review" link.

--

___
Python tracker 

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



[issue27806] 2.7 32-bit builds fail on future releases of OS X due to dependency on deleted header file

2016-09-16 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 4030300fcb18 by sashk in branch '2.7':
Issue #27806: Fix 32-bit builds on macOS Sierra 10.12 broken by removal of
https://hg.python.org/cpython/rev/4030300fcb18

--
nosy: +python-dev

___
Python tracker 

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



Re: Where is the documentation for ','?

2016-09-16 Thread Nathan Ernst
The grammar and what it represents is defined at
https://docs.python.org/3/reference/expressions.html#expression-lists

Regards

On Sep 16, 2016 9:59 PM, "Peng Yu"  wrote:

> OK. But it is documented somewhere in python doc?
>
> On Fri, Sep 16, 2016 at 9:48 PM, Lawrence D’Oliveiro
>  wrote:
> > On Saturday, September 17, 2016 at 2:05:49 PM UTC+12, Peng Yu wrote:
> >> x, y = y, x
> >
> > It’s just syntactic sugar for
> >
> > (x, y) = (y, x)
> > --
> > https://mail.python.org/mailman/listinfo/python-list
>
>
>
> --
> Regards,
> Peng
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26149] Suggest PyCharm Community as an editor for Unix platforms

2016-09-16 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

Hmm.. not sure if I did this correctly. I uploaded another patch file, is this 
right? Or, how can I edit my original patch?
Thanks.

--

___
Python tracker 

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



[issue26149] Suggest PyCharm Community as an editor for Unix platforms

2016-09-16 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

Thanks for the feedback :)
As suggested, I removed all other IDEs and just link to the wiki.

--
Added file: http://bugs.python.org/file44705/docupdate2.patch

___
Python tracker 

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



Re: Where is the documentation for ','?

2016-09-16 Thread Peng Yu
OK. But it is documented somewhere in python doc?

On Fri, Sep 16, 2016 at 9:48 PM, Lawrence D’Oliveiro
 wrote:
> On Saturday, September 17, 2016 at 2:05:49 PM UTC+12, Peng Yu wrote:
>> x, y = y, x
>
> It’s just syntactic sugar for
>
> (x, y) = (y, x)
> --
> https://mail.python.org/mailman/listinfo/python-list



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


Re: Where is the documentation for ','?

2016-09-16 Thread Lawrence D’Oliveiro
On Saturday, September 17, 2016 at 2:05:49 PM UTC+12, Peng Yu wrote:
> x, y = y, x

It’s just syntactic sugar for

(x, y) = (y, x)
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28168] Use _winapi.WaitForMultipleObjects in Popen.wait()

2016-09-16 Thread STINNER Victor

STINNER Victor added the comment:

> I decided to make it an error to pass an empty sequence

It makes sense since the original WaitForMultipleObjects() also requires at 
least one object:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms687025(v=vs.85).aspx

nCount [in]

The number of object handles in the array pointed to by lpHandles. The 
maximum number of object handles is MAXIMUM_WAIT_OBJECTS. This parameter cannot 
be zero.

--

___
Python tracker 

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



[issue28168] Use _winapi.WaitForMultipleObjects in Popen.wait()

2016-09-16 Thread STINNER Victor

STINNER Victor added the comment:

Oh nice, you implemented the PEP 475 for _winapi.WaitForMultipleObjects()! I 
missed this function when implementing this PEP :-)

--
nosy: +haypo

___
Python tracker 

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



Is there something similar to `set -v` of bash in python

2016-09-16 Thread Peng Yu
Hi, `set -v` in bash allows the print of the command before print the
output of the command.

I want to do the similar thing --- print a python command and then
print the output of the command. Is it possible with python?

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


Re: Where is the documentation for ','?

2016-09-16 Thread Peng Yu
help(tuple) gives me this, which does not mention ',' either.

Help on class tuple in module __builtin__:

class tuple(object)
 |  tuple() -> empty tuple
 |  tuple(iterable) -> tuple initialized from iterable's items
 |
 |  If the argument is a tuple, the return value is the same object.
 |
 |  Methods defined here:
 |
 |  __add__(...)
 |  x.__add__(y) <==> x+y
 |
 |  __contains__(...)
 |  x.__contains__(y) <==> y in x
 |
 |  __eq__(...)
 |  x.__eq__(y) <==> x==y
 |
 |  __ge__(...)
 |  x.__ge__(y) <==> x>=y
 |
 |  __getattribute__(...)
 |  x.__getattribute__('name') <==> x.name
 |
 |  __getitem__(...)
 |  x.__getitem__(y) <==> x[y]
 |
 |  __getnewargs__(...)
 |
 |  __getslice__(...)
 |  x.__getslice__(i, j) <==> x[i:j]
 |
 |  Use of negative indices is not supported.
 |
 |  __gt__(...)
 |  x.__gt__(y) <==> x>y
 |
 |  __hash__(...)
 |  x.__hash__() <==> hash(x)
 |
 |  __iter__(...)
 |  x.__iter__() <==> iter(x)
 |
 |  __le__(...)
 |  x.__le__(y) <==> x<=y
 |
 |  __len__(...)
 |  x.__len__() <==> len(x)
 |
 |  __lt__(...)
 |  x.__lt__(y) <==> x x*n
 |
 |  __ne__(...)
 |  x.__ne__(y) <==> x!=y
 |
 |  __repr__(...)
 |  x.__repr__() <==> repr(x)
 |
 |  __rmul__(...)
 |  x.__rmul__(n) <==> n*x
 |
 |  count(...)
 |  T.count(value) -> integer -- return number of occurrences of value
 |
 |  index(...)
 |  T.index(value, [start, [stop]]) -> integer -- return first
index of value.
 |  Raises ValueError if the value is not present.
 |
 |  --
 |  Data and other attributes defined here:
 |
 |  __new__ = 
 |  T.__new__(S, ...) -> a new object with type S, a subtype of T



On Fri, Sep 16, 2016 at 9:13 PM, MRAB  wrote:
> On 2016-09-17 03:05, Peng Yu wrote:
>>
>> Hi,
>>
>> I'm wondering where is the documentation for ',' as in the following
>> usage.
>>
>> x = 1
>> y = 2
>> x, y = y, x
>>
>> I tried help(','). But there are too many ',' in it and I don't see in
>> which section ',' is documented. Could anybody let me know? Thanks.
>>
> Search for 'tuple' instead.
> --
> https://mail.python.org/mailman/listinfo/python-list



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


[issue28185] Tabs in C source code

2016-09-16 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +haypo

___
Python tracker 

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



Re: Where is the documentation for ','?

2016-09-16 Thread MRAB

On 2016-09-17 03:05, Peng Yu wrote:

Hi,

I'm wondering where is the documentation for ',' as in the following usage.

x = 1
y = 2
x, y = y, x

I tried help(','). But there are too many ',' in it and I don't see in
which section ',' is documented. Could anybody let me know? Thanks.


Search for 'tuple' instead.
--
https://mail.python.org/mailman/listinfo/python-list


Where is the documentation for ','?

2016-09-16 Thread Peng Yu
Hi,

I'm wondering where is the documentation for ',' as in the following usage.

x = 1
y = 2
x, y = y, x

I tried help(','). But there are too many ',' in it and I don't see in
which section ',' is documented. Could anybody let me know? Thanks.

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


[issue28185] Tabs in C source code

2016-09-16 Thread Francisco Couzo

Changes by Francisco Couzo :


Added file: http://bugs.python.org/file44704/tabs_h.patch

___
Python tracker 

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



[issue28185] Tabs in C source code

2016-09-16 Thread Francisco Couzo

Changes by Francisco Couzo :


Removed file: http://bugs.python.org/file44703/tabs_h.patch

___
Python tracker 

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



[issue28185] Tabs in C source code

2016-09-16 Thread Francisco Couzo

Changes by Francisco Couzo :


--
versions: +Python 3.7
Added file: http://bugs.python.org/file44703/tabs_h.patch

___
Python tracker 

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



Re: is it possible to adjust convex hull to draw blue line instead of green line?

2016-09-16 Thread MRAB

On 2016-09-17 01:20, meInvent bbird wrote:

i succeed to use code to draw green line, but green line not draw the
large area, expect second uploaded picture, the blue line connect
the bottom of red line graph


[snip]

Here's the code with the commented code and print statements removed and 
the indentation fixed:



im = img.copy()

for cnt in contours:
hull = cv2.convexHull(cnt, returnPoints=True)
previousx = 0
previousy = 0

for c in hull:
if previousx != 0 and previousy != 0 and c[0][0] != 0 and 
c[0][1] != 0 and abs(previousy - c[0][1]) > 10 and abs(c[0][0] - 
previousx) > 1:
cv2.line(im, (previousx, previousy), (c[0][0], c[0][1]), 
(0, 255, 0), 2)


previousx = c[0][0]
previousy = c[0][1]



https://drive.google.com/file/d/0Bxs_ao6uuBDUWVBFZzVIVGotRlk/view?usp=sharing

expected is

https://drive.google.com/file/d/0Bxs_ao6uuBDUNGZFS2F3WnJERzA/view?usp=sharing

I think the problem might be that you're setting previousx to c[0][0] 
and previousy to c[0][1] even if you don't draw the line (because of the 
indentation), so you get a series of unconnected lines.


I'm not sure whether you should be setting previousx and previousy to 0 
each time around the outer loop. I can't test it, but if the previous 
fix doesn't work, it's one more thing to try.

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


Re: how to automate java application in window using python

2016-09-16 Thread Lawrence D’Oliveiro
On Friday, September 16, 2016 at 10:22:34 PM UTC+12, Christian Gollwitzer wrote:
> "How do I automate a Java application using Python?"

Which is really a meaningless question. “Automation” is what computer programs 
do. (Assuming “application” is just another word for “program”.) If the program 
doesn’t work the way you expect, fix it.

But then, “automation” and “GUI” never really went together, did they 
 ...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: is it possible to adjust convex hull to draw blue line instead of green line?

2016-09-16 Thread Steve D'Aprano
On Sat, 17 Sep 2016 10:20 am, meInvent bbird wrote:

> i succeed to use code to draw green line, but green line not draw the
> large area, expect second uploaded picture, the blue line connect
> the bottom of red line graph


Please don't waste our time with dead code that has been commented out or
that doesn't do anything.

Here is your code with the commented out dead code removed. You should do
this, don't expect us to do it:


im = img.copy()
cntcounter = 0
for cnt in contours:
print("approx=" + str(approx))
cntcounter = cntcounter + 1
print("here1")
hull = cv2.convexHull(cnt,returnPoints = True)
print("here2")
while im is None:
# WARNING: THIS IS AN INFINITE LOOP
time.sleep(1)
if im is not None:
print("here3")
previousx = 0
previousy = 0 
for c in hull: 
if (previousx != 0 and previousy != 0 and c[0][0] != 0
and c[0][1] != 0 and abs(previousy - c[0][1]) > 10
and abs(c[0][0] - previousx) > 1
):
while im is None:
# WARNING: THIS IS AN INFINITE LOOP
time.sleep(1)
cv2.line(im, (previousx, previousy),
 (c[0][0], c[0][1]), (0, 255, 0), 2)
print("")
previousx = c[0][0]
previousy = c[0][1]




Now it is much easier to read without the noise.

Problems:

(1) img is not defined;

(2) approx is not defined;

(3) contours is not defined;

(4) cv2 is not defined;

(5) you have TWO possible infinite loops in your code;

(6) time is not defined, but this at least I can guess is the 
standard time module;

(7) c is not defined.


As given to us, we cannot run your code or understand it, because too many
things are undefined.

My **guess** is that cv2.line() will take an argument to set the line
colour. You should read the documentation for cv2.line().


Before asking any more questions, please read this:

http://sscce.org/






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

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


[issue28185] Tabs in C source code

2016-09-16 Thread Francisco Couzo

New submission from Francisco Couzo:

Files I didn't change: Python/dup2.c, Python/strdup.c (Since they are external 
dependencies)

--
files: tabs_c.patch
keywords: patch
messages: 276762
nosy: franciscouzo, josh.r, mark.dickinson, martin.panter, r.david.murray, 
terry.reedy
priority: normal
severity: normal
status: open
title: Tabs in C source code
Added file: http://bugs.python.org/file44702/tabs_c.patch

___
Python tracker 

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



[issue28184] Trailing whitespace in C source code

2016-09-16 Thread Francisco Couzo

New submission from Francisco Couzo:

As per Terry's recommendations (#28145), I'm going to open a new issue for each 
case.

--
files: trailing_whitespace.patch
keywords: patch
messages: 276761
nosy: franciscouzo, josh.r, mark.dickinson, martin.panter, r.david.murray, 
terry.reedy
priority: normal
severity: normal
status: open
title: Trailing whitespace in C source code
versions: Python 3.7
Added file: http://bugs.python.org/file44701/trailing_whitespace.patch

___
Python tracker 

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



is it possible to adjust convex hull to draw blue line instead of green line?

2016-09-16 Thread meInvent bbird
i succeed to use code to draw green line, but green line not draw the 
large area, expect second uploaded picture, the blue line connect
the bottom of red line graph

im = img.copy()
cntcounter = 0
for cnt in contours:
#epsilon = 0.1*cv2.arcLength(cnt,True)
#approx = cv2.approxPolyDP(cnt,epsilon,True)
#peri = cv2.arcLength(cnt, True)
#approx = cv2.approxPolyDP(cnt, 0.15 * peri, True)
#print("len(approx)="+str(len(approx)))
#if len(approx) == 2:
print("approx=" + str(approx))
cntcounter = cntcounter + 1
print("here1")
#x,y,w,h = cv2.boundingRect(cnt)
hull = cv2.convexHull(cnt,returnPoints = True)
print("here2")
while im is None:
time.sleep(1)
if im is not None:
print("here3")
#cv2.rectangle(im, (x,y), (x+w, y+h), (0,255,0), 2) 

#cv2.imwrite("C:\\Users\\tester\\Documents\\masda"+str(cntcounter)+".png",imi)  
  
#im = cv2.line(im,(x,y),(x+w,y),(0,255,0),2)
#im = cv2.line(im,(x+w,y),(x+w,y+h),(0,255,0),2)
#im = cv2.line(im,(x,y+h),(x+w,y+h),(0,255,0),2)
#im = cv2.line(im,(x,y),(x,y+h),(0,255,0),2)
previousx = 0
previousy = 0 
for c in hull: 
if previousx != 0 and previousy != 0 and c[0][0] != 0 and 
c[0][1] != 0 and abs(previousy - c[0][1]) > 10 and abs(c[0][0] - previousx) > 
1:
while im is None:
time.sleep(1)

cv2.line(im,(previousx,previousy),(c[0][0],c[0][1]),(0,255,0),2)
print("")
#print("previousx=" + str(previousx))
#print("previousy=" + str(previousy))
#print("c[0][0]=" + str(c[0][0]))
#print("c[0][1]=" + str(c[0][1]))
previousx = c[0][0]
previousy = c[0][1]



https://drive.google.com/file/d/0Bxs_ao6uuBDUWVBFZzVIVGotRlk/view?usp=sharing

expected is

https://drive.google.com/file/d/0Bxs_ao6uuBDUNGZFS2F3WnJERzA/view?usp=sharing
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: why this code loop forever after a draw a rectangle

2016-09-16 Thread meInvent bbird
after succeed to draw lines in graph,

however,

https://drive.google.com/file/d/0Bxs_ao6uuBDUWVBFZzVIVGotRlk/view?usp=sharing

expected the blue line connect the bottom of red line graph

https://drive.google.com/file/d/0Bxs_ao6uuBDUNGZFS2F3WnJERzA/view?usp=sharing

how can convex hull be adjusted to do like second graph of sky blue line


On Saturday, September 17, 2016 at 7:48:46 AM UTC+8, meInvent bbird wrote:
> img is the image
> 
> im is a new memory of image using  img.copy()
> 
> 
> On Saturday, September 17, 2016 at 7:46:42 AM UTC+8, meInvent bbird wrote:
> > thank you very much,
> > it out of the loop now.
> > because drawLine function return things
> > 
> > i just change drawLine to rectangle,
> > have not thought that rectangle not return thing, just edit the parameter
> > 
> > 
> > 
> > On Saturday, September 17, 2016 at 5:26:53 AM UTC+8, MRAB wrote:
> > > On 2016-09-16 20:14, Gary Herron wrote:
> > > > On 09/16/2016 04:24 AM, meInvent bbird wrote:
> > > >> im = img.copy()
> > > >> cntcounter = 0
> > > >> for cnt in contours:
> > > >>  epsilon = 0.1*cv2.arcLength(cnt,True)
> > > >>  approx = cv2.approxPolyDP(cnt,epsilon,True)   
> > > >>  #peri = cv2.arcLength(cnt, True)
> > > >>  #approx = cv2.approxPolyDP(c, 0.5 * peri, True)
> > > >>  #print("len(approx)="+str(len(approx)))
> > > >>  if len(approx) == 4:
> > > >>  print("approx=" + str(approx))
> > > >>  cntcounter = cntcounter + 1
> > > >>  print("here1")
> > > >>  x,y,w,h = cv2.boundingRect(cnt)
> > > >>  print("here2")
> > > >>  while im is None:
> > > >>  time.sleep(1)
> > > >>  if im is not None:
> > > >>  print("here3")
> > > >>  im = cv2.rectangle(im.copy(), (x,y), (x+w, y+h), 
> > > >> (0,255,0), 2)
> > > >>  #im = cv2.line(im,(x,y),(x+w,y),(0,255,0),2)
> > > >>  #im = cv2.line(im,(x+w,y),(x+w,y+h),(0,255,0),2)
> > > >>  #im = cv2.line(im,(x,y+h),(x+w,y+h),(0,255,0),2)
> > > >>  #im = cv2.line(im,(x,y),(x,y+h),(0,255,0),2)
> > > >>
> > > >>
> > > >> cv2.imwrite(r'C:\Users\tester\Documents\masda.png',im)
> > > >
> > > >
> > > > These two lines:
> > > >
> > > >while im is None:
> > > >  time.sleep(1)
> > > >
> > > > are an infinite loop if im is None;
> > > >
> > > >
> > > > Since you haven't told us what im (or img, contours, cv2) are, I can't
> > > > tell how im might become None, but it does look like you (confusingly)
> > > > use im for two different things:  an img.copy() and a cv2.rectangle,
> > > > whatever those may be.
> > > >
> > > > Pure guesswork:  if cv2.rectangle draws a rectangle, what does it
> > > > return?  If it doesn't return anything, the line
> > > >  im = cv2.rectangle(...)
> > > > is how im gets the value of None.
> > > >
> > > It looks like the OP is using OpenCV.
> > > 
> > > You're right about cv2.rectangle; it does return None.
> > > 
> > > The line:
> > > 
> > >  im = cv2.rectangle(im.copy(), (x,y), (x+w, y+h), (0,255,0), 2)
> > > 
> > > makes a copy of the image im, draws a rectangle on it, and then binds 
> > > None to im.
> > > 
> > > The copied rectangle is discarded because there's no reference to it, so 
> > > the entire line in pointless.
> > > 
> > > It basically does the same thing as:
> > > 
> > >  im = None
> > > 
> > > only slower!

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


[issue28168] Use _winapi.WaitForMultipleObjects in Popen.wait()

2016-09-16 Thread Eryk Sun

Eryk Sun added the comment:

Hopefully this is my last change until someone reviews this. I decided to make 
it an error to pass an empty sequence, which previously would implicitly wait 
on the SIGINT event. This way simplifies the code and prevents someone from 
accidentally waiting forever on SIGINT when it's ignored or doesn't raise an 
exception. There should always be at least 1 other handle in the wait list.

--
Added file: http://bugs.python.org/file44700/issue_28168_04.patch

___
Python tracker 

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



[issue27806] 2.7 32-bit builds fail on future releases of OS X due to dependency on deleted header file

2016-09-16 Thread sashk

sashk added the comment:

Ned, please see attached third version of the patch with workaround suggested 
by Jeremy for older versions of OS X.

--
Added file: http://bugs.python.org/file44699/issue27806_v3.patch

___
Python tracker 

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



Re: why this code loop forever after a draw a rectangle

2016-09-16 Thread meInvent bbird
img is the image

im is a new memory of image using  img.copy()


On Saturday, September 17, 2016 at 7:46:42 AM UTC+8, meInvent bbird wrote:
> thank you very much,
> it out of the loop now.
> because drawLine function return things
> 
> i just change drawLine to rectangle,
> have not thought that rectangle not return thing, just edit the parameter
> 
> 
> 
> On Saturday, September 17, 2016 at 5:26:53 AM UTC+8, MRAB wrote:
> > On 2016-09-16 20:14, Gary Herron wrote:
> > > On 09/16/2016 04:24 AM, meInvent bbird wrote:
> > >> im = img.copy()
> > >> cntcounter = 0
> > >> for cnt in contours:
> > >>  epsilon = 0.1*cv2.arcLength(cnt,True)
> > >>  approx = cv2.approxPolyDP(cnt,epsilon,True) 
> > >>  #peri = cv2.arcLength(cnt, True)
> > >>  #approx = cv2.approxPolyDP(c, 0.5 * peri, True)
> > >>  #print("len(approx)="+str(len(approx)))
> > >>  if len(approx) == 4:
> > >>  print("approx=" + str(approx))
> > >>  cntcounter = cntcounter + 1
> > >>  print("here1")
> > >>  x,y,w,h = cv2.boundingRect(cnt)
> > >>  print("here2")
> > >>  while im is None:
> > >>  time.sleep(1)
> > >>  if im is not None:
> > >>  print("here3")
> > >>  im = cv2.rectangle(im.copy(), (x,y), (x+w, y+h), 
> > >> (0,255,0), 2)
> > >>  #im = cv2.line(im,(x,y),(x+w,y),(0,255,0),2)
> > >>  #im = cv2.line(im,(x+w,y),(x+w,y+h),(0,255,0),2)
> > >>  #im = cv2.line(im,(x,y+h),(x+w,y+h),(0,255,0),2)
> > >>  #im = cv2.line(im,(x,y),(x,y+h),(0,255,0),2)
> > >>
> > >>
> > >> cv2.imwrite(r'C:\Users\tester\Documents\masda.png',im)
> > >
> > >
> > > These two lines:
> > >
> > >while im is None:
> > >  time.sleep(1)
> > >
> > > are an infinite loop if im is None;
> > >
> > >
> > > Since you haven't told us what im (or img, contours, cv2) are, I can't
> > > tell how im might become None, but it does look like you (confusingly)
> > > use im for two different things:  an img.copy() and a cv2.rectangle,
> > > whatever those may be.
> > >
> > > Pure guesswork:  if cv2.rectangle draws a rectangle, what does it
> > > return?  If it doesn't return anything, the line
> > >  im = cv2.rectangle(...)
> > > is how im gets the value of None.
> > >
> > It looks like the OP is using OpenCV.
> > 
> > You're right about cv2.rectangle; it does return None.
> > 
> > The line:
> > 
> >  im = cv2.rectangle(im.copy(), (x,y), (x+w, y+h), (0,255,0), 2)
> > 
> > makes a copy of the image im, draws a rectangle on it, and then binds 
> > None to im.
> > 
> > The copied rectangle is discarded because there's no reference to it, so 
> > the entire line in pointless.
> > 
> > It basically does the same thing as:
> > 
> >  im = None
> > 
> > only slower!

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


Re: why this code loop forever after a draw a rectangle

2016-09-16 Thread meInvent bbird
thank you very much,
it out of the loop now.
because drawLine function return things

i just change drawLine to rectangle,
have not thought that rectangle not return thing, just edit the parameter



On Saturday, September 17, 2016 at 5:26:53 AM UTC+8, MRAB wrote:
> On 2016-09-16 20:14, Gary Herron wrote:
> > On 09/16/2016 04:24 AM, meInvent bbird wrote:
> >> im = img.copy()
> >> cntcounter = 0
> >> for cnt in contours:
> >>  epsilon = 0.1*cv2.arcLength(cnt,True)
> >>  approx = cv2.approxPolyDP(cnt,epsilon,True)   
> >>  #peri = cv2.arcLength(cnt, True)
> >>  #approx = cv2.approxPolyDP(c, 0.5 * peri, True)
> >>  #print("len(approx)="+str(len(approx)))
> >>  if len(approx) == 4:
> >>  print("approx=" + str(approx))
> >>  cntcounter = cntcounter + 1
> >>  print("here1")
> >>  x,y,w,h = cv2.boundingRect(cnt)
> >>  print("here2")
> >>  while im is None:
> >>  time.sleep(1)
> >>  if im is not None:
> >>  print("here3")
> >>  im = cv2.rectangle(im.copy(), (x,y), (x+w, y+h), 
> >> (0,255,0), 2)
> >>  #im = cv2.line(im,(x,y),(x+w,y),(0,255,0),2)
> >>  #im = cv2.line(im,(x+w,y),(x+w,y+h),(0,255,0),2)
> >>  #im = cv2.line(im,(x,y+h),(x+w,y+h),(0,255,0),2)
> >>  #im = cv2.line(im,(x,y),(x,y+h),(0,255,0),2)
> >>
> >>
> >> cv2.imwrite(r'C:\Users\tester\Documents\masda.png',im)
> >
> >
> > These two lines:
> >
> >while im is None:
> >  time.sleep(1)
> >
> > are an infinite loop if im is None;
> >
> >
> > Since you haven't told us what im (or img, contours, cv2) are, I can't
> > tell how im might become None, but it does look like you (confusingly)
> > use im for two different things:  an img.copy() and a cv2.rectangle,
> > whatever those may be.
> >
> > Pure guesswork:  if cv2.rectangle draws a rectangle, what does it
> > return?  If it doesn't return anything, the line
> >  im = cv2.rectangle(...)
> > is how im gets the value of None.
> >
> It looks like the OP is using OpenCV.
> 
> You're right about cv2.rectangle; it does return None.
> 
> The line:
> 
>  im = cv2.rectangle(im.copy(), (x,y), (x+w, y+h), (0,255,0), 2)
> 
> makes a copy of the image im, draws a rectangle on it, and then binds 
> None to im.
> 
> The copied rectangle is discarded because there's no reference to it, so 
> the entire line in pointless.
> 
> It basically does the same thing as:
> 
>  im = None
> 
> only slower!

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


Looking for tips and gotchas for working with Python 3.5 zipapp feature

2016-09-16 Thread Malcolm Greene
Looking for tips or edge case gotchas associated with using Python 3.5's
new zipapp feature. For those of you wondering what this feature is, see
the end of this post for a brief background [1].

Two questions in particular:

1. Are there any issues with deploying scripts that sit in sub-
   folders beneath the directory being zipped, eg. does zipapp only
   support a flat folder of scripts or does it recursively zip and
   path sub-folders?

2. Can additional non-Python files like config files be added to a
   zipapp without breaking them and if so, how would your script
   reference these embedded files (by opening up the zipapp as a zip
   archive and navigating from there?).

Thank you,
Malcolm

[1] The zipapp feature of Python 3.5 is pretty cool: It allows you to
package your Python scripts in a single executable zip file. This
isn't a replacement for tools like PyInstaller or Py2Exe, eg. it
doesn't bundle the Python interpreter in the zip file, but it's a
clean way to distribute multi-file scripts in environments where you
have control over users' Python setups.

Here's the manual page:

zipapp — Manage executable python zip archives
https://docs.python.org/3/library/zipapp.html

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


[issue28168] Use _winapi.WaitForMultipleObjects in Popen.wait()

2016-09-16 Thread Eryk Sun

Changes by Eryk Sun :


Added file: http://bugs.python.org/file44698/issue_28168_03.patch

___
Python tracker 

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



[issue28168] Use _winapi.WaitForMultipleObjects in Popen.wait()

2016-09-16 Thread Eryk Sun

Changes by Eryk Sun :


Removed file: http://bugs.python.org/file44673/issue_28168_01.patch

___
Python tracker 

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



[issue28168] Use _winapi.WaitForMultipleObjects in Popen.wait()

2016-09-16 Thread Eryk Sun

Changes by Eryk Sun :


Removed file: http://bugs.python.org/file44674/issue_28168_02.patch

___
Python tracker 

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



Re: Discover all non-standard library modules imported by a script

2016-09-16 Thread Malcolm Greene
Thanks for your suggestions Chris and Terry.

The answer I was looking for is the modulefinder module which is part of
the standard lib. Works like a charm!

Quote: This module provides a ModuleFinder class that can be used to
determine the set of modules imported by a script. modulefinder.py can
also be run as a script, giving the filename of a Python script as its
argument, after which a report of the imported modules will be printed.

https://docs.python.org/3.5/library/modulefinder.html 

Note there's a similar module for Python 2.7.

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


[issue22493] Deprecate the use of flags not at the start of regular expression

2016-09-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Patch LGTM (but I changed tests a little). Thanks Tim!

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



[issue22493] Deprecate the use of flags not at the start of regular expression

2016-09-16 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c35a528268fd by Serhiy Storchaka in branch '3.6':
Issue #22493: Warning message emitted by using inline flags in the middle of
https://hg.python.org/cpython/rev/c35a528268fd

New changeset 9d0f4da4d531 by Serhiy Storchaka in branch 'default':
Issue #22493: Warning message emitted by using inline flags in the middle of
https://hg.python.org/cpython/rev/9d0f4da4d531

--

___
Python tracker 

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



[issue28183] Clean up and speed up dict iteration

2016-09-16 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +methane, xiang.zhang

___
Python tracker 

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



Re: How to get the source code of python function being decorated?

2016-09-16 Thread Peter Otten
Peng Yu wrote:

> Hi, See the following example, I am not able to get the source code of
> the actual function that does the calculation of partial_ratio. Does
> anybody know what is the correct way of getting the source?
> 
> /tmp$ ./main.py
> @functools.wraps(func)
> def decorator(*args, **kwargs):
> if args[0] is None or args[1] is None:
> return 0
> return func(*args, **kwargs)
> 
> /tmp$ cat ./main.py
> #!/usr/bin/env python
> # vim: set noexpandtab tabstop=2 shiftwidth=2 softtabstop=-1
> # fileencoding=utf-8:
> 
> import fuzzywuzzy.fuzz
> import inspect
> print inspect.getsource(fuzzywuzzy.fuzz.partial_ratio)

In Python 3 functools.wraps() records the wrapped function as __wrapped__:

$ cat tmp.py
import functools

def spam(func):
@functools.wraps(func)
def decorator(*args, **kwargs):
return func(*args, **kwargs)
return decorator

@spam
def ham(foo, bar):
return 42

$ python3
...
>>> import inspect
>>> import tmp  
>>> print(inspect.getsource(tmp.ham))
@functools.wraps(func)
def decorator(*args, **kwargs):
return func(*args, **kwargs)

>>> print(inspect.getsource(tmp.ham.__wrapped__))
@spam
def ham(foo, bar):
return 42

In Python 2 when you look into the attributes of tmp.ham() using dir() 
you'll eventually find

>>> print inspect.getsource(tmp.ham.__closure__[0].cell_contents)
@spam
def ham(foo, bar):
return 42

but I'm not sure this is general enough to spare you the look into the 
source code.

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


[issue27761] Private _nth_root function loses accuracy

2016-09-16 Thread Tim Peters

Tim Peters added the comment:

Oops!  The `D2**e` in that code should be `pow(D2, e)`, to make it use the 
correct decimal context.

--

___
Python tracker 

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



[issue28183] Clean up and speed up dict iteration

2016-09-16 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

In some circumstances iterating dict under 3.6 can be 20% slower than under 3.5.

$ ./python -m perf timeit -s "d = dict.fromkeys(range(10**6))" -- "list(d)"

Python 3.5: Median +- std dev: 33.8 ms +- 0.7 ms
Python 3.6: Median +- std dev: 37.8 ms +- 0.5 ms

Seems this is compiler and platform specific, it is reproducible only with GCC 
on 32 bit.
 
Proposed patch restores 3.5 performance and simplifies the code.

Python 3.6 patched: Median +- std dev: 33.7 ms +- 0.7 ms

Other types of iteration:

$ ./python -m perf timeit -s "d = dict.fromkeys(range(10**6)); v = d.values()" 
-- "list(v)"
Python 3.5:Median +- std dev: 26.2 ms +- 0.7 ms
Python 3.6 unpatched:  Median +- std dev: 28.0 ms +- 0.6 ms
Python 3.6 patched:Median +- std dev: 26.3 ms +- 1.1 ms

$ ./python -m perf timeit -s "d = dict.fromkeys(range(10**6)); v = d.items()" 
-- "list(v)"
Python 3.5:Median +- std dev: 232 ms +- 6 ms
Python 3.6 unpatched:  Median +- std dev: 259 ms +- 6 ms
Python 3.6 patched:Median +- std dev: 243 ms +- 9 ms

_PyDict_Next():
$ ./python -m perf timeit -s "d = dict.fromkeys(range(10**6))" -- "set(d)"
Python 3.5:Median +- std dev: 68.3 ms +- 1.8 ms
Python 3.6 unpatched:  Median +- std dev: 68.1 ms +- 2.5 ms
Python 3.6 patched:Median +- std dev: 66.0 ms +- 1.2 ms

PyDict_Next():
$ ./python -m perf timeit -s "from _testcapi import test_dict_iteration as t" 
-- "t()"
Python 3.5:Median +- std dev: 3.31 ms +- 0.10 ms
Python 3.6 unpatched:  Median +- std dev: 3.51 ms +- 0.09 ms
Python 3.6 patched:Median +- std dev: 3.43 ms +- 0.09 ms

--
components: Interpreter Core
files: dict_iter.patch
keywords: patch
messages: 276755
nosy: haypo, ned.deily, rhettinger, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Clean up and speed up dict iteration
type: performance
versions: Python 3.6, Python 3.7
Added file: http://bugs.python.org/file44697/dict_iter.patch

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-09-16 Thread Tim Peters

Tim Peters added the comment:

Mark, thanks for the counterexample!  I think I can fairly accuse you of 
thinking ;-)

I expect the same approach would be zippy for scaling x by 2**e, provided that 
the scaled value doesn't exceed the dynamic range of the decimal context.  Like 
so:

def erootn(x, e, n,
  D=decimal.Decimal,
  D2=decimal.Decimal(2),
  pow=c.power,
  sub=c.subtract,
  div=c.divide):
g = x**(1.0/n) * 2.0**(e/n) # force e to float for Python 2?
Dg = D(g)
return g - float(sub(Dg, div(D(x)*D2**e, pow(Dg, n-1 / n

The multiple errors in the native-float-precision starting guess shouldn't 
hurt.  In this case D(x)*D2**e may not exactly equal the scaled input either, 
but the error(s) are "way at the end" of the extended-precision decimal format.

I don't know the range of `e` you have to worry about.  On my box, 
decimal.MAX_EMAX == 99 ... but the docs say that on a 32-bit 
box it's "only" 42500.  If forcing the context Emax to that isn't enough, 
then your code is still graceful but this other approach would need to get 
uglier.

--

___
Python tracker 

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



Re: How to get the source code of python function being decorated?

2016-09-16 Thread Ned Batchelder
On Friday, September 16, 2016 at 3:20:15 PM UTC-4, Peng Yu wrote:
> Hi, See the following example, I am not able to get the source code of
> the actual function that does the calculation of partial_ratio. Does
> anybody know what is the correct way of getting the source?
> 
> /tmp$ ./main.py
> @functools.wraps(func)
> def decorator(*args, **kwargs):
> if args[0] is None or args[1] is None:
> return 0
> return func(*args, **kwargs)
> 
> /tmp$ cat ./main.py
> #!/usr/bin/env python
> # vim: set noexpandtab tabstop=2 shiftwidth=2 softtabstop=-1 
> fileencoding=utf-8:
> 
> import fuzzywuzzy.fuzz
> import inspect
> print inspect.getsource(fuzzywuzzy.fuzz.partial_ratio)
>

In general, you can't get at the decorated function. Decorators can
do anything they want with the function they decorate, including
completely ignore it, or store it in a closure, assign it to a global,
add it to a data structure, etc.

Can you tell us more about the problem you are trying to solve? Why
do you want a program that access the source of decorated functions?
Maybe there's another way to get at what you need.

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


[issue27806] 2.7 32-bit builds fail on future releases of OS X due to dependency on deleted header file

2016-09-16 Thread Jeremy Sequoia

Jeremy Sequoia added the comment:

sys/cdefs.h (on new enough darwin) does this for such cases:

#ifndef __has_include
#define __has_include(x) 0
#endif

but of course that isn't present in sys/cdefs.h on older SDKs, so you can just 
shove that above the check and it should fallback the way you want.

Using gcc-4.2 on Sierra would end up with the wrong result, but that's not a 
supported configuration.

--

___
Python tracker 

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



[issue27806] 2.7 32-bit builds fail on future releases of OS X due to dependency on deleted header file

2016-09-16 Thread Ned Deily

Ned Deily added the comment:

sashk, thanks for the patches!  The general approach LGTM as well.  
Unfortunately, we need the fix to work with gcc-4.2 since the Python 2.7 
installers are still built and supported on OS X 10.5 and 10.6 and the 
__has_include preprocessor construct is not available in gcc-4.2.

--

___
Python tracker 

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



Re: why this code loop forever after a draw a rectangle

2016-09-16 Thread MRAB

On 2016-09-16 20:14, Gary Herron wrote:

On 09/16/2016 04:24 AM, meInvent bbird wrote:

im = img.copy()
cntcounter = 0
for cnt in contours:
 epsilon = 0.1*cv2.arcLength(cnt,True)
 approx = cv2.approxPolyDP(cnt,epsilon,True)
 #peri = cv2.arcLength(cnt, True)
 #approx = cv2.approxPolyDP(c, 0.5 * peri, True)
 #print("len(approx)="+str(len(approx)))
 if len(approx) == 4:
 print("approx=" + str(approx))
 cntcounter = cntcounter + 1
 print("here1")
 x,y,w,h = cv2.boundingRect(cnt)
 print("here2")
 while im is None:
 time.sleep(1)
 if im is not None:
 print("here3")
 im = cv2.rectangle(im.copy(), (x,y), (x+w, y+h), (0,255,0), 2)
 #im = cv2.line(im,(x,y),(x+w,y),(0,255,0),2)
 #im = cv2.line(im,(x+w,y),(x+w,y+h),(0,255,0),2)
 #im = cv2.line(im,(x,y+h),(x+w,y+h),(0,255,0),2)
 #im = cv2.line(im,(x,y),(x,y+h),(0,255,0),2)


cv2.imwrite(r'C:\Users\tester\Documents\masda.png',im)



These two lines:

   while im is None:
 time.sleep(1)

are an infinite loop if im is None;


Since you haven't told us what im (or img, contours, cv2) are, I can't
tell how im might become None, but it does look like you (confusingly)
use im for two different things:  an img.copy() and a cv2.rectangle,
whatever those may be.

Pure guesswork:  if cv2.rectangle draws a rectangle, what does it
return?  If it doesn't return anything, the line
 im = cv2.rectangle(...)
is how im gets the value of None.


It looks like the OP is using OpenCV.

You're right about cv2.rectangle; it does return None.

The line:

im = cv2.rectangle(im.copy(), (x,y), (x+w, y+h), (0,255,0), 2)

makes a copy of the image im, draws a rectangle on it, and then binds 
None to im.


The copied rectangle is discarded because there's no reference to it, so 
the entire line in pointless.


It basically does the same thing as:

im = None

only slower!

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


[issue16902] Add OSS module support for Solaris

2016-09-16 Thread Tim Mooney

Tim Mooney added the comment:

Sooo  It's been 3 years.  Brian's patch has bit-rotted a bit, but it's easy 
to update for recent Python.

What are the hold-ups to getting this applied?

--

___
Python tracker 

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



[issue16700] Document that bytes OS API can returns unusable results on Windows

2016-09-16 Thread Mark Lawrence

Changes by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
Python tracker 

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



Re: Discover all non-standard library modules imported by a script

2016-09-16 Thread Terry Reedy

On 9/16/2016 7:29 AM, Malcolm Greene wrote:

Looking for suggestions on how, given a main script, discover all the
non-standard library modules imported across all modules, eg. the
modules that other modules import, etc. I'm not looking to discover
dynamic imports or other edge cases, just the list modules loaded via
"import " and "from  import ...". I know I could write a
script to do this, but certainly there must be such a capability in the
standard library?

Use case: Discovering list of modules to use for building a Python 3.5
zipapp distributable.


You could check the .__file__ attribute of each module in sys.modules 
for 'site-packages', (or more generally, for non-stdlib locations).


--
Terry Jan Reedy

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


[issue28179] Segfault in test_recursionlimit_fatalerror

2016-09-16 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


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

___
Python tracker 

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



[issue28179] Segfault in test_recursionlimit_fatalerror

2016-09-16 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Running with fresh build from IDLE in a subprocess on Win10, with 15 instead of 
10, I quickly get a fatal Python error and the Windows box equivalent to a 
segfault.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue15443] datetime module has no support for nanoseconds

2016-09-16 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

Another advantage of a single nanoseconds field is that currently microseconds 
are packed in 3 bytes and nanoseconds would fit in 4 - a 1 byte increase, but 
to add a 0-999 field, one would need at least 2 bytes.

--
versions: +Python 3.7 -Python 3.6

___
Python tracker 

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



[issue15443] datetime module has no support for nanoseconds

2016-09-16 Thread Steve Holden

Steve Holden added the comment:

I agree on reflection that a single nanoseconds integral value makes more 
sense. This then requires refactoring of the existing code so that existing 
tests continue to pass using a microsecond property.

Code using ONLY nanoseconds is a disjoint case, for which new tests will be 
required. It clearly cannot be expected to be backwards compatible with 
pre-implementation versions.

Does it make sense to define behaviour for cases where the user attempts to MIX 
microseconds and nanoseconds? One validation I would suggest if so is that in 
the presence of a microseconds specification a constraint of 0 <= nanoseconds < 
1000 must be imposed.

--

___
Python tracker 

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



[issue28145] Fix whitespace in C source code

2016-09-16 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Converting tabs to spaces and deleting trailing whitespace are separate issues 
and should be discussed and possibly done separately.

I think trailing whitespace should be uniformly fixed and prohibited for C 
files as it seems to be for most other files, for reasons including the issue 
cited by Mark.  I seems silly that one should be faced with either reverting 
changes by a mandated fixup program or pushing a somewhat messy patch.  

Does the repository check and reject new and changed lines with trailing 
whitespace, as it does for other file types?  If so, then existing lines with 
whitespace are a trap for someone who makes a small change (such as '<=' to 
'<') and forgets to run patchcheck.

I think generated code should also be generated without whitespace and I would 
also make this a separate patch.  The review mindset for substantive code 
change is different from review of changes that must not make a substantive 
change.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue22493] Deprecate the use of flags not at the start of regular expression

2016-09-16 Thread Tim Graham

Tim Graham added the comment:

Yes, I found that Django needs an update to support that syntax in URLpatterns. 
Thanks.

--

___
Python tracker 

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



[issue25283] Make tm_gmtoff and tm_zone available on all platforms

2016-09-16 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

The problem of computing tm_gmtoff on platforms without it was solved by tzcode 
some time ago. [1,2]  Consider stealing some of their logic.

[1]: http://mm.icann.org/pipermail/tz/2014-September/021601.html
[2]: https://github.com/eggert/tz/commit/40b395e139

--

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-09-16 Thread Mark Dickinson

Mark Dickinson added the comment:

> And it's still the case that I haven't found a case where its result isn't 
> correctly rounded.

Here's one: :-)

>>> rootn(1 + 2**-52, 2)
1.0002

The correctly rounded result would be 1.0.

--

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-09-16 Thread Mark Dickinson

Mark Dickinson added the comment:

> Decimal pow doesn't special-case integer exponents; the solution will still 
> be based on exp and ln.

Ah, sorry; I'm wrong. That was true for the Python version of the decimal 
module, not for the C implementation.

--

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-09-16 Thread Mark Dickinson

Mark Dickinson added the comment:

> It does use the Decimal pow(), but with an integer exponent, so this specific 
> use of pow() doesn't invoke the Decimal exp() or ln() either.

Decimal pow doesn't special-case integer exponents; the solution will still be 
based on exp and ln.

--

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-09-16 Thread Mark Dickinson

Mark Dickinson added the comment:

> Mark, the code I showed in roots.py is somewhat more accurate and highly 
> significantly faster than the code you just posted.

Okay, fair enough. In that case, we still need a solution for computing rootn(x 
* 2**e) in the case where x*2**e itself overflows / underflows an IEEE 754 
float.

--

___
Python tracker 

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



Re: why this code loop forever after a draw a rectangle

2016-09-16 Thread Gary Herron

On 09/16/2016 05:18 AM, meInvent bbird wrote:

i follow this post to give some time it to operate,
wait a long time still looping

http://answers.opencv.org/question/60094/libpng-warning-image-width-is-zero-in-ihdr/


i can not stand this Ninja coding life any more,
i have to open my code for ask this error


import cv2
import numpy as np
#from matplotlib import pyplot as plt
import time

#print("1=" + str(int(sys.argv[1])))
#print("2=" + str(int(sys.argv[2])))
#print("3=" + str(int(sys.argv[3])))

img_rgb = cv2.imread(r'C:\Users\martin\Documents\scree2.png')
img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
template = cv2.imread(r'C:\Users\martin\Documents\dragob.png',0)
w, h = template.shape[::-1]

res = cv2.matchTemplate(img_gray,template,cv2.TM_CCOEFF_NORMED)
threshold = 0.64
 
loc = np.where( res >= threshold)

pt = [(0,0)]
 
while not zip(*loc[::-1]):

 threshold = threshold - 0.02
 loc = np.where( res >= threshold)

counter = 1
print("threshold="+str(threshold))
for pt2 in zip(*loc[::-1]):
 cv2.rectangle(img_rgb, pt2, (pt2[0] + w, pt2[1] + h), (0,0,255), 2)
 pt = pt2
 crop_img = img_rgb[pt[1]:(pt[1]+h), pt[0]:(pt[0]+w)]
 counter = counter + 1

cv2.imwrite("C:\\Users\\tester\\Documents\\res.png",crop_img)


#import cv2
#winName = "Movement Indicator"
#cv2.namedWindow(winName, cv2.WINDOW_NORMAL)
img = cv2.imread(r'C:\Users\tester\Documents\res.png',1)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
height, width = gray.shape
edges = cv2.Canny(gray,height,width,apertureSize = 3)
#edges = cv2.Canny(gray,30,200)

#gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
#ret,thresh = 
cv2.threshold(edges.copy(),cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE,0)
ret,thresh = cv2.threshold(edges,250,150,0)
contours,hierarchy = cv2.findContours(thresh, 1, 2)
#contours = sorted(contours, key = cv2.contourArea, reverse = True)[:10]

im = img.copy()
cntcounter = 0
for cnt in contours:
 epsilon = 0.1*cv2.arcLength(cnt,True)
 approx = cv2.approxPolyDP(cnt,epsilon,True)
 #peri = cv2.arcLength(cnt, True)
 #approx = cv2.approxPolyDP(c, 0.5 * peri, True)
 #print("len(approx)="+str(len(approx)))
 if len(approx) == 4:
 print("approx=" + str(approx))
 cntcounter = cntcounter + 1
 print("here1")
 x,y,w,h = cv2.boundingRect(cnt)
 print("here2")
 #im = img.copy()
 while im is None:
 time.sleep(1)
 if im is not None:
 print("here3")
 im = cv2.rectangle(im.copy(), (x,y), (x+w, y+h), (0,255,0), 2)
 
#cv2.imwrite("C:\\Users\\martin\\Documents\\masda"+str(cntcounter)+".png",imi)
 #im = cv2.line(im,(x,y),(x+w,y),(0,255,0),2)
 #im = cv2.line(im,(x+w,y),(x+w,y+h),(0,255,0),2)
 #im = cv2.line(im,(x,y+h),(x+w,y+h),(0,255,0),2)
 #im = cv2.line(im,(x,y),(x,y+h),(0,255,0),2)








On Friday, September 16, 2016 at 7:34:04 PM UTC+8, Waffle wrote:

On 16 September 2016 at 14:24, meInvent bbird  wrote:

im = img.copy()
cntcounter = 0
for cnt in contours:
 epsilon = 0.1*cv2.arcLength(cnt,True)
 approx = cv2.approxPolyDP(cnt,epsilon,True)
 #peri = cv2.arcLength(cnt, True)
 #approx = cv2.approxPolyDP(c, 0.5 * peri, True)
 #print("len(approx)="+str(len(approx)))
 if len(approx) == 4:
 print("approx=" + str(approx))
 cntcounter = cntcounter + 1
 print("here1")
 x,y,w,h = cv2.boundingRect(cnt)
 print("here2")
 while im is None:
 time.sleep(1)
 if im is not None:
 print("here3")
 im = cv2.rectangle(im.copy(), (x,y), (x+w, y+h), (0,255,0), 2)
 #im = cv2.line(im,(x,y),(x+w,y),(0,255,0),2)
 #im = cv2.line(im,(x+w,y),(x+w,y+h),(0,255,0),2)
 #im = cv2.line(im,(x,y+h),(x+w,y+h),(0,255,0),2)
 #im = cv2.line(im,(x,y),(x,y+h),(0,255,0),2)


cv2.imwrite(r'C:\Users\tester\Documents\masda.png',im)
--
https://mail.python.org/mailman/listinfo/python-list

not sure but..  this bit reads really suspicious:

 while im is None:
 time.sleep(1)

if im is ever None then how will it ever become not None? unless there
is some other thread at work i can't really see this happening.
and if there is some other thread at work then there is probably some
better solution than sleep()


Reading the manual for opencv, we see that cv2.rectangle does indeed 
return None:
  Python: cv.Rectangle(img, pt1, pt2, color, thickness=1, 
lineType=8, shift=0) → None


So the first pass through your loop does indeed set im to None with the line
im = cv2.rectangle(im.copy(), (x,y), (x+w, y+h), (0,255,0), 2)
and the next pass through the loop hits the infinite loop:
while im is None:
time.sleep(1)



How to install Python.h on FreeBSD 10.0-RELEASE?

2016-09-16 Thread Don Kuenz

The installed python packages are shown below. Searches lead me to
believe that a PTH option make play a role.


$ uname -v
FreeBSD 10.0-RELEASE #0 r260789: Thu Jan 16 22:34:59 UTC 2014 
r...@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC

$ pkg info | grep python
py27-dnspython-1.14.0  DNS toolkit for Python
py27-notify-0.1.1_11   python bindings for libnotify
py27-telepathy-python-0.15.19_1 Python bindings for the Telepathy framework
python-2.7_2,2 The "meta-port" for the default version of 
Python interpreter
python2-2_3The "meta-port" for version 2 of the Python 
interpreter
python27-2.7.12Interpreted object-oriented programming language
python3-3_3The "meta-port" for version 3 of the Python 
interpreter
python34-3.4.5 Interpreted object-oriented programming language

$ cd /usr/ports/lang/python
$ make config
===> No options to configure

---

Thank you,

--
Don Kuenz KB7RPU

There be triple ways to take, of the eagle or the snake,
Or the way of a man with a maid;
But the seetest way to me is a ship's upon the sea
In the heel of the Northeast Trade.
  - Kipling
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: why this code loop forever after a draw a rectangle

2016-09-16 Thread Gary Herron

On 09/16/2016 04:24 AM, meInvent bbird wrote:

im = img.copy()
cntcounter = 0
for cnt in contours:
 epsilon = 0.1*cv2.arcLength(cnt,True)
 approx = cv2.approxPolyDP(cnt,epsilon,True)
 #peri = cv2.arcLength(cnt, True)
 #approx = cv2.approxPolyDP(c, 0.5 * peri, True)
 #print("len(approx)="+str(len(approx)))
 if len(approx) == 4:
 print("approx=" + str(approx))
 cntcounter = cntcounter + 1
 print("here1")
 x,y,w,h = cv2.boundingRect(cnt)
 print("here2")
 while im is None:
 time.sleep(1)
 if im is not None:
 print("here3")
 im = cv2.rectangle(im.copy(), (x,y), (x+w, y+h), (0,255,0), 2)
 #im = cv2.line(im,(x,y),(x+w,y),(0,255,0),2)
 #im = cv2.line(im,(x+w,y),(x+w,y+h),(0,255,0),2)
 #im = cv2.line(im,(x,y+h),(x+w,y+h),(0,255,0),2)
 #im = cv2.line(im,(x,y),(x,y+h),(0,255,0),2)


cv2.imwrite(r'C:\Users\tester\Documents\masda.png',im)



These two lines:

  while im is None:
time.sleep(1)

are an infinite loop if im is None;


Since you haven't told us what im (or img, contours, cv2) are, I can't 
tell how im might become None, but it does look like you (confusingly) 
use im for two different things:  an img.copy() and a cv2.rectangle, 
whatever those may be.


Pure guesswork:  if cv2.rectangle draws a rectangle, what does it 
return?  If it doesn't return anything, the line

im = cv2.rectangle(...)
is how im gets the value of None.

--
Dr. Gary Herron
Professor of Computer Science
DigiPen Institute of Technology
(425) 895-4418

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


How to get the source code of python function being decorated?

2016-09-16 Thread Peng Yu
Hi, See the following example, I am not able to get the source code of
the actual function that does the calculation of partial_ratio. Does
anybody know what is the correct way of getting the source?

/tmp$ ./main.py
@functools.wraps(func)
def decorator(*args, **kwargs):
if args[0] is None or args[1] is None:
return 0
return func(*args, **kwargs)

/tmp$ cat ./main.py
#!/usr/bin/env python
# vim: set noexpandtab tabstop=2 shiftwidth=2 softtabstop=-1 fileencoding=utf-8:

import fuzzywuzzy.fuzz
import inspect
print inspect.getsource(fuzzywuzzy.fuzz.partial_ratio)

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


[issue16700] Document that bytes OS API can returns unusable results on Windows

2016-09-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Maybe this issue is outdated in 3.6 (thanks to PEP 529), but this still is a 
problem under 3.5 and 2.7.

--
status: closed -> open
versions: +Python 3.5 -Python 3.3, Python 3.4

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-09-16 Thread Tim Peters

Tim Peters added the comment:

Mark, the code I showed in roots.py is somewhat more accurate and highly 
significantly faster than the code you just posted.  It's not complicated at 
all:  it just uses Decimal to do a single Newton correction with extended 
precision.

Since it doesn't use the Decimal exp() or ln(), it's faster.  It does use the 
Decimal pow(), but with an integer exponent, so this specific use of pow() 
doesn't invoke the Decimal exp() or ln() either.  And it's still the case that 
I haven't found a case where its result isn't correctly rounded.  My testing 
framework found multiple not-correctly-rounded cases in your new code within 
seconds.

Presumably you could boost the precision to improve that, but then it would get 
even slower.

--

___
Python tracker 

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



[issue28111] geometric_mean can raise OverflowError for large input length

2016-09-16 Thread Mark Dickinson

Changes by Mark Dickinson :


--
title: geometric_mean can raise OverflowError when checking for inf -> 
geometric_mean can raise OverflowError for large input length

___
Python tracker 

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



[issue27806] 2.7 32-bit builds fail on future releases of OS X due to dependency on deleted header file

2016-09-16 Thread Jeremy Sequoia

Jeremy Sequoia added the comment:

Thanks, yep that looks much nicer to me.  Containing the core logic at a 
central choke point makes maintenance much easier.  I'll work to get this into 
MacPorts.

--

___
Python tracker 

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



[issue27922] Make IDLE tests less flashy

2016-09-16 Thread Terry J. Reedy

Terry J. Reedy added the comment:

It is more a matter of tradeoffs rather than 'okay'.

There is no general pydev rule against gui flashing.  The tk and ttk gui tests 
still do, but that is primarily Serhiy's concern.

The IDLE tests are at most perhaps a third complete, so they would have become 
collectively 3 or more times worse.  I should run the IDLE tests at least once 
for each patch and usually do it multiple times.  When I work on a module or 
its tests, I tend work incrementally and run the test for the module 10 or 20 
times or more.  So my first concern is my own eyes and mental state.

Second, I plan to ask others to run test_idle to make up for the lack of 
buildbot coverage, and I will feel better about doing so after the patches 
already made.  If one or a few flashes are left, I and others are still much 
better off.

In this case, there are two obvious fixes, but I don't like either.  Maybe I 
will come up with a third I like better, perhaps after some refactoring of the 
module.  I would also like to better understand the detailed behavior.  In the 
meanwhile, I reopened to add a comment to the test, so I don't lose track of 
the source of the remaining flash.

--
status: closed -> open

___
Python tracker 

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



[issue28176] Fix callbacks race in asyncio.SelectorLoop.sock_connect

2016-09-16 Thread STINNER Victor

STINNER Victor added the comment:

The timeout of 3 seconds seem to be too short for some buildbots like "AMD64 
FreeBSD CURRENT Non-Debug 3.x".

http://buildbot.python.org/all/builders/AMD64%20FreeBSD%20CURRENT%20Non-Debug%203.x/builds/295/steps/test/logs/stdio

test.test_asyncio.test_windows_utils (unittest.loader.ModuleSkipped) ... 
Exception in thread Thread-50:
Traceback (most recent call last):
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/threading.py",
 line 916, in _bootstrap_inner
self.run()
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/test/test_asyncio/test_selector_events.py",
 line 1819, in run
sock, addr = self.srv_sock.accept()
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/socket.py",
 line 205, in accept
fd, addr = self._accept()
socket.timeout: timed out

test test_asyncio failed
skipped 'Windows only'

==
ERROR: test_sock_connect_sock_write_race 
(test.test_asyncio.test_selector_events.SelectorLoopFunctionalTests)
--
Traceback (most recent call last):
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/test/test_asyncio/test_selector_events.py",
 line 1868, in test_sock_connect_sock_write_race
timeout=TIMEOUT))
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/asyncio/base_events.py",
 line 457, in run_until_complete
return future.result()
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/asyncio/futures.py",
 line 292, in result
raise self._exception
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/asyncio/tasks.py",
 line 239, in _step
result = coro.send(None)
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/asyncio/tasks.py",
 line 397, in wait_for
raise futures.TimeoutError()
concurrent.futures._base.TimeoutError

--
nosy: +haypo
resolution: fixed -> 
status: closed -> pending

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-09-16 Thread Mark Dickinson

Mark Dickinson added the comment:

Here's the error analysis, for the record. It's crude, but effective.  Assume
our decimal context precision is p (so p = 20 for the above code).

1. d is represented exactly with value in [1.0, 2.0).  (Conversions from float
   to Decimal are exact.)

2. c.ln(d) < 1.0, and Decimal's ln operation is correctly rounded, so the
   *absolute* error in c.ln(d) is at most 0.5 * 10**-p.

3. Similarly, LOG2 has an absolute error of at most 0.5 * 10**-p.

4. Let q be the unique integer satisfying 10**q <= n < 10**(q+1).

5. r * LOG2 < n < 10**(q+1), so ulp(r * LOG2) <= 10**(q + 1 - p),
   and the rounding error in computing r * LOG2 is at most
   0.5 * 10**(q + 1 - p). We also inherit the error from LOG2, scaled
   up by r (which is less than 10**(q+1)), so this inherited error
   is also bounded by 0.5 * 10**(q + 1 - p). Our total absolute error
   is now bounded by 10**(q + 1 - p).

6. The result of the addition of d to r * LOG2 is also bounded by
   n < 10**(q+1), so introduces a new rounding error of up to
   0.5 * 10**(q + 1 - p) on top of the errors in d and r * LOG2
   (steps 2 and 5). Our total error is now bounded by 1.5*10**(q + 1 - p).

7. Division by n produces a result <= 1.0. It divides our absolute error so
   far by n (>= 10**q), giving a new error of at most 15 * 10**-p, and
   introduces a new rounding error of at most 0.5 * 10**-p. Bound
   so far is 15.5 * 10**-p.

8. The exponential operation gives a result in the range [1.0, 2.0],
   and converts our absolute error of 15.5 * 10**-p into a relative
   error of at most 15.5 * 10**-p (let's call it 16 * 10**-p to be
   safe), which since our result is bounded by 2.0 amounts to an absolute
   error of at most 32 * 10**-p. We get a rounding error on the result
   of at most 5 * 10**-p (like ln, the decimal module's "exp" operation
   is also correctly rounded), making our total error bounded by 37 * 10**-p.

Finally, we want to express the error bound above in terms of ulps of the
original IEEE 754 binary64 format that float (almost certainly) uses.
Since our result (before the ldexp) is in the range [1.0, 2.0], one ulp
for the binary format is 2**-52. So the error bound in step 8, expressed
in binary64 ulps, is 37 / 2 **-52 * 10**-p < 2 * 10**(17-p) ulps. Rounding
from the final Decimal value to float also incurs an error of at most
0.5 ulps, so we end up with an error bound of

   final_error <= 0.5 + 2 * 10**(17-p) ulps.

For p = 20, this is 0.502 ulps.

--

___
Python tracker 

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



[issue24416] Return a namedtuple from date.isocalendar()

2016-09-16 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
assignee:  -> belopolsky
nosy: +belopolsky
versions: +Python 3.7 -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: how to automate java application in window using python

2016-09-16 Thread vern . muhr
On Thursday, September 15, 2016 at 11:57:04 PM UTC-7, meInvent bbird wrote:
> On Friday, September 16, 2016 at 2:26:47 AM UTC+8, bream...@gmail.com wrote:
> > On Thursday, September 15, 2016 at 8:13:05 AM UTC+1, meInvent bbird wrote:
> > > how to automate java application in window using python
> > > 
> > > 1. scroll up or down of scroll bar
> > > 2. click button
> > > 3. type text in textbox
> > 

Check out Sikuli at www.sikuli.org. It uses Jython, but hopefully that is close 
enough.

Best, Vern
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26149] Suggest PyCharm Community as an editor for Unix platforms

2016-09-16 Thread Guido van Rossum

Guido van Rossum added the comment:

Hm, maybe the list should just removed and only the link to the wiki preserved? 
Agreed that the list here feels outdated. And updating it is always going to be 
a political game (e.g. why isn't Wing IDE listed?)

--
nosy: +gvanrossum

___
Python tracker 

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



[issue28111] geometric_mean can raise OverflowError when checking for inf

2016-09-16 Thread Mark Dickinson

Mark Dickinson added the comment:

See msg276732 in issue 27761 for a possible solution.

--

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-09-16 Thread Mark Dickinson

Mark Dickinson added the comment:

I think this whole nth root discussion has become way more complicated than it 
needs to be, and there's a simple and obvious solution.

Two observations:

1. What we actually need is not nth_root(x), but nth_root(x*2**e) for a float x 
and integer e. That's easily computed as exp((log(x) + e*log(2)) / n), and if 
we (a) rescale x to lie in [1.0, 2.0) and (b) remove multiples of n from e 
beforehand and so replace e with e % n, all intermediate values in this 
computation are small (less than 2.0).

2. It's easy to compute the above expression either directly using the math 
module (which gives an nth root operation with an error of a handful of ulps), 
or with extra precision using the Decimal module (which gives an nth root 
operation that's almost always correctly rounded).

If we do this, this also fixes issue #28111, which is caused by the current 
algorithm getting into difficulties when computing the nth root of the 2**e 
part of x*2**e.

Here's a direct solution using the Decimal module. If my back-of-the-envelope 
forward error analysis is correct, the result is always within 0.502 ulps of 
the correct result. That means it's *usually* going to be correctly rounded, 
and *always* going to be faithfully rounded. If 0.502 ulps isn't good enough 
for you, increase the context precision from 20 to 30, then we'll always be 
within 0.50002 ulps instead.

The code deals with the core problem where x is finite and positive. Extending 
to negative values, zeros, nans and infinities is left as an exercise for the 
reader.


import decimal
import math

ROOTN_CONTEXT = decimal.Context(prec=20)
LOG2 = ROOTN_CONTEXT.ln(2)


def rootn(x, e, n):
"""
Accurate value for (x*2**e)**(1/n).

Result is within 0.502 ulps of the correct result.
"""
if not 0.0 < x < math.inf:
raise ValueError("x should be finite and positive")

m, exp = math.frexp(x)
q, r = divmod(exp + e - 1, n)
d = decimal.Decimal(m*2.0)
c = ROOTN_CONTEXT  # for brevity
y = c.exp(c.divide(c.add(c.ln(d), c.multiply(r, LOG2)), n))
return math.ldexp(y, q)

--

___
Python tracker 

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



[issue28128] Improve the warning message for invalid escape sequences

2016-09-16 Thread Eric V. Smith

Eric V. Smith added the comment:

Tim: Cool! That's way more useful than I thought it would be.

Serhiy: It's a proof of concept. Lots of design remains to be done. I'm not 
sure we've agreed on the concept yet, so I don't think it's worthwhile 
designing the API.

--

___
Python tracker 

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



[issue28128] Improve the warning message for invalid escape sequences

2016-09-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The basic concept LGTM.

first_invalid_escape_char is redundant, it is just s[first_invalid_escape_idx]. 
Or maybe better to return a pointer instead of an index.

bytes literals need similar solution.

--

___
Python tracker 

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



[issue1284316] Win32: Security problem with default installation directory

2016-09-16 Thread Mark Lawrence

Changes by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
Python tracker 

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



[issue28180] sys.getfilesystemencoding() should default to utf-8

2016-09-16 Thread STINNER Victor

STINNER Victor added the comment:

> is this someday already?)

Not yet :-)

--

___
Python tracker 

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



[issue28128] Improve the warning message for invalid escape sequences

2016-09-16 Thread Tim Graham

Tim Graham added the comment:

Eric, your patch was good enough to allow me to easily identify and fix all the 
warnings in Django: https://github.com/django/django/pull/7254. Thanks!

--

___
Python tracker 

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



[issue26081] Implement asyncio Future in C to improve performance

2016-09-16 Thread Rémi Cardona

Changes by Rémi Cardona :


--
nosy: +RemiCardona

___
Python tracker 

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



[issue1284316] Win32: Security problem with default installation directory

2016-09-16 Thread Steve Dower

Steve Dower added the comment:

Changing the default install directory in a maintenance release is not okay.

Users who are concerned about security can change the install directory, and 
bugs that arise as a result will be considered on their own merits.

Alternatively, you can obtain Python 2.7 from one of the companies who maintain 
a distribution (such as Continuum Analytics). Some of them default to a secure 
install directory.

--
stage: test needed -> resolved
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



[issue28147] Unbounded memory growth resizing split-table dicts

2016-09-16 Thread INADA Naoki

INADA Naoki added the comment:

This is patch for Python 3.5.
The patch uses more conservative approach.

--
Added file: http://bugs.python.org/file44696/fix-28147-py35.patch

___
Python tracker 

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



[issue28151] testPythonOrg() of test_robotparser fails on validating python.org HTTPS certificate

2016-09-16 Thread Berker Peksag

Berker Peksag added the comment:

Here's a patch that uses pythontest.net.

--
keywords: +patch
stage: needs patch -> patch review
Added file: http://bugs.python.org/file44695/issue28151.diff

___
Python tracker 

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



[issue28182] Expose OpenSSL verification results in SSLError

2016-09-16 Thread Chi Hsuan Yen

New submission from Chi Hsuan Yen:

This was originally a post at python-ideas. Now I reformat it to be more like a 
feature request.

Currently, Python raises SSLError with reason=CERTIFICATE_VERIFY_FAILED for all 
kinds of certificate verification failures. This results in difficulties in 
debugging SSL errors for others. (Some downstream bug reports: [1][2]) In 
OpenSSL, such errors are further divided into several kinds. For example, 
expired certificates result in X509_V_ERR_CERT_HAS_EXPIRED, and typical 
self-signed certificates fall into X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT. The 
error code can be retrieved via `SSL_get_verify_result` and human readable 
messages are available from `X509_verify_cert_error_string`. I hope I can get 
error messages like this: (Omit URLError to avoid verbose messages)

$ ./python -c 'import urllib.request; 
urllib.request.urlopen("https://self-signed.badssl.com/;)'
Traceback (most recent call last):
  File "/home/yen/Projects/cpython/Lib/urllib/request.py", line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
  File "/home/yen/Projects/cpython/Lib/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
  File "/home/yen/Projects/cpython/Lib/http/client.py", line 1285, in 
_send_request
self.endheaders(body, encode_chunked=encode_chunked)
  File "/home/yen/Projects/cpython/Lib/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
  File "/home/yen/Projects/cpython/Lib/http/client.py", line 1026, in 
_send_output
self.send(msg)
  File "/home/yen/Projects/cpython/Lib/http/client.py", line 964, in send
self.connect()
  File "/home/yen/Projects/cpython/Lib/http/client.py", line 1400, in connect
server_hostname=server_hostname)
  File "/home/yen/Projects/cpython/Lib/ssl.py", line 401, in wrap_socket
_context=self, _session=session)
  File "/home/yen/Projects/cpython/Lib/ssl.py", line 808, in __init__
self.do_handshake()
  File "/home/yen/Projects/cpython/Lib/ssl.py", line 1061, in do_handshake
self._sslobj.do_handshake()
  File "/home/yen/Projects/cpython/Lib/ssl.py", line 683, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED: DEPTH_ZERO_SELF_SIGNED_CERT] 
certificate verify failed: self signed certificate (_ssl.c:752)

And for expired certificates:

$ ./python -c 'import urllib.request; 
urllib.request.urlopen("https://expired.badssl.com/;)'
Traceback (most recent call last):
  File "/home/yen/Projects/cpython/Lib/urllib/request.py", line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
  File "/home/yen/Projects/cpython/Lib/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
  File "/home/yen/Projects/cpython/Lib/http/client.py", line 1285, in 
_send_request
self.endheaders(body, encode_chunked=encode_chunked)
  File "/home/yen/Projects/cpython/Lib/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
  File "/home/yen/Projects/cpython/Lib/http/client.py", line 1026, in 
_send_output
self.send(msg)
  File "/home/yen/Projects/cpython/Lib/http/client.py", line 964, in send
self.connect()
  File "/home/yen/Projects/cpython/Lib/http/client.py", line 1400, in connect
server_hostname=server_hostname)
  File "/home/yen/Projects/cpython/Lib/ssl.py", line 401, in wrap_socket
_context=self, _session=session)
  File "/home/yen/Projects/cpython/Lib/ssl.py", line 808, in __init__
self.do_handshake()
  File "/home/yen/Projects/cpython/Lib/ssl.py", line 1061, in do_handshake
self._sslobj.do_handshake()
  File "/home/yen/Projects/cpython/Lib/ssl.py", line 683, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED: CERT_HAS_EXPIRED] certificate 
verify failed: certificate has expired (_ssl.c:752)

I've once tried to achieve it, but my CPython knowledge is way too limited to 
give a good enough patch.

[1] https://github.com/rg3/youtube-dl/issues/10574
[2] https://github.com/rg3/youtube-dl/issues/7309

--
assignee: christian.heimes
components: SSL
messages: 276724
nosy: Chi Hsuan Yen, alex, christian.heimes, dstufft, janssen
priority: normal
severity: normal
status: open
title: Expose OpenSSL verification results in SSLError
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



[issue27973] urllib.urlretrieve() fails on second ftp transfer

2016-09-16 Thread Sohaib Ahmad

Sohaib Ahmad added the comment:

Hi Senthil,

Thanks for the review. Now that I look at it, even with a default value, an ftp 
specific parameter sure does break the open() API abstraction.

--

___
Python tracker 

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



[issue28180] sys.getfilesystemencoding() should default to utf-8

2016-09-16 Thread R. David Murray

R. David Murray added the comment:

I thought we "fixed" this by using surrogate escape when the locale was ASCII?  
We certainly have discussed changing the default and posix and so far have 
decided not to (someday that will change...is this someday already?)

--
nosy: +r.david.murray
stage: resolved -> 
versions: +Python 3.7 -Python 3.5

___
Python tracker 

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



[issue27391] server_hostname should only be required when checking host names

2016-09-16 Thread Guido van Rossum

Changes by Guido van Rossum :


--
nosy:  -gvanrossum

___
Python tracker 

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



[issue28143] ASDL compatibility with Python 3 system interpreter

2016-09-16 Thread R. David Murray

R. David Murray added the comment:

If we go that route it doesn't, from a certain point of view, solve the problem 
for systems that *only* ship python3...but I think we can ignore that issue: 
IMO it would be fine in that scenario to say that if you want to run the 
python2 regen scripts you have to install python2.  Especially since you can do 
that by building from source using the checked in artifacts.

--

___
Python tracker 

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



[issue28128] Improve the warning message for invalid escape sequences

2016-09-16 Thread Emanuel Barry

Emanuel Barry added the comment:

Personally I'd be fine with only one warning, reporting the first invalid 
escape. Presumably the string would be checked as a whole, or would get an r 
prefix. Patch seems like a good start; bytes would also need updating in that 
regard. Don't worry too much about the details, we can iron that out later :)

Also yeah, the fact that warnings are triggered at compile time results in 
surprising behaviour even for me. I'm liking the idea of a 
DeprecatedSyntaxWarning more.

I'll try to get some work done in that regard by the end of next week, but 
life's been somewhat busy so I can't give any guarantees. Thank you for your 
patch draft though, it helps me to figure out how I should tackle this!

--

___
Python tracker 

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



[issue25270] codecs.escape_encode systemerror on empty byte string

2016-09-16 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the reviews everyone!

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



  1   2   >