[issue30000] Inconsistency in the zlib module

2017-04-06 Thread Ellison Marks

Ellison Marks added the comment:

I'm not sure I agree with that. The docs for compressobj just say

"Returns a compression object, to be used for compressing data streams that 
won’t fit into memory at once."

Which I don't think says much about the complexity aspect. Whether you're 
compressing a smaller bit of data or a stream, I think the optional parameters 
in compressobj are just as applicable to compress. When you've got an in-memory 
chunk of data, it seems to be going out of the way to construct a compressobj 
just to get at the optional parameters.

--

___
Python tracker 

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



[issue30000] Inconsistency in the zlib module

2017-04-06 Thread Xiang Zhang

Xiang Zhang added the comment:

Such a change in my mind is an enhancement and only could get into 3.7.

IMHO zlib.compress() and zlib.decompress() are for simple usage, 
zlib.compressobj() and zlib.decompressobj() for advanced usage if you want more 
controls. Actually I would prefer simplifying zlib.decompress() signature 
(dropping the wbits parameter) than adding more complex to zlib.compress(). Of 
course we can't do that to maintain backwards compatibility. :-)

-1 on this change.

--
nosy: +martin.panter, xiang.zhang
versions:  -Python 2.7, Python 3.3, Python 3.4, 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



[issue30009] Integer conversion failure

2017-04-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

"%s" rounds float representation to 12 digits in Python 2.7. Replace "%s" with 
"%r" and you will get precise representation of floats.

int(4.01)= 4
int(0.019574)= 0
int(0.03915) = 0
int(0.09787) = 0
int(0.19574) = 0
int(0.9787)  = 0
R = 0.009787

See also https://docs.python.org/2/tutorial/floatingpoint.html .

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue30009] Integer conversion failure

2017-04-06 Thread Eryk Sun

Eryk Sun added the comment:

Use %r instead of %s to show the repr. Hopefully that should clear things up 
for you. int() truncates toward 0. The float in this case is slightly less than 
1.

--
nosy: +eryksun
resolution:  -> not a bug
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



[issue30009] Integer conversion failure

2017-04-06 Thread Tri Nguyen

New submission from Tri Nguyen:

This code below shows a situation when Python int() library would return a 
value of int(1.0) -> 0.0

---CODE
CHANGES = [1.00, 0.50, 0.25, 0.10, 0.05, 0.01]

# This code was originally to solve the least number of changes needed.
# However, in an attempt to solve this. A bug is found.

def get_change(R):
for change in CHANGES:
# This division and int() is where failure is happening
num = int(R / change)
# This printing line shows the failure.
print 'int(%s)\t = %s' % (R / change, num)
R = R - num * change
print 'R = %s' % R

get_change(4.01)

-OUTPUT--

int(4.01)= 4
int(0.02)= 0
int(0.04)= 0
int(0.1) = 0
int(0.2) = 0
int(1.0) = 0# This should be 1, right?
R = 0.01

--
components: Library (Lib)
files: int_bug.py
messages: 291249
nosy: nvutri
priority: normal
severity: normal
status: open
title: Integer conversion failure
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file46783/int_bug.py

___
Python tracker 

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



Re: Quick questions about globals and database connections

2017-04-06 Thread Jussi Piitulainen
DFS  writes:

> On 4/6/2017 10:54 AM, Python wrote:
>> Le 06/04/2017 à 16:46, DFS a écrit :
>>> On 4/5/2017 10:52 PM, Dan Sommers wrote:
 On Wed, 05 Apr 2017 22:00:46 -0400, DFS wrote:

> I have a simple hard-coded check in place before even trying to
> connect:
>
> if dbtype not in ('sqlite postgres'):
>print "db type must be sqlite or postgres"
>exit()

 That's not doing what you think it is.

 Hint:  What is ('sqlite postgres')?
>>>
>>> ?
>>>
>>> dbtype is a string, and the check works perfectly.  No typos make it
>>> past the guard.
>>
>> except that it would be True for dbtype = 'lite post' or dbtype = 'stgr'
>
>
> Except before I even get there I have another checkpoint.
>
> ---
> if len(sys.argv) != 4:
>   print "Enter group name, verbose setting (-s or -v), and db type"
>   exit(0)
>
> GRP = sys.argv[1]   (a few lines later I check this value against a db)   
>   
> verbose = 'x'
> if sys.argv[2] == '-s': verbose = False
> if sys.argv[2] == '-v': verbose = True
> if verbose not in (True,False):
>   print "Enter -s (silent) or -v (verbose)"
>   exit()
>   
> dbtype = sys.argv[3]  
> if dbtype not in ('sqlite postgres'):
>   print "db type must be sqlite or postgres"
>   exit()
> ---
>
> $1,000,000 virtual if you can get a bad command past those.
>
> These are good commands:
> $python progname.py comp.lang.python -v postgres
> $python progname.py comp.lang.c -s sqlite

So these are meant to be bad commands:
$python progname.py comp.lang.python -v post
$python progname.py comp.lang.c -s sql
$python progname.py comp.lang.cobol -v 'lite post'
$python progname.py comp.lang.perl -s stgr

What happens when you try them with the above code?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue29996] Use terminal width by default in pprint

2017-04-06 Thread Xiang Zhang

Xiang Zhang added the comment:

I use screens and usually like to open a terminal to fill the screen. One of my 
use case is changed by this patch from:

 'manufacturers_specifications': '2U 2*Intel Xeon E5-2603 4核 8*8G '
 'DDR3-1333 ECC 1.35v,12*300G 15K '
 'RPM 3.5寸 SAS,RAID '
 '卡带电池cache大于等于1GB,支持 Raid0 1 10 5 '
 '6 50 60[D23]',

to:

 'manufacturers_specifications': '2U 2*Intel Xeon E5-2603 4核 8*8G 
DDR3-1333 ECC 1.35v,12*300G 15K RPM 3.5寸 SAS,RAID 卡带电池cache大于等于1GB,支持 Raid0 1 
10 5 6 50 60[D23]',

Actually looks not bad. But why change the default behaviour? Can we provide 
this as a bonus and keep the default behaviour? Current defaults  80 is not 
unreasonable even for large terminals. If users prefer long lines and don't 
want to choose an arbitrary number, they could use this feature.

--
nosy: +xiang.zhang

___
Python tracker 

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



[issue29353] Incorrect handling of HTTP response with "Content-Type: message/rfc822" header

2017-04-06 Thread Senthil Kumaran

Changes by Senthil Kumaran :


--
nosy: +orsenthil

___
Python tracker 

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



[issue30000] Inconsistency in the zlib module

2017-04-06 Thread Ellison Marks

Ellison Marks added the comment:

I made a try at a patch for this.

My C is rudimentary at best, so I was hoping someone could look it over before 
I submitted a PR?

https://github.com/gotyaoi/cpython/commit/2906fc9069ce6ec4888a547b5088ef9177a21c9a

--

___
Python tracker 

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



Re: Temporary variables in list comprehensions

2017-04-06 Thread Tim Chase
On 2017-04-06 14:56, Vincent Vande Vyvre wrote:
> With two passes
> 
> e = [expensive_calculation(x) for x in data]
> final = [(x, y+1) for x, y in zip(e, e)]

Using a generator it can be done in one pass:

 final = [
   (value, tmp, tmp+1)
   for value, tmp
   in (
 (x, expensive_calculation(x))
 for x in data
 )
   ]

The above makes use of the original value as well at top level
(whether you need it for "if" filtering, or in your final tuple
result). If you don't care, you can discard it

 final = [
   (tmp, tmp+1)
   for tmp
   in (
 expensive_calculation(x)
 for x in data
 )
   ]

-tkc


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


[issue30004] in regex-howto, improve example on grouping

2017-04-06 Thread Cristian Barbarosie

Cristian Barbarosie added the comment:

Just discovered that a nearly identical example is presented in the end of 
section "Non-capturing and Named Groups". My proposal applies to this other 
example, too.
And, by the way, reading this HOWTO has been very useful to me.

--

___
Python tracker 

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



[issue29955] logging decimal point should come from locale

2017-04-06 Thread Vinay Sajip

Vinay Sajip added the comment:

> and provides no straightforward API for me to reconfigure its logger.

As far as I know, you just need to do something which configures a Flask 
logger, then call logging.config.dictConfig() with a suitable configuration 
which doesn't disable existing loggers and configures the Flask logger how you 
want. (The dictConfig call should replace any existing configuration with what 
you've passed to it). See this:

https://stackoverflow.com/questions/11816236/how-to-config-flask-app-logger-from-a-configure-file

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



Re: Temporary variables in list comprehensions

2017-04-06 Thread Lele Gaifax
Piet van Oostrum  writes:

> It is a poor man's 'let'. It would be nice if python had a real 'let'
> construction. Or for example:
>
> [(tmp, tmp + 1) for x in data with tmp = expensive_calculation(x)]
>
> Alas!

It would be nice indeed!

Or even

  [(tmp, tmp + 1) for x in data
   with expensive_calculation(x) as tmp
   if tmp is not None]

that fits the usual "with" syntax.

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
l...@metapensiero.it  | -- Fortunato Depero, 1929.

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


[issue29996] Use terminal width by default in pprint

2017-04-06 Thread Josh Rosenberg

Josh Rosenberg added the comment:

Thus, you keep your default behavior of width=80, while I just add the 
following to my PYTHONSTARTUP file:

from functools import partial
from pprint import pprint, AUTOWIDTH

pprint = partial(pprint, width=AUTOWIDTH)

and we both get what we want.

--

___
Python tracker 

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



[issue29996] Use terminal width by default in pprint

2017-04-06 Thread Josh Rosenberg

Josh Rosenberg added the comment:

If you want the dir listing output in a column, you're just relying on your 
listing to be wider than 80 characters, it still doesn't columnize unless you 
pass that point.

Personally, I feel if I made the terminal wider, I'd like to actually use that 
width.

I suppose an alternative, if you really don't want autosizing, is to make 
auto-sizing supported without having to explicitly call getterminalsize over 
and over, perhaps by creating some sentinel value (pprint.AUTOWIDTH or 
whatever) to make it trivial to do (or to allow those who desire it to use 
partial binding to make it the default for a session up front).

--
nosy: +josh.r

___
Python tracker 

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



[issue29943] PySlice_GetIndicesEx change broke ABI in 3.5 and 3.6 branches

2017-04-06 Thread Christoph Gohlke

Changes by Christoph Gohlke :


--
nosy: +cgohlke

___
Python tracker 

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



[issue11978] Report correct coverage.py data for tests that invoke subprocesses

2017-04-06 Thread Brett Cannon

Brett Cannon added the comment:

There's also what changes might occur in the coverage results when we start 
using fullcoverage: https://github.com/python/core-workflow/issues/18

--

___
Python tracker 

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



[issue29999] repr() of ImportError misses keyword arguments name and path

2017-04-06 Thread Brett Cannon

Brett Cannon added the comment:

I consider it an enhancement, especially if someone was slopping with their 
tests and explicitly checks the repr of ImportError.

--
type:  -> enhancement

___
Python tracker 

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



[issue29996] Use terminal width by default in pprint

2017-04-06 Thread Fred L. Drake, Jr.

Fred L. Drake, Jr. added the comment:

I wouldn't go so far as to say it's never come up; it's something I've thought 
about a number of times, and I've waffled on it a few times.

It's not fundamentally unreasonable to want it to adapt to the current terminal 
window, though I think it would be in a minority among the Unix command line 
tools that I use.

Raymond's point about potentially confusing students is an important one, 
though.  If adaptive behavior is sufficiently desirable, the module should 
check the value of an environment variable, and default to the current 
behavior.  PYTHONADAPTIVEPPRINT ?

--

___
Python tracker 

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



[issue29989] subprocess.Popen does not handle file-like objects without file descriptors

2017-04-06 Thread Josh Rosenberg

Changes by Josh Rosenberg :


--
nosy: +josh.r

___
Python tracker 

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



[issue29996] Use terminal width by default in pprint

2017-04-06 Thread Raymond Hettinger

Raymond Hettinger added the comment:

One other thought:  This module has a very long history. It is widely used, has 
had many feature requests and bug reports, but this particular feature has 
never been requested.  That should tell us something about whether there is an 
actual need.  To me, this seems like a new made-up requirement, invented in 
complete isolation from users.

--

___
Python tracker 

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



[issue29996] Use terminal width by default in pprint

2017-04-06 Thread Raymond Hettinger

Raymond Hettinger added the comment:

After more thought, put me down for -1 on this proposal.   

I use pprint() quite a bit when teaching Python courses.  I expect that 100% of 
the time that users are following the live examples, I will get stopped and 
asked why their output is different from mine.

Also, I question the usefulness of the auto-resizing.  When I pprint a dir() 
listing or some such, the intended effect is almost always that I want a 
vertical presentation.  If a horizontal one-liner was desired, I would have 
used print() instead.  ISTM, this proposal is out of touch with the actual 
needs and desires of users.

As a reference point, consider that IPython pretty prints output by default and 
is not terminal width sensitive.

--

___
Python tracker 

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



[issue30001] CPython contribution docs reference missing /issuetracker page

2017-04-06 Thread Alex Jordan

Alex Jordan added the comment:

Filed https://github.com/python/devguide/issues/156.

Sorry for the noise! I just assumed everything went through bpo. Guess not :)

--

___
Python tracker 

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



[issue30008] OpenSSL 1.1.0 deprecated functions

2017-04-06 Thread Mike Gilbert

New submission from Mike Gilbert:

Some effort was made to port Python to OpenSSL 1.1.0 (see issue 26470). 
However, the code still uses several deprecated functions, and fails to compile 
against OpenSSL 1.1.0 if these functions are disabled.

This may be replicated by building OpenSSL with --api=1.1.0. This will disable 
all functions marked as deprecated.

I have attached a build log from the cpython master branch.

Downstream bug: https://bugs.gentoo.org/show_bug.cgi?id=592480

--
components: Library (Lib)
files: build.log
messages: 291236
nosy: floppymaster
priority: normal
severity: normal
status: open
title: OpenSSL 1.1.0 deprecated functions
type: compile error
versions: Python 3.7
Added file: http://bugs.python.org/file46782/build.log

___
Python tracker 

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



[issue29955] logging decimal point should come from locale

2017-04-06 Thread Skip Montanaro

Skip Montanaro added the comment:

Vinay> I would like to close this issue now...

Go for it.

As I indicated in a previous comment, the exercise was as much to try and
come to grips with the process as to actually make the change. There
certainly appear to be good reasons to leave well enough alone. My primary
(though minor) concerns at this point are:

* the datetime module hard-coded it one way (period) while the logging
package hard-coded it the other way.

* other logging packages I've used/inherited in other languages
(admittedly, pretty much Americo-centric) all seem to have used periods.

This only became an issue for me because I recently started using Flask,
which sets up the logging environment and provides no straightforward API
for me to reconfigure its logger. (Peter Otten demonstrated a way to do
this using functools.partial, which, while doable, certainly doesn't strike
me as straightforward.) In cases where I'm in complete control, configuring
my own logging environment makes sense. (In reality, when I'm in complete
control, I tend to roll my own 20-line Logger class and not use the logging
module at all, but that's a historical artifact of me discovering
performance issues several years ago in applications which logged heavily.
Those issues may well not exist today.)

Skip

--
status: pending -> open

___
Python tracker 

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



[issue29939] Compiler warning in _ctypes_test.c

2017-04-06 Thread Vinay Sajip

Vinay Sajip added the comment:

Added relevant "needs backport" tags to PR, will get to it soon. Reopening till 
then.

--
status: closed -> open

___
Python tracker 

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



Correction of announcement of Version 2 of a steganographical software of mine

2017-04-06 Thread Mok-Kong Shen


Due to a new convention of my Internet provider, my current home page is 
now:


http://mokkong-shen.homepage.t-online.de

M. K. Shen
--
https://mail.python.org/mailman/listinfo/python-list


[issue29939] Compiler warning in _ctypes_test.c

2017-04-06 Thread STINNER Victor

STINNER Victor added the comment:

IHMO it's worth it to backport the fix, since Benjamin showed that GCC 
optimizer removes the function body and so defeat the purpose of the test.

--
nosy: +haypo

___
Python tracker 

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



[issue29939] Compiler warning in _ctypes_test.c

2017-04-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thanks Vinay!

--

___
Python tracker 

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



[issue29939] Compiler warning in _ctypes_test.c

2017-04-06 Thread Vinay Sajip

Vinay Sajip added the comment:

Should be fixed by 164d30e.

--
resolution:  -> fixed
stage: needs patch -> 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



[issue26789] Please do not log during shutdown

2017-04-06 Thread Vinay Sajip

Vinay Sajip added the comment:

In the OP, the error is caused by `open` being unavailable, which is a builtin. 
According to what Serhiy says, this error would be after step 6 in his list, so 
`sys` wouldn't be available either, and nor perhaps would any other builtins.

As some termination issues are asyncio-related (e.g. this one, "coroutine was 
never awaited"), it would make more sense for this kind of error handling to 
happen there - there's more contextual information available than there is in 
logging, so the error message displayed would be more useful because it could 
use the additional context available.

--

___
Python tracker 

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



Re: Quick questions about globals and database connections

2017-04-06 Thread Python

Le 06/04/2017 à 16:46, DFS a écrit :

On 4/5/2017 10:52 PM, Dan Sommers wrote:

On Wed, 05 Apr 2017 22:00:46 -0400, DFS wrote:


I have a simple hard-coded check in place before even trying to connect:

if dbtype not in ('sqlite postgres'):
   print "db type must be sqlite or postgres"
   exit()


That's not doing what you think it is.

Hint:  What is ('sqlite postgres')?


?

dbtype is a string, and the check works perfectly.  No typos make it
past the guard.


except that it would be True for dbtype = 'lite post' or dbtype = 'stgr'



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


Re: Quick questions about globals and database connections

2017-04-06 Thread Jussi Piitulainen
DFS writes:

> On 4/5/2017 10:52 PM, Dan Sommers wrote:
>> On Wed, 05 Apr 2017 22:00:46 -0400, DFS wrote:
>>
>>> I have a simple hard-coded check in place before even trying to connect:
>>>
>>> if dbtype not in ('sqlite postgres'):
>>>print "db type must be sqlite or postgres"
>>>exit()
>>
>> That's not doing what you think it is.
>>
>> Hint:  What is ('sqlite postgres')?
>
> ?
>
> dbtype is a string, and the check works perfectly.  No typos make it
> past the guard.

"lite post" in "sqlite postgres"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Temporary variables in list comprehensions

2017-04-06 Thread Jussi Piitulainen
Vincent Vande Vyvre writes:

> Le 06/04/17 à 14:25, Piet van Oostrum a écrit :
>> Steven D'Aprano  writes:
>>
>>> Suppose you have an expensive calculation that gets used two or more
>>> times in a loop. The obvious way to avoid calculating it twice in an
>>> ordinary loop is with a temporary variable:
>>>
>>> result = []
>>> for x in data:
>>>  tmp = expensive_calculation(x)
>>>  result.append((tmp, tmp+1))
>>>
>>>
>>> But what if you are using a list comprehension? Alas, list comps
>>> don't let you have temporary variables, so you have to write this:
>>>
>>>
>>> [(expensive_calculation(x), expensive_calculation(x) + 1) for x in data]
>>>
>>>
>>> Or do you? ... no, you don't!
>>>
>>>
>>> [(tmp, tmp + 1) for x in data for tmp in [expensive_calculation(x)]]
>>>
>>>
>>> I can't decide whether that's an awesome trick or a horrible hack...
>> It is a poor man's 'let'. It would be nice if python had a real 'let'
>> construction. Or for example:
>>
>> [(tmp, tmp + 1) for x in data with tmp = expensive_calculation(x)]
>>
>> Alas!
>
> With two passes
>
> e = [expensive_calculation(x) for x in data]
> final = [(x, y+1) for x, y in zip(e, e)]
>
> Vincent

Imagine some crazy combinatory question - how many ways can one choose
two subsets of the ten decimal digits so that the size of the first is
the minimum of the second and the size of the second is the maximum of
the first _or_ the minima and maxima of the two are the same?

Comprehensions lend themselves readily to such explorations. It happens
that some expensively computed value is needed twice, like the minima
and maxima of the two combinations in this exercise (because this
exercise was carefully crafted to be just so, but anyway), and then it
saves time to do the computations once: let the values have names.

from itertools import combinations as choose

print(sum(1 for m in range(1,10) for n in range(1,10)
  for a in choose(range(1,10), m)
  for b in choose(range(1,10), n)
  if ((len(a) == min(b) and len(b) == max(a)) or
  (min(a) == min(b) and max(a) == max(b)

print(sum(1 for m in range(1,10) for n in range(1,10)
  for a in choose(range(1,10), m)
  for b in choose(range(1,10), n)
  for lena, mina, maxa in [[len(a), min(a), max(a)]]
  for lenb, minb, maxb in [[len(b), min(b), max(b)]]
  if ((lena == minb and lenb == maxa) or
  (mina == minb and maxa == maxb

I realized afterwards that the sizes, len(a) and len(b), already had
names, m and n, and were only used once in the condition anyway, but let
that illustrate the point: this kind of expression lends itself to
analysis and modification, which is what one wants in explorative code.

(But the "for x in [foo(u,w)]" works, so, shrug, I guess? I'd welcome a
proper let construction, but then I find that I can live without.)
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue19225] lack of PyExc_BufferError doc

2017-04-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Sorry, but I just found that warning categories are enumerated near the 
documentation of PyErr_WarnEx(). I think that that enumeration is no longer 
needed and can be removed.

--

___
Python tracker 

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



Re: Problem installing 3.6.1 AMD64

2017-04-06 Thread Colin J. Williams
   Eryk,

   Many thanks.  I wasn't aware of the Path Editor,

   Colin W.

   On 2017-04-05 7:55 PM, eryk sun wrote:

 On Wed, Apr 5, 2017 at 6:46 PM, Colin J. Williams [1] wrote:

Successful install reported, but:

  Microsoft Windows [Version 10.0.14393]
  (c) 2016 Microsoft Corporation. All rights reserved.

 You're using Windows 10.


  C:\Users\CJW>cd\python
  The system cannot find the path specified.

  C:\Users\CJW>cd\

 What is this supposed to be doing?


  C:\>path
  PATH=C:\Program Files\Python35\Scripts\;C:\Program
  Files\Python35\;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system
  
32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
  Files (x86)\ATI Technologi
  es\ATI.ACE\Core-Static;C:\Program Files
  
(x86)\AMD\ATI.ACE\Core-Static;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;
  C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL
  Server\130\Tools\Binn\;C:\Program Files\TortoiseHg\;
  C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files
  (x86)\Skype\Phone\;C:\Users\CJW\AppData\Local\Progra
  
ms\Python\Python35\Scripts\;C:\Users\CJW\AppData\Local\Programs\Python\Python35\;C:\Python35\Lib\site-packages\PyQt5;C:\
  
Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
  Files (x86)\
  ATI Technologies\ATI.ACE\Core-Static;C:\Program Files
  (x86)\Skype\Phone\;C:\Users\CJW\AppData\Local\Programs\Git\cmd;C:\
  Users\CJW\AppData\Local\Microsoft\WindowsApps;

  C:\>

Python35 has been deleted, but it remains in the PATH.

I would welcome advice.

 The environment variable editor in Windows 10 has made editing PATH
 about as easy as possible. Just manually remove (select and click on
 "Delete") whichever paths are no longer valid. Apparently one is
 per-machine in "C:\Program Files\Python35", which will likely be in
 the system PATH, and the other is per-user in
 "C:\Users\CJW\AppData\Local\Programs\Python\Python35", which will
 likely be in the user PATH.

References

   Visible links
   1. mailto:c...@ncf.ca
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue19225] lack of PyExc_BufferError doc

2017-04-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 2cfe583ac8d3eaa98e3d2aca597577ce4787ca20 by Serhiy Storchaka 
(cocoatomo) in branch '3.5':
[3.5] bpo-19225: Lack of c api exceptions doc (#965)
https://github.com/python/cpython/commit/2cfe583ac8d3eaa98e3d2aca597577ce4787ca20


--

___
Python tracker 

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



[issue29955] logging decimal point should come from locale

2017-04-06 Thread Vinay Sajip

Vinay Sajip added the comment:

I would like to close this issue now, without making changes. Will do in one 
day, unless someone pipes up.

--
resolution:  -> not a bug
status: open -> pending

___
Python tracker 

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



[issue30007] report bug

2017-04-06 Thread Xiang Zhang

Xiang Zhang added the comment:

This tracker is for CPython developing. Your problem is in the third party 
module. You could refer Google or stackoverflow.

--
nosy: +xiang.zhang
resolution:  -> third party
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



Re: Temporary variables in list comprehensions

2017-04-06 Thread Vincent Vande Vyvre

Le 06/04/17 à 14:25, Piet van Oostrum a écrit :

Steven D'Aprano  writes:


Suppose you have an expensive calculation that gets used two or more times in a
loop. The obvious way to avoid calculating it twice in an ordinary loop is with
a temporary variable:

result = []
for x in data:
 tmp = expensive_calculation(x)
 result.append((tmp, tmp+1))


But what if you are using a list comprehension? Alas, list comps don't let you
have temporary variables, so you have to write this:


[(expensive_calculation(x), expensive_calculation(x) + 1) for x in data]


Or do you? ... no, you don't!


[(tmp, tmp + 1) for x in data for tmp in [expensive_calculation(x)]]


I can't decide whether that's an awesome trick or a horrible hack...

It is a poor man's 'let'. It would be nice if python had a real 'let'
construction. Or for example:

[(tmp, tmp + 1) for x in data with tmp = expensive_calculation(x)]

Alas!


With two passes

e = [expensive_calculation(x) for x in data]
final = [(x, y+1) for x, y in zip(e, e)]

Vincent


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


Re: PYTHON

2017-04-06 Thread Jan Erik Moström
On 6 Apr 2017, at 14:43, aldersilva...@gmail.com wrote:

> Hello, how can I start programming?

Let me google that for you => http://www.learnpython.org

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


[issue30007] report bug

2017-04-06 Thread Yared Gebre

New submission from Yared Gebre:

Hello,

I am using python 3.6 could you look at this bug. Thanks.

/home/yared/anaconda3/lib/python3.6/site-packages/mlimages/util/file_api.py
in add_ext_name(cls, path, ext_name) 63 @classmethod 64
 def add_ext_name(cls, path, ext_name):---> 65 name, ext =
os.path.splitext(os.path.basename(path)) 66 added =
os.path.join(os.path.dirname(path), name + ext_name + ext) 67
   return added
/home/yared/anaconda3/lib/python3.6/posixpath.py in basename(p)142
def basename(p):143 """Returns the final component of a
pathname"""--> 144 p = os.fspath(p)145 sep = _get_sep(p)
 146 i = p.rfind(sep) + 1

TypeError: expected str, bytes or os.PathLike object, not ImageProperty

--
messages: 291225
nosy: Yaredoh
priority: normal
severity: normal
status: open
title: report bug

___
Python tracker 

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



PYTHON

2017-04-06 Thread aldersilva676
Hello, how can I start programming?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30006] Deadlocks in `concurrent.futures.ProcessPoolExecutor`

2017-04-06 Thread Thomas Moreau

New submission from Thomas Moreau:

The design of ProcessPoolExecutor contains some possible race conditions that 
may freeze the interpreter due to deadlocks. This is notably the case  with 
pickling and unpickling errors for a submitted job and returned results. This 
makes it hard to reuse a launched executor.

We propose in the joint PR to fix some of those situations to make the 
ProcessPoolExecutor more robust to failure in the different threads and worker.

--
components: Library (Lib)
messages: 291224
nosy: tomMoral
priority: normal
pull_requests: 1180
severity: normal
status: open
title: Deadlocks in `concurrent.futures.ProcessPoolExecutor`
type: behavior

___
Python tracker 

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



[issue29533] urllib2 works slowly with proxy on windows

2017-04-06 Thread Marc Schlaich

Marc Schlaich added the comment:

This could be even a security issue.

People might rely on a proxy as a privacy feature. In this case the proxy 
should do forward/reverse DNS requests and not the client. Doing DNS lookups to 
check for proxy bypass doesn't seem right. I don't think that major browsers 
are doing this, at least Firefox is not 
(https://bugzilla.mozilla.org/show_bug.cgi?id=136789).

--
nosy: +schlamar

___
Python tracker 

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



Re: Temporary variables in list comprehensions

2017-04-06 Thread Piet van Oostrum
Steven D'Aprano  writes:

> Suppose you have an expensive calculation that gets used two or more times in 
> a 
> loop. The obvious way to avoid calculating it twice in an ordinary loop is 
> with 
> a temporary variable:
>
> result = []
> for x in data:
> tmp = expensive_calculation(x)
> result.append((tmp, tmp+1))
>
>
> But what if you are using a list comprehension? Alas, list comps don't let 
> you 
> have temporary variables, so you have to write this:
>
>
> [(expensive_calculation(x), expensive_calculation(x) + 1) for x in data]
>
>
> Or do you? ... no, you don't!
>
>
> [(tmp, tmp + 1) for x in data for tmp in [expensive_calculation(x)]]
>
>
> I can't decide whether that's an awesome trick or a horrible hack...

It is a poor man's 'let'. It would be nice if python had a real 'let'
construction. Or for example:

[(tmp, tmp + 1) for x in data with tmp = expensive_calculation(x)]

Alas!
-- 
Piet van Oostrum 
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list


ANN: pyftpdlib 1.5.2 released

2017-04-06 Thread Giampaolo Rodola'
Hello all,
I'm glad to announce the release of pyftpdlib 1.5.2:
https://github.com/giampaolo/pyftpdlib

About
=

pyftpdlib (process and system utilities) is a cross-platform library for
retrieving information on running processes and system utilization (CPU,
memory, disks, network) in Python. It is useful mainly for system
monitoring, profiling and limiting process resources and management of
running processes. It implements many functionalities offered by command
line tools such as: ps, top, lsof, netstat, ifconfig, who, df, kill, free,
nice, ionice, iostat, iotop, uptime, pidof, tty, taskset, pmap. It
currently supports Linux, Windows, OSX, Sun Solaris, FreeBSD, OpenBSD and
NetBSD, both 32-bit and 64-bit architectures, with Python versions from 2.6
to 3.5 (users of Python 2.4 and 2.5 may use 2.1.3 version). PyPy is also
known to work.

What's new
==

**Enhancements**

- #378: SSL security was improved by disabling SSLv2, SSLv3 and
SSL_COMPRESSION
  features. New TLS_FTPHandler's ssl_options class attribute was added.
- #380: AbstractedFS.listdir() can now return also a generator (not only a
  list).

**Bug fixes**

- #367: ThreadedFTPServer no longer hangs if close_all() is called.
- #394: ETIMEDOUT is not treated as an alias for "connection lost".
- #400: QUIT can raise KeyError in case the user hasn't logged in yet and
sends
  QUIT command.

Links
=

- Home page: https://github.com/giampaolo/pyftpdlib
- Download: https://pypi.python.org/pypi/pyftpdlib
- Documentation: http://pythonhosted.org/pyftpdlib
- What's new: https://github.com/giampaolo/pyftpdlib/blob/master/HISTORY.rst

--

Giampaolo - http://grodola.blogspot.com
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


[issue29533] urllib2 works slowly with proxy on windows

2017-04-06 Thread Julia Dolgova

Julia Dolgova added the comment:

Steve, do you mean that there should be no address to IE configuration from 
urllib? I could undertake it if I understand the task.

gethostbyaddr() is ok. It just makes a reverse lookup, that some dns-servers 
work up too slow. The command "nslookup" also works slowly in same conditions. 
The problem is in those dns-servers I think.

--

___
Python tracker 

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



[issue11978] Report correct coverage.py data for tests that invoke subprocesses

2017-04-06 Thread Nick Coghlan

Nick Coghlan added the comment:

To be more specific regarding `sitecustomize.py`:

$ echo "print('Hello from sitecustomize.py')" > Lib/sitecustomize.py
$ ./python -c "print('Hello from command line')"
Hello from sitecustomize.py
Hello from command line

Since we only need these instructions to work for a local checkout, we can rely 
on the `sitecustomize.py` hook.

It means we'll still miss coverage results from subprocess tests run in 
isolated mode or with site.py processing disabled, but those are both 
relatively rare and involve *not* running code that is normally run, so 
shouldn't impact the aggregate coverage results.

--

___
Python tracker 

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



[issue29989] subprocess.Popen does not handle file-like objects without file descriptors

2017-04-06 Thread Raphael Gaschignard

Raphael Gaschignard added the comment:

the subprocess module has code to handle file objects that don't use file 
descriptors. It's not that file descriptors are necessary for the parameter, 
but that the way POpen is trying to detect "no file descriptor support" is 
through "fileno returns -1" rather than "fileno raises OSError"

--

___
Python tracker 

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



[issue11978] Report correct coverage.py data for tests that invoke subprocesses

2017-04-06 Thread Nick Coghlan

Nick Coghlan added the comment:

As a starting point, I'd suggest looking at what can be achieved without making 
any changes to CPython or its test suite:

1. Set COVERAGE_PROCESS_START in the environment where the tests are being run

2. Inject a sitecustomize.py file into Lib (and add `Lib/sitecustomize.py` to 
`.gitignore`)

There are cases that won't cover (like subprocesses with a custom environment), 
but it will provide a starting point for the tests that just pass the current 
environment through, and will also provide a way to notify 
test.support.script_helper of the expected value of COVERAGE_PROCESS_START in 
the future.

--

___
Python tracker 

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



[issue11978] Report correct coverage.py data for tests that invoke subprocesses

2017-04-06 Thread Jaysinh shukla

Jaysinh shukla added the comment:

I found the regrtest wasn't displaying correct coverage for when the code is 
executed from call `Lib.test.support.script_helper.assert_python_ok`. I found 
`assert_python_ok` is using `subprocess` under the hood. It seems this problem 
is unobserved from a long time but it is having status `open`.

What should be the ideal situation for this? I request any core-developer to 
guide on this. I am interested in doing some more research on this issue. 
Thanks!

--
nosy: +jaysinh.shukla

___
Python tracker 

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



[issue29989] subprocess.Popen does not handle file-like objects without file descriptors

2017-04-06 Thread Xiang Zhang

Xiang Zhang added the comment:

Hmm, what do you mean by 'the raised exception is not handled properly'? 
Currently the exception is just propagated to the user to signal the argument 
seems to be wrong, right?

--
nosy: +xiang.zhang

___
Python tracker 

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



[issue30003] Remove hz codec

2017-04-06 Thread Ma Lin

Ma Lin added the comment:

I tried to fix this two years ago, here is the patch (not merged):
http://bugs.python.org/review/24117/diff/14803/Modules/cjkcodecs/_codecs_cn.c

But later, I thought it's a good opportunity to remove this codec, this serious 
bug indicates that almost no one is using it. But fixing will create a 
possibility that someone will using it in future.
So I suggest we don't fix it, just remove it or leave it as is.

hz is outdated, searching on internet almost no one talking about it.

> Or do you know other bugs?
It has another small bug in decoder, about state switch, but it's trivial, also 
fixed in the patch.

--

___
Python tracker 

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



[issue29990] Range checking in GB18030 decoder

2017-04-06 Thread Ma Lin

Ma Lin added the comment:

This is a very trivial bug, it's hard to imagine a scene that someone trying to 
decode those 8630 illegal 4-byte sequences with GB18030 decoder.
And I think this bug can't lead to security vulnerabilities.

As far as I can see, GB2312/GBK/GB18030 codecs are bugfree except this bug, of 
course maybe I'm wrong.

--

___
Python tracker 

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



[issue30003] Remove hz codec

2017-04-06 Thread STINNER Victor

STINNER Victor added the comment:

Can't we fix the bug instead of removing the whole codec? Or do you know other 
bugs?

The bug is only on the encoder part, right? I see unit test for '~' on the hz 
decoder.

--

___
Python tracker 

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



[issue29990] Range checking in GB18030 decoder

2017-04-06 Thread STINNER Victor

STINNER Victor added the comment:

An incorrect implementation of a decoder might lead to security vulnerabilities:
http://unicodebook.readthedocs.io/issues.html#security-vulnerabilities

*But* UTF-8 decoder of Python 2 is *not* strict and nobody complained.

I suggest that, once the changed is merged in master, backport the fix to 3.6 
and 3.5.

But I'm not sure that it's worth it to backport it to 2.7? Is there a risk to 
break an application?

--

___
Python tracker 

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



[issue30005] Pickling and copying exceptions doesn't preserve non-__dict__ attributes

2017-04-06 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
dependencies: +Pickling and copying ImportError doesn't preserve name and path

___
Python tracker 

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



[issue30005] Pickling and copying exceptions doesn't preserve non-__dict__ attributes

2017-04-06 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Pickling and copying exceptions preserves only __dict__ attributes.

This includes writeable internal fields initialized in constructor:

>>> import pickle, copy
>>> e = StopIteration(12)
>>> e.value = 34
>>> e.value
34
>>> e2 = pickle.loads(pickle.dumps(e, 4))
>>> e2.value
12
>>> e2 = copy.copy(e)
>>> e2.value
12

And __slots__:

>>> class E(Exception): __slots__ = ('x', 'y')
... 
>>> e = E()
>>> e.x = 12
>>> e.x
12
>>> e2 = pickle.loads(pickle.dumps(e, 4))
>>> e2.x
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: x
>>> e2 = copy.copy(e)
>>> e2.x
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: x

__context__, __cause__ and __traceback__ are lost too (see issue29466).

Issue26579 is similar, but resolving it will not resolve this issue since 
BaseException has its own __reduce__ and __setstate__ implementations.

The solution of this issue will look similar to issue29998, but more complex 
and general.

--
components: Interpreter Core
messages: 291212
nosy: alexandre.vassalotti, serhiy.storchaka
priority: normal
severity: normal
stage: needs patch
status: open
title: Pickling and copying exceptions doesn't preserve non-__dict__ attributes
type: behavior
versions: Python 2.7, 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