[issue21085] Cygwin does not provide siginfo_t.si_band

2016-09-30 Thread Zachary Ware

Changes by Zachary Ware :


--
title: compile error Python3.3 on Cygwin -> Cygwin does not provide 
siginfo_t.si_band

___
Python tracker 

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



[issue21085] compile error Python3.3 on Cygwin

2016-09-30 Thread Zachary Ware

Zachary Ware added the comment:

Thanks for the patch, masamoto, and thanks for the review and rebase, erik.bray!

I only applied this to 3.7.  It's much more open to experimentation currently, 
and we have a way to go before Python can even be built on Cygwin.  Once we 
reach a more stable point (say, the full test suite can be run, even if not 
everything passes), we can evaluate whether backporting all the changes it took 
to get there is worthwhile.

--
assignee: erik.bray -> zach.ware
nosy: +zach.ware
resolution:  -> fixed
stage: commit review -> resolved
status: open -> closed
versions: +Python 3.7 -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



Re: how to append to list in list comprehension

2016-09-30 Thread Sayth Renshaw
On Saturday, 1 October 2016 14:17:06 UTC+10, Rustom Mody  wrote:
> On Saturday, October 1, 2016 at 9:08:09 AM UTC+5:30, Sayth Renshaw wrote:
> > I do like [(f + ['0'] if len(f) < 5 else f) for f in fups ] Rustom, if 
> > there are better non list comprehension options I would like to know as 
> > generally I find then confusing.
> 
> Two points here — best taken independently:
> 1. List comprehensions are confusing
> 2. When to want/not want them
> 
> 
> For 1 I suggest you (privately) rewrite them with '|' for 'for' and '∈' for 
> 'in'
> Once you do that they will start looking much more like the origin that 
> inspires
> them — set builder notation:
> https://en.wikipedia.org/wiki/Set-builder_notation
> 
> From there I suggest you play with replacing '[]' with '{}' ie actually try
> out set comprehensions and then others like dict-comprehensions — very nifty
> and oft-neglected. And the mother of all — generator comprehensions.
> 
> Of course to check it out in python you will need to invert the translation:
> '|' for 'for' and '∈' for 'in'
> the point of which is to use python as a kind of math assembly language
> *into* which you *code* but not in which you *think*
> 
> For 2 its important that you always keep in front of you whether you want to
> approach a problem declaratively (the buzzword FP!) or imperatively.
> Python is rather unique in the extent to which it allows both
> This also makes it uniquely difficult because its all too easy to garble the 
> two styles as John's .append inside a LC illustrates.
> 
> And the way to ungarble your head is by asking yourself the meta-question:
> Should I be asking "How to solve this (sub)problem?" or more simply
> "What is the (sub)problem I wish to solve?"
> 
> How questions naturally lead to imperative answers; whats to declarative
> 
> You may be helped with [plug!] my writings on FP:
> http://blog.languager.org/search/label/FP
> 
> Particularly the tables in:
> http://blog.languager.org/2016/01/primacy.html

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


[issue21085] compile error Python3.3 on Cygwin

2016-09-30 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 6874928eae4b by Zachary Ware in branch 'default':
Issue #21085: add configure check for siginfo_t.si_band
https://hg.python.org/cpython/rev/6874928eae4b

--
nosy: +python-dev

___
Python tracker 

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



[issue27897] Avoid possible crash in pysqlite_connection_create_collation

2016-09-30 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thanks Martin!

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



[issue27897] Avoid possible crash in pysqlite_connection_create_collation

2016-09-30 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 38e954a2a37e by Serhiy Storchaka in branch '2.7':
Issue #27897: Fixed possible crash in sqlite3.Connection.create_collation()
https://hg.python.org/cpython/rev/38e954a2a37e

--

___
Python tracker 

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



Re: unintuitive for-loop behavior

2016-09-30 Thread Rustom Mody
On Saturday, October 1, 2016 at 8:55:19 AM UTC+5:30, Random832 wrote:
> On Fri, Sep 30, 2016, at 20:46, Gregory Ewing wrote:
> > What *is* necessary and sufficient is to make each iteration
> > of the for-loop create a new binding of the loop variable
> > (and not any other variable!).
> 
> I don't think that's true. I think this is logic that is excessively
> tied to the toy examples that are used to illustrate the problem.
> 
> You don't think it's common [at least, as far as defining a lambda
> inside a loop at all is common] to do something like this?
> 
> for a in collection:
> b = some_calculation_of(a)
> do_something_with(lambda: ... b ...)

Common? — Dunno
What I know — Yuck!

[Yeah… someone brought up on Lisp and APL and who finds C++ terrifying!]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Lawrence D'Oliveiro

2016-09-30 Thread Rustom Mody
On Saturday, October 1, 2016 at 10:04:01 AM UTC+5:30, Rustom Mody wrote:
> On Friday, September 30, 2016 at 10:45:03 PM UTC+5:30, Ethan Furman wrote:
> > Lawrence D'Oliveiro is banned from Python List until the new year.
> > 
> > If his posts show up somewhere else (e.g. Usenet), please ignore them.  If 
> > you must respond to him please trim out his text so the rest of us don't 
> > have to deal with him.
> > 
> > --
> > Python List Moderators
> 
> Sure Lawrence was/is being rude/difficult/whatever but does it warrant that 
> much
> severity?
> 
> If we consider the 4 cases (I know in recent times) that have been banned
> 1. Mark Lawrence
> 2. Thomas Lahn
> 3. jmf
> 4. and now Lawrence d'Oliveiro
> 
> that is also the (my subjective) order of rudeness (jmf is never rude but
> highly troublesome)

I meant to say “in decreasing order”
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Lawrence D'Oliveiro

2016-09-30 Thread Rustom Mody
On Friday, September 30, 2016 at 10:45:03 PM UTC+5:30, Ethan Furman wrote:
> Lawrence D'Oliveiro is banned from Python List until the new year.
> 
> If his posts show up somewhere else (e.g. Usenet), please ignore them.  If 
> you must respond to him please trim out his text so the rest of us don't have 
> to deal with him.
> 
> --
> Python List Moderators

Sure Lawrence was/is being rude/difficult/whatever but does it warrant that much
severity?

If we consider the 4 cases (I know in recent times) that have been banned
1. Mark Lawrence
2. Thomas Lahn
3. jmf
4. and now Lawrence d'Oliveiro

that is also the (my subjective) order of rudeness (jmf is never rude but
highly troublesome)

Of course you/other-mods will have your own metrics
But please run your own abuse-metric-eval on this case again
And there is found a bug therein consider toning down 2 months to (say) 2 weeks

None of the above gainsays the fact that you folks — list-mods — do a onerous
splendid, mostly invisible job. For which thanks!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to append to list in list comprehension

2016-09-30 Thread Rustom Mody
On Saturday, October 1, 2016 at 9:08:09 AM UTC+5:30, Sayth Renshaw wrote:
> I do like [(f + ['0'] if len(f) < 5 else f) for f in fups ] Rustom, if there 
> are better non list comprehension options I would like to know as generally I 
> find then confusing.

Two points here — best taken independently:
1. List comprehensions are confusing
2. When to want/not want them


For 1 I suggest you (privately) rewrite them with '|' for 'for' and '∈' for 'in'
Once you do that they will start looking much more like the origin that inspires
them — set builder notation:
https://en.wikipedia.org/wiki/Set-builder_notation

From there I suggest you play with replacing '[]' with '{}' ie actually try
out set comprehensions and then others like dict-comprehensions — very nifty
and oft-neglected. And the mother of all — generator comprehensions.

Of course to check it out in python you will need to invert the translation:
'|' for 'for' and '∈' for 'in'
the point of which is to use python as a kind of math assembly language
*into* which you *code* but not in which you *think*

For 2 its important that you always keep in front of you whether you want to
approach a problem declaratively (the buzzword FP!) or imperatively.
Python is rather unique in the extent to which it allows both
This also makes it uniquely difficult because its all too easy to garble the 
two styles as John's .append inside a LC illustrates.

And the way to ungarble your head is by asking yourself the meta-question:
Should I be asking "How to solve this (sub)problem?" or more simply
"What is the (sub)problem I wish to solve?"

How questions naturally lead to imperative answers; whats to declarative

You may be helped with [plug!] my writings on FP:
http://blog.languager.org/search/label/FP

Particularly the tables in:
http://blog.languager.org/2016/01/primacy.html
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28275] LZMADecompressor.decompress Use After Free

2016-09-30 Thread Martin Panter

Changes by Martin Panter :


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



[issue28276] test_loading.py - false positive result for "def test_find" when find_library() is not functional or the (shared) library does not exist

2016-09-30 Thread Martin Panter

Martin Panter added the comment:

Other tests in this file skip the test if libc_name is None. So I think it 
would make more sense to skip the test rather than fail in test_find(). I.e.

if not found:
self.skipTest("Could not find c and m libraries")

If you are confident that find_library() will always find libc on AIX, perhaps 
you can suggest an extra test (or add to an existing test), to first check for 
the AIX platform, and only then fail if find_library() returned None.

--

___
Python tracker 

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



Re: unintuitive for-loop behavior

2016-09-30 Thread Steve D'Aprano
On Sat, 1 Oct 2016 10:46 am, Gregory Ewing wrote:

> Steve D'Aprano wrote:
>> Giving for-loops their own namespace is a grossly unintuitive and a very
>> weird thing to do.
>> 
>> It would be terribly inconvenient and surprising for if...else blocks to
>> be separate namespaces:
> 
> There's an important difference between a for-loop and an
> if-statement that's relevant here: a for-loop binds a name,
> whereas an if-statement doesn't.

That's incorrect: either can bind any number of names:

if condition:
a = 1
b = 2
else:
a = 222
b = 111


for i in seq:
x = i + 1
y = x**2
z = 3*y



> Whenever there's binding going on, it's necessary to decide
> whether it should be creating a new binding or updating an
> existing one.

Right.


> This is actually a *different* issue from one of scope.
> List comprehensions were changed so that the loop variable
> lives in a different scope from the containing function.
> However, they still have the same unintuitive behaviour
> with regard to capture of the loop variable by a lambda.
> 
>  >> l = [lambda: i for i in range(3)]
>  >>> for f in l: print(f())
> ...
> 2
> 2
> 2
> 
> Most people consider *this* behaviour to be far weirder
> than anything that would result from giving for-loop
> variables their own scope.
> 
> Even if you don't think it's weird, it's hard to argue
> that it's *useful* in any significant number of cases.

Firstly, let's agree (or perhaps we don't?) that loop variables are the same
kind of variable as any other. It would be strange and confusing to have
different kinds of variables with different binding and lookup rules based
on where they came from.

The whole list comprehension and lambda syntax is a red herring. Let's write
it like this:

alist = []
for i in (0, 1, 2):
def func():
return i
alist.append(func)

for f in alist:
print(f())



And the output is the same:

2
2
2


Okay, that's inconvenient and not what I wanted. Obviously. But as they say
about computers, "this damn machine won't do what I want, only what I tell
it to do". It did *exactly what I told it to do*, and, yes, that is a good
thing. Let's remember that the variable i is no more special than any other
variable:

alist = []
x = 0
for i in (0, 1, 2):
def func():
return x
alist.append(func)

x = 999
# What do you predict the functions will return?
for f in alist:
print(f())



Are you surprised that each of the func()'s return the same value, the
current value of x instead of whatever accidental value of x happened to
exist when the function was defined? I should hope not. I would expect that
most people would agree that variable lookups should return the value of
the variable *as it is now*, not as it was when the function was defined.
Let's call that Rule 1, and I say it is fundamental to being able to reason
about code. If I say:

x = 1
spam(x)

then spam() MUST see the current value of x, namely 1, not some mysterious
value of x that happened to exist long ago in the mists of time when spam()
was first defined. And Rule 1 needs to apply to ALL variable look ups, not
just arguments to functions.


Closures, of course, are a special case of Rule 1, not an exception:

def make(arg):
x = arg
def func():
   return x
return func

f = make(0)
print(f())


*Without* closures, that would lead to a NameError (unless there happened to
be a global called "x"): the local variables of make() no longer exist, so
you cannot refer to them. That was the behaviour in Python 1.5, for
example.

But *with* closures, the local variables still exist: the inner function
grabs the surrounding environment (or at least as much as it needs) and
keeps it alive, so that it can look up names in that surrounding scope.

What do you expect should happen here?

def make(arg):
x = arg
def func():
   return x
x = 999
return func

f = make(0)
print(f())


By Rule 1, the only sensible behaviour is for f() to return 999, regardless
of whether it is convenient or not, regardless of whether that is what I
intended or not. The interpreter shouldn't try to guess what I mean, it
shouldn't cache variable look-ups, and it shouldn't try to give x special
behaviour different from all other variables just so this special case is
more convenient.

But wait, I hear you say, what about closures? They cache the value of the
surrounding variables don't they? Perhaps in a sense, but only a weak
sense. Each call to make() creates a *new* local environment (its a
function, each time you call a function it starts completely afresh) so
each of the inner functions returned is independent of the others, with its
own independent closure. And each inner function still looks up the current
value of *their own* closed-over x, not a snapshot of x as it was when the
inner function was defined.

Final step: let's unroll that original loop.

l = [lambda: i for i in range(3)]
for f in l: print(f())


becomes:

l = []
i = 0

Re: unintuitive for-loop behavior

2016-09-30 Thread Rustom Mody
For the most part you've taken the words out of my mouth!
Some more details...

On Saturday, October 1, 2016 at 6:16:32 AM UTC+5:30, Gregory Ewing wrote:
> Steve D'Aprano wrote:
> > Giving for-loops their own namespace is a grossly unintuitive and a very
> > weird thing to do.
> > 
> > It would be terribly inconvenient and surprising for if...else blocks to be
> > separate namespaces:
> 
> There's an important difference between a for-loop and an
> if-statement that's relevant here: a for-loop binds a name,
> whereas an if-statement doesn't.
> 
> Whenever there's binding going on, it's necessary to decide
> whether it should be creating a new binding or updating an
> existing one.
> 
> This is actually a *different* issue from one of scope.
> List comprehensions were changed so that the loop variable
> lives in a different scope from the containing function.
> However, they still have the same unintuitive behaviour
> with regard to capture of the loop variable by a lambda.
> 
>  >> l = [lambda: i for i in range(3)]
>  >>> for f in l: print(f())
> ...
> 2
> 2
> 2
> 
> Most people consider *this* behaviour to be far weirder
> than anything that would result from giving for-loop
> variables their own scope.
> 
> Even if you don't think it's weird, it's hard to argue
> that it's *useful* in any significant number of cases.
> 
> > To me, "make for-loops be their own scope" sounds like a joke feature out of
> > joke languages like INTERCAL.
> 
> Which is a straw man, since that's not actually what we're
> talking about doing. It's neither necessary nor sufficient
> to solve the problem.
> 
> What *is* necessary and sufficient is to make each iteration
> of the for-loop create a new binding of the loop variable
> (and not any other variable!).


Yes one basic problem with comprehensions in python is that they are 
defined by assignment not binding to the comprehension variable

> 
> > I'm not aware of any sensible language that
> > does anything like this.
> 
> Scheme and Ruby come to mind as examples of languages in
> which the equivalent of a for-loop results in each iteration
> getting a new binding of the control variable. Although
> you could argue that these languages are not "sensible". :-)

Python copied comprehensions from haskell and copied them wrong

Here are all the things (that I can think of) that are wrong:
1. Scope leakage from inside to outside the comprehension
2. Scope leakage from one value to the next
3. The name 'for' misleadingly associates for-loops and comprehensions
4. The for-loop based implementation strategy made into definitional semantics
5. The absence of simple binding inside comprehensions:
   [f(newvar) for v in l newvar = rhs]

1 was considered sufficiently important to make a breaking change from python2 
to 3
2 is what causes the lambda gotcha
3 is what makes noobs to take longer than necessary to grok them
4 is what causes a useless distinction between 1 and 2 — scope leakage is scope
leakage. The explanatory mechanisms of why/whither/what etc should at best be 
secondary
5. is workaroundable with a [... for newvar in [rhs]]
   Possible and clunky
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to append to list in list comprehension

2016-09-30 Thread Sayth Renshaw

> > I want to go threw and for each index error at [4] append a 0.
> 
> You want to append 0 if the list does not have at least 5 items?
> 
> > p = re.compile('\d+')
> > fups = p.findall(nomattr['firstup'])
> > [x[4] for x in fups if IndexError fups.append(0)]
> > print(fups)
> 
> > Unsure why I cannot use append in this instance
> 
> Because that's incorrect syntax.
> 
> > how can I modify to acheive desired output?
> 
> for f in fups:
> if len(f) < 5:
> f.append(0)
> 
> Or, if you really want to use a list comprehension:
> 
>   [f.append(0) for f in fups if len(f) < 5]
> 
> However there's no reason to use a list comprehension here.  The whole
> point of list comprehensions is to create a *new* list, which you don't
> appear to need; you just need to modify the existing fups list.
> 
> -- 
> John Gordon   A is for Amy, who fell down the stairs
 B is for Basil, assaulted by bears
> -- Edward Gorey, "The Gashlycrumb Tinies"

You are right John in that I don't want a new list I just wish to modify 
in-place to acheive the desired output.

I had no direct desire to use list comprehension just seemed an option.

Ultimately once it works I will abstract it into a function for other lists 
that will have a similar issue.

def listClean(fups)
holder = [(f + ['0'] if len(f) < 5 else f) for f in fups ] 
return holder[0], holder[1], holder[2], holder[3], holder[4]

and then call it in my csv.writer that I have, which currently errors quite 
correctly that it cannot write index[4] as some of my lists fail it.


I do like [(f + ['0'] if len(f) < 5 else f) for f in fups ] Rustom, if there 
are better non list comprehension options I would like to know as generally I 
find then confusing.
Cheers

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


Re: how to append to list in list comprehension

2016-09-30 Thread Rustom Mody
On Saturday, October 1, 2016 at 7:48:19 AM UTC+5:30, John Gordon wrote:
> In Sayth Renshaw  writes:
> 
> > I want to go threw and for each index error at [4] append a 0.
> 
> You want to append 0 if the list does not have at least 5 items?
> 
> > p = re.compile('\d+')
> > fups = p.findall(nomattr['firstup'])
> > [x[4] for x in fups if IndexError fups.append(0)]
> > print(fups)
> 
> > Unsure why I cannot use append in this instance
> 
> Because that's incorrect syntax.
> 
> > how can I modify to acheive desired output?
> 
> for f in fups:
> if len(f) < 5:
> f.append(0)
> 
> Or, if you really want to use a list comprehension:
> 
>   [f.append(0) for f in fups if len(f) < 5]

Wrong

fups = [['0', '0', '0', '0'],
['0', '0', '0', '0'],
['0', '0', '0', '0'],
['0', '0', '0', '0'],
['0', '0', '0', '0'],
['0', '0', '0', '0'],
['7', '2', '1', '0', '142647', '00'],
['7', '2', '0', '1', '87080', '00'],
['6', '1', '1', '1', '51700', '00'],
['4', '1', '1', '0', '36396', '00'] ]

>>> [f.append(0) for f in fups if len(f) < 5] 
[None, None, None, None, None, None]

Or right if you re-squint:

>>> fups
[['0', '0', '0', '0', 0], ['0', '0', '0', '0', 0], ['0', '0', '0', '0', 0], 
['0', '0', '0', '0', 0], ['0', '0', '0', '0', 0], ['0', '0', '0', '0', 0], 
['7', '2', '1', '0', '142647', '00'], ['7', '2', '0', '1', '87080', '00'], 
['6', '1', '1', '1', '51700', '00'], ['4', '1', '1', '0', '36396', '00']]
>>> 

Which is to say that imperative code — .append — inside a comprehension 
is a bad idea

One comprehension way to do it would be:

>>> [(f + ['0'] if len(f) < 5 else f) for f in fups ]
[['0', '0', '0', '0', '0'], ['0', '0', '0', '0', '0'], ['0', '0', '0', '0', 
'0'], ['0', '0', '0', '0', '0'], ['0', '0', '0', '0', '0'], ['0', '0', '0', 
'0', '0'], ['7', '2', '1', '0', '142647', '00'], ['7', '2', '0', '1', '87080', 
'00'], ['6', '1', '1', '1', '51700', '00'], ['4', '1', '1', '0', '36396', '00']]
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28275] LZMADecompressor.decompress Use After Free

2016-09-30 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 36d37ff6c236 by Martin Panter in branch '3.5':
Issue #28275: Clean up to avoid use-after-free after bzip decompress failure
https://hg.python.org/cpython/rev/36d37ff6c236

New changeset dca18f0ec280 by Martin Panter in branch '3.6':
Issue #28275: Merge bz2 fix from 3.5 into 3.6
https://hg.python.org/cpython/rev/dca18f0ec280

New changeset 35b5f4cc08f4 by Martin Panter in branch 'default':
Issue #28275: Merge bz2 fix from 3.6
https://hg.python.org/cpython/rev/35b5f4cc08f4

--

___
Python tracker 

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



Re: unintuitive for-loop behavior

2016-09-30 Thread Random832
On Fri, Sep 30, 2016, at 20:46, Gregory Ewing wrote:
> What *is* necessary and sufficient is to make each iteration
> of the for-loop create a new binding of the loop variable
> (and not any other variable!).

I don't think that's true. I think this is logic that is excessively
tied to the toy examples that are used to illustrate the problem.

You don't think it's common [at least, as far as defining a lambda
inside a loop at all is common] to do something like this?

for a in collection:
b = some_calculation_of(a)
do_something_with(lambda: ... b ...)

There's a reason that C++'s solution to this problem is an explicit list
of what names are captured as references vs values inside the lambda.

I think what we really need is an explicit expression/block that gives a
list of names and says that all uses of that name in any function
defined inside the expression/block refer to the value that that
expression had when the expression/block was entered.

Suppose:

[final exponent: lambda base: (base ** exponent) for exponent in
range(9)]

for exponent in range: 9
   final exponent:
   def pwr(base):
   return base ** exponent
   result.append(pwr)

for a in collection:
b = some_calculation_of(a)
final b: do_something_with(lambda: ... b ...)

Maybe do stuff like "for final var in ..." for both loops and
comprehensions, or "final var = expr:", depending on if we can make the
intuitive-looking syntax well-defined. "final" is a placeholder for
whatever new keyword is chosen, though I will note that even though IIRC
Guido doesn't like this sort of thing, it would only appear next to
identifiers in the proposed syntax and two identifiers not joined by an
operator is meaningless.

An alternative would be, considering that the problem only applies to
nested functions, to expand the "keyword argument" hack into a
less-"hacky" and less verbose solution, e.g. "lambda base, $exponent:
base ** exponent" - creating, in effect, a keyword argument with the
name 'exponent' that can't actually be passed in to the function.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to make a foreign function run as fast as possible in Windows?

2016-09-30 Thread Chris Angelico
On Sat, Oct 1, 2016 at 11:27 AM,   wrote:
> At this moment my interest is how to make it runs at 100% core usage. Windows 
> task manager shows this function takes only ~70% usage, and the number varies 
> during its execution, sometimes even drop to 50%.
>

What's it doing? Not every task can saturate the CPU - sometimes they
need the disk or network more.

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


[issue27897] Avoid possible crash in pysqlite_connection_create_collation

2016-09-30 Thread Martin Panter

Martin Panter added the comment:

The test in 2.7 (1aae9b7ff321) seems to cause a Windows 8.1 buildbot to hang in 
test_sqlite. I deduced this because there is no mention of "test_sqlite" in the 
test log output, compared to a previous successful test log.

http://buildbot.python.org/all/builders/AMD64%20Windows8.1%20Non-Debug%202.7/builds/474

--
nosy: +martin.panter

___
Python tracker 

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



Re: Could find libpython.so after succesfull compilation.

2016-09-30 Thread Steven Truppe
Damn i'm so stupid... the files where in fron on of my eyes and i was 
just not able to find then ..



On 2016-10-01 02:23, Steven Truppe wrote:

Hi all,


i've compiled python3.5 and all went fine, i find ./python and it 
works, most of the make test stuff is working my only problem is that 
i'm not able to find libpython.so 



am i missing somehting ?


Thianks in advance



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


[issue28288] Expose environment variable for Py_Py3kWarningFlag

2016-09-30 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the patch. I left some comments on Rietveld.

--
stage: test needed -> patch review

___
Python tracker 

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



Re: how to append to list in list comprehension

2016-09-30 Thread John Gordon
In <534d5506-1810-4a79-ac8f-95a664d17...@googlegroups.com> Sayth Renshaw 
 writes:

> I want to go threw and for each index error at [4] append a 0.

You want to append 0 if the list does not have at least 5 items?

> p = re.compile('\d+')
> fups = p.findall(nomattr['firstup'])
> [x[4] for x in fups if IndexError fups.append(0)]
> print(fups)

> Unsure why I cannot use append in this instance

Because that's incorrect syntax.

> how can I modify to acheive desired output?

for f in fups:
if len(f) < 5:
f.append(0)

Or, if you really want to use a list comprehension:

  [f.append(0) for f in fups if len(f) < 5]

However there's no reason to use a list comprehension here.  The whole
point of list comprehensions is to create a *new* list, which you don't
appear to need; you just need to modify the existing fups list.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: Could find libpython.so after succesfull compilation.

2016-09-30 Thread Steven Truppe

I fond this in the ./configuration help:

*  --enable-shared disable/enable building shared python library*

so i tried:

$configure --enabled-shard

but i can't still find a library inside my build directory.



On 2016-10-01 02:23, Steven Truppe wrote:

Hi all,


i've compiled python3.5 and all went fine, i find ./python and it 
works, most of the make test stuff is working my only problem is that 
i'm not able to find libpython.so 



am i missing somehting ?


Thianks in advance



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


[issue28225] bz2 does not support pathlib

2016-09-30 Thread Berker Peksag

Changes by Berker Peksag :


--
nosy: +berker.peksag

___
Python tracker 

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



[issue27511] Add PathLike objects support to BZ2File

2016-09-30 Thread Berker Peksag

Changes by Berker Peksag :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> bz2 does not support pathlib

___
Python tracker 

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



[issue28228] imghdr does not support pathlib

2016-09-30 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the review, Brett!

The next target is gzip module. Thanks for the all patches Ethan :)

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

___
Python tracker 

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



[issue28227] gzip does not support pathlib

2016-09-30 Thread Berker Peksag

Changes by Berker Peksag :


--
nosy: +berker.peksag

___
Python tracker 

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



how to append to list in list comprehension

2016-09-30 Thread Sayth Renshaw
I have a list of lists of numbers like this excerpt.

['0', '0', '0', '0']
['0', '0', '0', '0']
['0', '0', '0', '0']
['0', '0', '0', '0']
['0', '0', '0', '0']
['0', '0', '0', '0']
['7', '2', '1', '0', '142647', '00']
['7', '2', '0', '1', '87080', '00']
['6', '1', '1', '1', '51700', '00']
['4', '1', '1', '0', '36396', '00']

I want to go threw and for each index error at [4] append a 0.

I have called the lists fups.

p = re.compile('\d+')
fups = p.findall(nomattr['firstup'])
[x[4] for x in fups if IndexError fups.append(0)]
print(fups)

Unsure why I cannot use append in this instance, how can I modify to acheive 
desired output?

Desired Output
['0', '0', '0', '0', '0']
['0', '0', '0', '0', '0']
['0', '0', '0', '0', '0']
['0', '0', '0', '0', '0']
['0', '0', '0', '0', '0']
['0', '0', '0', '0', '0']
['7', '2', '1', '0', '142647', '00']
['7', '2', '0', '1', '87080', '00']
['6', '1', '1', '1', '51700', '00']
['4', '1', '1', '0', '36396', '00']

Thanks

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


[issue28228] imghdr does not support pathlib

2016-09-30 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 929e3adefe7a by Berker Peksag in branch '3.6':
Issue #28228: imghdr now supports pathlib
https://hg.python.org/cpython/rev/929e3adefe7a

New changeset 013b3b5d3b6c by Berker Peksag in branch 'default':
Issue #28228: Merge from 3.6
https://hg.python.org/cpython/rev/013b3b5d3b6c

--
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: What is a mechanism equivalent to "trace variable w ..." in Tcl for Python?

2016-09-30 Thread Terry Reedy

On 9/30/2016 2:23 PM, Les Cargill wrote:


A really interesting design approach in Tcl is to install a callback
when a variable is written to. This affords highly event-driven
programming.

Example ( sorry; it's Tcl  ) :


namespace eval events {
set preRPM -1
proc handleRPM { args } {
# do stuff to handle an RPM change here
variable ::motor::RPM
variable preRPM
puts "RPM changed from $preRPM to $RPM
set preRPM $RPM
}
}

...

trace variable ::motor::RPM w ::events::handleRPM


'trace variable' and the corresponding 'trace vdelete' and trace vinfo' 
have been deprecated in favor of the newer 'trace add variable', 'trace 
remove variable', and 'trace info variable.  In 3.6, the tkinter 
Variable class has corresponding new trace_add, trace_remove, and 
trace_info methods.



...

set ::motor::RPM 33.33


The cost of being able to trace variables is having to set them through 
a method that can check for the existence of callbacks.  The are used in 
tk to connect the values of widgets.



What is an equivalent mechanism in Python?


Python has a trace module for functions and lines, rather than 
variables.  I believe the primary intended use is for debugging.


The Variable class in tkinter.__init__, currently about line 290, wraps 
the tcl mechanism so it literally is the 'equivalent mechanism' in 
Python.  It could be rewritten to do everything in Python instead of 
calling into tk.  However, it can also be used as it without displaying 
a gui window.  Use what you already know.


import tkinter as tk
root = tk.Tk()  # Only needed to create Vars.
root.withdraw()  # So keep it invisible.

avar = tk.StringVar(root)
avar.trace_add('write', lambda tk_id, unknown, mode:
   print(avar.get(), tk_id, unknown, mode))
# See >>> help(tk.Variable.trace_add) for more.
avar.set('abc')
avar.set('def')

* prints
abc PY_VAR0  write  # 'unknown' == ''
def PY_VAR0  write

Since you are familiar with tcl, you could potentially use root.call() 
to call into tcl yourself.


There are other packages in Python that implement the idea of 
broadcasting a change to a set of reistered listeners.


--
Terry Jan Reedy

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


Re: How to make a foreign function run as fast as possible in Windows?

2016-09-30 Thread jfong
Paul  Moore at 2016/9/30 7:07:35PM wrote:
> OK. So if your Python code only calls the function once, the problem needs to 
> be fixed in the external code (the assembly routine). But if you can split up 
> the task at the Python level to make multiple calls to the function, each to 
> do a part of the task, then you could set up multiple threads in your Python 
> code, each of which handles part of the task, then Python merges the results 
> of the sub-parts to give you the final answer. Does that make sense to you? 
> Without any explicit code, it's hard to be sure I'm explaining myself clearly.
> 

That's what I will do later, to split the task into multiple cores by passing a 
range parameter (such as 0~14, 15~29, ..) to each instance. Right now, I just 
embedded the range in the function to make it simple on testing.

At this moment my interest is how to make it runs at 100% core usage. Windows 
task manager shows this function takes only ~70% usage, and the number varies 
during its execution, sometimes even drop to 50%.

I also had test a batch file (copied from another discussion forum):
@echo off
:loop
goto loop
It takes ~85% usage, and the number is stable.

The result is obviously different. My question is how to control it:-)

--Jach

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


[issue28259] Ctypes bug windows

2016-09-30 Thread Steve Dower

Steve Dower added the comment:

You keep removing the Windows component - is this not actually a bug on Windows?

--

___
Python tracker 

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



[issue28283] test_sock_connect_sock_write_race() of test.test_asyncio.test_selector_events fails randomly on FreeBSD

2016-09-30 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f7688db81753 by Berker Peksag in branch '3.5':
Issue #28283: Remove flaky test test_sock_connect_sock_write_race again
https://hg.python.org/cpython/rev/f7688db81753

New changeset 0fe04467c4b5 by Berker Peksag in branch '3.6':
Issue #28283: Merge from 3.5
https://hg.python.org/cpython/rev/0fe04467c4b5

New changeset 4ba2f6bce7f4 by Berker Peksag in branch 'default':
Issue #28283: Merge from 3.6
https://hg.python.org/cpython/rev/4ba2f6bce7f4

--

___
Python tracker 

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



Re: unintuitive for-loop behavior

2016-09-30 Thread Gregory Ewing

Steve D'Aprano wrote:

What happens if it is *not* a misfeature? Gotchas are not always
misfeatures -- sometimes gotchas are gotchas because people's expectations
are simply wrong, and pandering to their confused expectations does not
actually help them.

I haven't made up my mind about *this* specific (mis)feature itself.


Here's my analysis of it.

First, some definitions:

Current behaviour: The way for-loop variables currently
interact with nested functions.

Alternative behaviour: A nested function captures a
different instance of the for-loop variable on each
iteration. (But *nothing* else changes; in particular,
the body of the loop is *not* a separate scope.)

The current behaviour is completely useless (or at least it's
useful in in only a vanishingly small proportion of cases).
The alternative behaviour would sometimes be useful.

Nothing would need to change except in the rare case where
the loop variable is referenced by a nested function. You
would only pay for the feature if you used it.

There would be no need for ugly workarounds such as default
argument abuse or introducing another level of nested
function.

As a bonus, the alternative behaviour would be more in
line with people's intuitions.

There are some sharp contrasts here with the default
argument situation. There, the alternative behaviour would
be very wasteful in the majority of cases, and there is
a clean workaround for cases where a mutable default is
needed.

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


[issue28226] compileall does not support pathlib

2016-09-30 Thread Berker Peksag

Changes by Berker Peksag :


--
status: open -> closed

___
Python tracker 

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



Could find libpython.so after succesfull compilation.

2016-09-30 Thread Steven Truppe

Hi all,


i've compiled python3.5 and all went fine, i find ./python and it works, 
most of the make test stuff is working my only problem is that i'm not 
able to find libpython.so 



am i missing somehting ?


Thianks in advance

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


Re: unintuitive for-loop behavior

2016-09-30 Thread Gregory Ewing

Steve D'Aprano wrote:

Giving for-loops their own namespace is a grossly unintuitive and a very
weird thing to do.

It would be terribly inconvenient and surprising for if...else blocks to be
separate namespaces:


There's an important difference between a for-loop and an
if-statement that's relevant here: a for-loop binds a name,
whereas an if-statement doesn't.

Whenever there's binding going on, it's necessary to decide
whether it should be creating a new binding or updating an
existing one.

This is actually a *different* issue from one of scope.
List comprehensions were changed so that the loop variable
lives in a different scope from the containing function.
However, they still have the same unintuitive behaviour
with regard to capture of the loop variable by a lambda.

>> l = [lambda: i for i in range(3)]
>>> for f in l: print(f())
...
2
2
2

Most people consider *this* behaviour to be far weirder
than anything that would result from giving for-loop
variables their own scope.

Even if you don't think it's weird, it's hard to argue
that it's *useful* in any significant number of cases.


To me, "make for-loops be their own scope" sounds like a joke feature out of
joke languages like INTERCAL.


Which is a straw man, since that's not actually what we're
talking about doing. It's neither necessary nor sufficient
to solve the problem.

What *is* necessary and sufficient is to make each iteration
of the for-loop create a new binding of the loop variable
(and not any other variable!).


I'm not aware of any sensible language that
does anything like this.


Scheme and Ruby come to mind as examples of languages in
which the equivalent of a for-loop results in each iteration
getting a new binding of the control variable. Although
you could argue that these languages are not "sensible". :-)

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


[issue10415] readline.insert_text documentation incomplete

2016-09-30 Thread Berker Peksag

Berker Peksag added the comment:

I agree with Martin. Closing this as 'out of date' for now, but we can reopen 
if you could provide more information. Thanks!

--
resolution:  -> out of date
stage: needs patch -> resolved
status: pending -> closed
type:  -> behavior

___
Python tracker 

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



[issue28226] compileall does not support pathlib

2016-09-30 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 13cd90bdcfbe by Berker Peksag in branch '3.6':
Issue #28226: Fix test_compileall on Windows
https://hg.python.org/cpython/rev/13cd90bdcfbe

New changeset ff80d77200ed by Berker Peksag in branch 'default':
Issue #28226: Merge from 3.6
https://hg.python.org/cpython/rev/ff80d77200ed

--

___
Python tracker 

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



[issue18235] _sysconfigdata.py wrong on AIX installations

2016-09-30 Thread David Edelsohn

David Edelsohn added the comment:

Michael Felt,

The patch was from Michael Haubenwallner.  I was addressing Michael 
Haubenwallner.

--

___
Python tracker 

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



[issue28294] HTTPServer server.py assumes sys.stderr != None

2016-09-30 Thread Guido van Rossum

Guido van Rossum added the comment:

I wonder if we shouldn't close this as "won't fix" and tell the OP to override 
the log_message() method. It's kind of curious to complain about *this* 
dependency on sys.stderr existing and working, since there are probably 1000s 
of other places in the stdlib that also depend on that.

--
nosy: +gvanrossum

___
Python tracker 

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



rocket simulation game with just using tkinter

2016-09-30 Thread Irmen de Jong
Hi,

I've made a very simple rocket simulation game, inspired by the recent success 
of SpaceX
where they managed to land the Falcon-9 rocket back on a platform.

I was curious if you can make a simple graphics animation game with just using 
Tkinter,
instead of using other game libraries such as PyGame.
As it turns out, that works pretty well and it was quite easy to write. 
Granted, there's
not much going on on the screen, but still the game runs very smoothly and I 
think it is
fun for a little while where you try to learn to control the rocket and attempt 
to
successfully land it on the other launchpad!

The physics simulation is tied to the game's frame rate boohoo, but the upside 
is that
you can change the framerate to control the game's difficulty. It's easy at 
<=20, fun at
30 and impossible at 60 :)  It's running on 30 by default.


You can get the code here if you want to give it a try:
https://github.com/irmen/rocketsimulator

So you just need python 2/3 with tkinter to play this!


Have fun
Irmen
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28321] Plistlib: Half of the double width characters are missing when writing binary plist

2016-09-30 Thread kuglee

New submission from kuglee:

I read an emoji character from a plist file. The emoji printed correctly to 
stdout. However when I dump the file to a binary plist only the half of the 
emoji was present.

--

___
Python tracker 

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



[issue28321] Plistlib: Half of the double width characters are missing when writing binary plist

2016-09-30 Thread kuglee

Changes by kuglee :


--
components: Library (Lib)
files: input.plist
nosy: kuglee
priority: normal
severity: normal
status: open
title: Plistlib: Half of the double width characters are missing when writing 
binary plist
type: behavior
versions: Python 3.5
Added file: http://bugs.python.org/file44897/input.plist

___
Python tracker 

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



[issue28321] Plistlib: Half of the double width characters are missing when writing binary plist

2016-09-30 Thread kuglee

Changes by kuglee :


Added file: http://bugs.python.org/file44898/output.plist

___
Python tracker 

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



[issue18235] _sysconfigdata.py wrong on AIX installations

2016-09-30 Thread Michael Felt

Michael Felt added the comment:

I am not suggesting anything. I am only trying to report what I experience.

The first observation was that I could not build python when src != build 
directory. I believe that was the original complaint as well.

The second observation came when I tried to use pip install, and also make of 
the mercurial "addition". That module consistently failed until I editted, 
manually, the _sysconf*.py file to make LDwhatever the same as LDCXXwhatever.

With study I  could figure out what they stand for - I would guess they are 
related, if not derived from, to some "autotool" conventions.

To be honest, I do not understand what is meant by "flipping", so I am neither 
for nor against.

For me to test a patch - which I am very willing to do - I would be grateful 
for the mercurial command(s) to test it normally (now that I finally have it 
working - I figured out how to make the SSL part work this evening).

In short, please do not shoot me, the messenger :)

--

___
Python tracker 

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



[issue28319] typo in lzma module documentation

2016-09-30 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the report!

--
nosy: +berker.peksag
resolution:  -> fixed
stage:  -> resolved
status: open -> closed
versions: +Python 3.6

___
Python tracker 

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



[issue28319] typo in lzma module documentation

2016-09-30 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 258436eecb51 by Berker Peksag in branch '3.5':
Issue #28319: Fix typo in lzma.rst
https://hg.python.org/cpython/rev/258436eecb51

New changeset a1e7c9d249ed by Berker Peksag in branch '3.6':
Issue #28319: Merge from 3.5
https://hg.python.org/cpython/rev/a1e7c9d249ed

New changeset 40bcf4a8b57d by Berker Peksag in branch 'default':
Issue #28319: Merge from 3.6
https://hg.python.org/cpython/rev/40bcf4a8b57d

--
nosy: +python-dev

___
Python tracker 

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



[issue28319] typo in lzma module documentation

2016-09-30 Thread Berker Peksag

Changes by Berker Peksag :


--
type:  -> behavior

___
Python tracker 

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



[issue28226] compileall does not support pathlib

2016-09-30 Thread Berker Peksag

Berker Peksag added the comment:

Windows buildbots didn't like a6f0cc1820f4 :) Fix is incoming.

==
FAIL: test_compile_dir_pathlike (test.test_compileall.CompileallTests)
--
Traceback (most recent call last):
  File "D:\buildarea\3.6.ware-win81-release\build\lib\test\test_compileall.py", 
line 161, in test_compile_dir_pathlike
self.assertIn("Listing '{}'...".format(self.directory), stdout.getvalue())
AssertionError: "Listing 'D:\\temp\\tmpuziqv_kw'..." not found in "Listing 
'D:temptmpuziqv_kw'...\nListing 
'D:temptmpuziqv_kw_subdir'...\nCompiling 
'D:temptmpuziqv_kw_subdir_test3.py'...\nCompiling 
'D:temptmpuziqv_kw_test.py'...\nCompiling 
'D:temptmpuziqv_kw_test2.py'...\n"

==
FAIL: test_compile_file_pathlike (test.test_compileall.CompileallTests)
--
Traceback (most recent call last):
  File "D:\buildarea\3.6.ware-win81-release\build\lib\test\test_compileall.py", 
line 111, in test_compile_file_pathlike
"Compiling '{}'...\n".format(self.source_path))
AssertionError: "Compiling 'D:temptmpqvjkm0fm_test.py'...\n" != 
"Compiling 'D:\\temp\\tmpqvjkm0fm\\_test.py'...\n"
- Compiling 'D:\\temp\\tmpqvjkm0fm\\_test.py'...
?  - --
+ Compiling 'D:\temp\tmpqvjkm0fm\_test.py'...

--
status: closed -> open

___
Python tracker 

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



[issue28228] imghdr does not support pathlib

2016-09-30 Thread Brett Cannon

Brett Cannon added the comment:

Berker, your patch LGTM

--
assignee:  -> berker.peksag

___
Python tracker 

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



[issue28226] compileall does not support pathlib

2016-09-30 Thread Ethan Furman

Ethan Furman added the comment:

Thanks, Berker Peksag!

--
assignee: ethan.furman -> 

___
Python tracker 

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



[issue28226] compileall does not support pathlib

2016-09-30 Thread Berker Peksag

Berker Peksag added the comment:

I found a similar problem in compile_dir() and fixed it in the commit.

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



[issue28226] compileall does not support pathlib

2016-09-30 Thread Roundup Robot

Roundup Robot added the comment:

New changeset a6f0cc1820f4 by Berker Peksag in branch '3.6':
Issue #28226: compileall now supports pathlib
https://hg.python.org/cpython/rev/a6f0cc1820f4

New changeset fcce24bc9416 by Berker Peksag in branch 'default':
Issue #28226: Merge from 3.6
https://hg.python.org/cpython/rev/fcce24bc9416

--
nosy: +python-dev

___
Python tracker 

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



[issue28320] Hostname validation is False by default in imaplib

2016-09-30 Thread Maciej Szulik

New submission from Maciej Szulik:

According to David [1] hostname validation should be True by default for the 
imaplib, my tests clearly show something different. Additionally he states you 
Christian were doing so, that's why I'm opening this not to forget about the 
problem and discuss eventually what should happen.


[1] 
http://bugs.python.org/review/25591/diff/16398/Lib/test/test_imaplib.py#newcode451

--
assignee: christian.heimes
components: email
messages: 22
nosy: barry, christian.heimes, maciej.szulik, r.david.murray
priority: normal
severity: normal
stage: needs patch
status: open
title: Hostname validation is False by default in imaplib
type: security
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



[issue25591] refactor imaplib tests

2016-09-30 Thread Maciej Szulik

Maciej Szulik added the comment:

David I apologize for 2 emails from Reitveld, for some reason it didn't show me 
all in one view :/ (I need to master Reitveld better). I've just updated patch 
according to your comments.

--
Added file: http://bugs.python.org/file44896/new_imap_tests_v5.diff

___
Python tracker 

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



Re: Counting words in a string??

2016-09-30 Thread breamoreboy
On Friday, September 30, 2016 at 8:12:47 PM UTC+1, Jake wrote:
> On Friday, 30 September 2016 19:49:57 UTC+1, srinivas devaki  wrote:
> > On Oct 1, 2016 12:10 AM, "Jake" wrote:
> > >
> > > Hi, I need a program which:
> > > 1) Asks the user for a sentence of their choice (not including
> > punctuation)
> > > 2) Ask the user which word they would like to know is repeated
> > > 3) Print out to the user how many times the word came up which they chose
> > from their sentence.
> > >
> > 
> > typical home work assignment, even though stop asking for programs and
> > start asking how to make the same.
> > 
> > anyway if you ever try to write code for this you have to split you
> > sentence and use a dict for counting
> > 
> > Python has Counter from collections but it is a little bit slower when
> > compared to defaultdict for this kind of purpose.
> > 
> > Regards
> > Srinivas Devaki
> > Senior (final yr) student at Indian Institute of Technology (ISM), Dhanbad
> > Computer Science and Engineering Department
> > ph: +91 9491 383 249
> > telegram_id: @eightnoteight
> 
> --
> Could you make the program for me or provide an outline?

We'll start work as soon as your cheque made payable to the Python Software 
Foundation has been cashed.  It works a bit like the Monty Python "Blackmail" 
sketch, the higher the grade you want, the more you have to pay.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is a mechanism equivalent to "trace variable w ..." in Tcl for Python?

2016-09-30 Thread breamoreboy
On Friday, September 30, 2016 at 7:16:10 PM UTC+1, Les Cargill wrote:
> A really interesting design approach in Tcl is to install a callback
> when a variable is written to. This affords highly event-driven 
> programming.
> 
> Example ( sorry; it's Tcl  ) :
> 
> 
> namespace eval events {
>   set preRPM -1
>   proc handleRPM { args } {
>   # do stuff to handle an RPM change here
>   variable ::motor::RPM
>  variable preRPM
>   puts "RPM changed from $preRPM to $RPM
>   set preRPM $RPM
>  }
> }
> 
> ...
> 
> trace variable ::motor::RPM w ::events::handleRPM
> 
> ...
> 
> set ::motor::RPM 33.33
> 
> What is an equivalent mechanism in Python?
> 
> Thanks in advance.
> 
> -- 
> Les Cargill

Perhaps you could pinch the idea, or even the code, from tkinter?  E.g. see the 
section "Variable tracing" at 
http://stupidpythonideas.blogspot.co.uk/2013/12/tkinter-validation.html

Kindest regards.

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


Re: Counting words in a string??

2016-09-30 Thread mm0fmf

On 30/09/2016 20:12, Jake wrote:

On Friday, 30 September 2016 19:49:57 UTC+1, srinivas devaki  wrote:

On Oct 1, 2016 12:10 AM, "Jake"  wrote:


Hi, I need a program which:
1) Asks the user for a sentence of their choice (not including

punctuation)

2) Ask the user which word they would like to know is repeated
3) Print out to the user how many times the word came up which they chose

from their sentence.




typical home work assignment, even though stop asking for programs and
start asking how to make the same.

anyway if you ever try to write code for this you have to split you
sentence and use a dict for counting

Python has Counter from collections but it is a little bit slower when
compared to defaultdict for this kind of purpose.

Regards
Srinivas Devaki
Senior (final yr) student at Indian Institute of Technology (ISM), Dhanbad
Computer Science and Engineering Department
ph: +91 9491 383 249
telegram_id: @eightnoteight


--
Could you make the program for me or provide an outline?


How much will you pay for a commented program or an outline?
--
https://mail.python.org/mailman/listinfo/python-list


Re: What is a mechanism equivalent to "trace variable w ..." in Tcl for Python?

2016-09-30 Thread Random832
On Fri, Sep 30, 2016, at 14:42, Ned Batchelder wrote:
> On Friday, September 30, 2016 at 2:16:10 PM UTC-4, Les Cargill wrote:
> > What is an equivalent mechanism in Python?
> 
> There's no way* to hook into "x = 2", but you could hook into "x.a = 2"
> if you wanted do, by defining __setattr__ on x's class.

That or set cls.a to be a descriptor (using either @property or a
custom-made descriptor class)

class motor:
@property
def RPM(self): return self._RPM
@RPM.setter
def RPM(self, value):
print("RPM changed from", self._RPM, "to", value)
self._RPM = value

If you really wanted to get crazy, you could use self.__dict__['RPM']
instead of self._RPM, which would allow you to inject the descriptor
separately after the class has already been defined and used. Making it
work right if the definition of motor already has an RPM descriptor [for
example, if it uses __slots__] is an exercise for the reader.

> *OK, there might be some crazy hack involving your own class as the
> globals for a module or something, but it sounds ill-advised.

You can make your own class to be *the module itself* to support
external code's "mod.x = 2", but AIUI that won't apply to plain
assignment, which bypasses most of the relevant machinery.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28315] incorrect "in ?" output in 'divide' example at "Defining Clean-up Actions" in tutorial

2016-09-30 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Pushed to all 4 versions in ce57a74b5223, 1bead1f0260f, c729a62d4ec5, and 
89cc2a6b64aa, but I gave issue # as 28815 instead of 28315.  Thanks for the 
clean patch for 3.5.  It mostly worked for 2.7, which also had an additional 
item not in 3.5.

The only other file in /Doc with 'in ?' is Doc/includes/test.py, which is 
mostly a doctest docstring.  The test obviously have not been run for years and 
the directory puzzles me, so I left it alone.

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

___
Python tracker 

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



Re: Counting words in a string??

2016-09-30 Thread Chris Angelico
On Sat, Oct 1, 2016 at 5:12 AM, Jake  wrote:
> Could you make the program for me or provide an outline?

No. In case you didn't read any of the other responses, this community
is not a plagiarism source. If you want to learn to be a programmer,
you're going to have to learn some key skills, one of which (possibly
the most important) is figuring out how to break a problem down into
its parts. Start work. If you don't have any clue how to start, ask
your professor - that way, it's not cheating.

Or if you don't HAVE a professor (if this is a coding challenge from a
self-paced online course, for instance), then you may need to consider
a pay-for course. A good few of these exist (check the Python Wiki for
some), and in some cases, you can get one-on-one tuition, which can
help you out enormously. But whether it's freely-given help on a
mailing list, group lectures, or personal tutoring, you won't get
people just giving you the code - not if they care about you becoming
a competent programmer, anyway.

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


Re: Counting words in a string??

2016-09-30 Thread Jake
On Friday, 30 September 2016 19:49:57 UTC+1, srinivas devaki  wrote:
> On Oct 1, 2016 12:10 AM, "Jake"  wrote:
> >
> > Hi, I need a program which:
> > 1) Asks the user for a sentence of their choice (not including
> punctuation)
> > 2) Ask the user which word they would like to know is repeated
> > 3) Print out to the user how many times the word came up which they chose
> from their sentence.
> >
> 
> typical home work assignment, even though stop asking for programs and
> start asking how to make the same.
> 
> anyway if you ever try to write code for this you have to split you
> sentence and use a dict for counting
> 
> Python has Counter from collections but it is a little bit slower when
> compared to defaultdict for this kind of purpose.
> 
> Regards
> Srinivas Devaki
> Senior (final yr) student at Indian Institute of Technology (ISM), Dhanbad
> Computer Science and Engineering Department
> ph: +91 9491 383 249
> telegram_id: @eightnoteight

--
Could you make the program for me or provide an outline?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Counting words in a string??

2016-09-30 Thread Peter Pearson
On Fri, 30 Sep 2016 11:37:19 -0700 (PDT), Jake  wrote:
> Hi, I need a program which:
> 1) Asks the user for a sentence of their choice (not including punctuation)
> 2) Ask the user which word they would like to know is repeated
> 3) Print out to the user how many times the word came up which they chose
>from their sentence.
>
> It would help if you could comment the code. 
> Thankyou in advance!!

Welcome to the Python newsgroup.  Many helpful, capable, and polite
people frequent this newsgroup, but doing someone's homework assignment
is not viewed as helpful.  If you write the code and run into a problem,
then you can post the code here (if it's short) with a specific question,
and will probably get a prompt and very helpful response.


-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28315] incorrect "in ?" output in 'divide' example at "Defining Clean-up Actions" in tutorial

2016-09-30 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
assignee: docs@python -> terry.reedy
nosy: +terry.reedy
stage:  -> commit review
versions: +Python 3.6, Python 3.7

___
Python tracker 

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



Re: Counting words in a string??

2016-09-30 Thread Rob Gaddi
Jake wrote:

> Hi, I need a program which:
> 1) Asks the user for a sentence of their choice (not including punctuation)
> 2) Ask the user which word they would like to know is repeated
> 3) Print out to the user how many times the word came up which they chose 
> from their sentence.
>
> It would help if you could comment the code. 
> Thankyou in advance!!

I'm sure it would help; your professor will probably take points off
otherwise.

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Counting words in a string??

2016-09-30 Thread srinivas devaki
On Oct 1, 2016 12:10 AM, "Jake"  wrote:
>
> Hi, I need a program which:
> 1) Asks the user for a sentence of their choice (not including
punctuation)
> 2) Ask the user which word they would like to know is repeated
> 3) Print out to the user how many times the word came up which they chose
from their sentence.
>

typical home work assignment, even though stop asking for programs and
start asking how to make the same.

anyway if you ever try to write code for this you have to split you
sentence and use a dict for counting

Python has Counter from collections but it is a little bit slower when
compared to defaultdict for this kind of purpose.

Regards
Srinivas Devaki
Senior (final yr) student at Indian Institute of Technology (ISM), Dhanbad
Computer Science and Engineering Department
ph: +91 9491 383 249
telegram_id: @eightnoteight
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is a mechanism equivalent to "trace variable w ..." in Tcl for Python?

2016-09-30 Thread Ned Batchelder
On Friday, September 30, 2016 at 2:16:10 PM UTC-4, Les Cargill wrote:
> A really interesting design approach in Tcl is to install a callback
> when a variable is written to. This affords highly event-driven 
> programming.
> 
> Example ( sorry; it's Tcl  ) :
> 
> 

(I can't read Tcl, sorry)

> 
> What is an equivalent mechanism in Python?

There's no way* to hook into "x = 2", but you could hook into "x.a = 2"
if you wanted do, by defining __setattr__ on x's class.

*OK, there might be some crazy hack involving your own class as the
globals for a module or something, but it sounds ill-advised.

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


[issue18235] _sysconfigdata.py wrong on AIX installations

2016-09-30 Thread David Edelsohn

David Edelsohn added the comment:

Michael,

Are you suggesting to move the code fragment *AND* revert or change the 
reversal of LDSHARED?  The Python code seems to be setting and reversing the 
value in multiple places.

This also relates to Issue25825.

Repeatedly flipping this around is not making progress.

--

___
Python tracker 

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



[issue28287] Refactor subprocess.Popen to let a subclass handle IO asynchronously

2016-09-30 Thread Terry J. Reedy

Changes by Terry J. Reedy :


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



[issue28287] Refactor subprocess.Popen to let a subclass handle IO asynchronously

2016-09-30 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
nosy: +yselivanov

___
Python tracker 

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



[issue28228] imghdr does not support pathlib

2016-09-30 Thread Ethan Furman

Ethan Furman added the comment:

Berker, yes please.  I just got back from vacation.

--

___
Python tracker 

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



Counting words in a string??

2016-09-30 Thread Jake
Hi, I need a program which:
1) Asks the user for a sentence of their choice (not including punctuation)
2) Ask the user which word they would like to know is repeated
3) Print out to the user how many times the word came up which they chose from 
their sentence.

It would help if you could comment the code. 
Thankyou in advance!!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: unintuitive for-loop behavior

2016-09-30 Thread Steve D'Aprano
On Fri, 30 Sep 2016 11:43 pm, BartC wrote:

> It can make sense for 'x' to be local to this for-loop block (everything
> else is at it works now), and independent of any x's in outer blocks. It
> means being able to do stuff like this:
> 
> for x in a:
>   for x in b:
>  pass
>   pass # outer x still has its value

If you're (generic you) not using the loop variables, as in your example,
why do you care if one overwrites the other? You're not using either of
them.

And if you are using them, then surely you need them to be different names
so you can use them *both*. So why does it matter if they are in different
scopes?

I can't think of an example of where I would want two nested for-loops,
where *both* loop variables need to be the same name, but I only want to
access the inner variable inside the inner loop and the outer variable in
the outer loop.

And if I was in that position, why couldn't I just relax the "must be the
same name" condition and give them different names? Its not like there is a
shortage of possible names.


> And any even more outer x's are not affected. With 'for', especially one
> inside a list-comp, often you just need some throwaway index variable
> without worrying if it will clash with an existing local.
> 
> But it's not useful enough I think to bother changing now. Or even when
> the language was designed.

Indeed.



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


[issue28264] Turtle.onclick events blocked by Turtle.stamp

2016-09-30 Thread Terry J. Reedy

Terry J. Reedy added the comment:

3.4 only gets security patches.  I cannot reproduce in 3.5.2 or 3.6.0b1 on Win  
10.  Left click always moves the turtle whether or not stamp is activated.  
Until problem is verified in a current release, we will have to assume it has 
been fixed by a turtle or tkinter patch in 3.5.

--
nosy: +terry.reedy
title: Python 3.4.4 Turtle library - Turtle.onclick events blocked by 
Turtle.stamp -> Turtle.onclick events blocked by Turtle.stamp

___
Python tracker 

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



Re: unintuitive for-loop behavior

2016-09-30 Thread Steve D'Aprano
On Fri, 30 Sep 2016 03:06 pm, Rustom Mody wrote:

> On Friday, September 30, 2016 at 10:23:31 AM UTC+5:30, Gregory Ewing
> wrote:
>> namenobodywants wrote:
>>  > can anyone help to reconcile me to this semantics?
>> 
>> Not really. Most people agree that it's not desirable
>> behaviour, but we've ended up here due to a convoluted
>> history, and there doesn't seem to be a good way to
>> fix it without breaking a lot of existing code.
> 
> Thanks for an unusually helpful answer.
> 
> In my experience telling a beginner:
> «This» is a misfeature/gotcha
> And «this» is its workaround
> 
> greatly shortens the learning curve as compared to long-winded
> justificatory explanations

What happens if it is *not* a misfeature? Gotchas are not always
misfeatures -- sometimes gotchas are gotchas because people's expectations
are simply wrong, and pandering to their confused expectations does not
actually help them.

I haven't made up my mind about *this* specific (mis)feature itself. I know
I don't want for-loops to introduce their own scope, but that doesn't mean
that the binding behaviour inside for-loops is necessarily the best way of
doing it. I'm still thinking about it.

But *in general*, people often don't think the logical consequences through
before deciding what behaviour is "obviously" right. They insist that
whatever behaviour would be convenient for them *now* is the one and only
correct way of doing things -- even if, an hour later, the *opposite*
behaviour is convenient and therefore the correct way of doing things.

Obviously late binding is the one and only correct way of setting function
parameter defaults -- until we need early binding, then it is the one and
only correct way of doing it.

Gotchas usually exist for a reason. Very few programming languages design
gotchas into them to deliberately trip people up[1], or even through
carelessness. More often, they're the unexpected consequences of a series
of sensible, or even unavoidable, decisions.






[1] "When I design my killer language, the identifiers `foo` and `bar` will
be reserved words, never used, and not even mentioned in the reference
manual. Any program using one will simply dump core without comment.
Multitudes will rejoice."  -  Tim Peters


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


What is a mechanism equivalent to "trace variable w ..." in Tcl for Python?

2016-09-30 Thread Les Cargill


A really interesting design approach in Tcl is to install a callback
when a variable is written to. This affords highly event-driven 
programming.


Example ( sorry; it's Tcl  ) :


namespace eval events {
set preRPM -1
proc handleRPM { args } {
# do stuff to handle an RPM change here
variable ::motor::RPM
variable preRPM
puts "RPM changed from $preRPM to $RPM
set preRPM $RPM
}
}

...

trace variable ::motor::RPM w ::events::handleRPM

...

set ::motor::RPM 33.33

What is an equivalent mechanism in Python?

Thanks in advance.

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


[issue28318] Python unittest.mock.mock_calls stores references to arguments instead of their values

2016-09-30 Thread R. David Murray

R. David Murray added the comment:

This is pretty much just the way python works.  The only alternative would be 
for mock to try to do a deepcopy, which won't always work, so it is probably 
better not to do it at all.

--
nosy: +michael.foord, r.david.murray, rbcollins

___
Python tracker 

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



Re: Regarding Job Opportunity for the position Python Developer in Mc Lean, VA

2016-09-30 Thread gowri
On Friday, September 30, 2016 at 10:56:14 AM UTC-5, go...@spsolinc.com wrote:
> Hi,
> 
> Here we have an immediate opening. Location will be Mc Lean, VA.
> Please revert back to us if you are interested.
> Need good Python experience. SAS or AWS knowledge is added advantage.
> 
> Thanks,
> Gowri Shekar
> 972-983-3467

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


[issue28319] typo in lzma module documentation

2016-09-30 Thread Vladimir Rutsky

New submission from Vladimir Rutsky:

"Specifying custom filter chains" section contains:

> It only supports a single The delta filter supports only one option, dist.

Probably should be just:

> The delta filter supports only one option, dist.

--
assignee: docs@python
components: Documentation
messages: 277765
nosy: docs@python, vrutsky
priority: normal
severity: normal
status: open
title: typo in lzma module documentation
versions: Python 3.5, Python 3.7

___
Python tracker 

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



[issue28301] python3.4-config --extension-suffix reports '.cpython-34m.so'

2016-09-30 Thread Berker Peksag

Changes by Berker Peksag :


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



[issue28318] Python unittest.mock.mock_calls stores references to arguments instead of their values

2016-09-30 Thread Guillaume Chorn

New submission from Guillaume Chorn:

In the unittest.mock library, when a Mock object stores the calls made on it in 
its `mock_calls` attribute, it appears to store references to the call 
arguments instead of the actual values of the call arguments. In cases where 
call args are mutable types, this results in the undesirable behavior below:

```python
import mock

arg = ['one']

test_function(arg)

# passes
test_function.assert_has_calls([mock.call(['one'])])

arg += ['two']

test_function(arg)

# fails, even though we just verified the first call above!
test_function.assert_has_calls([
mock.call(['one']),
mock.call(['one','two'])
])

# passes, even though we didn't make the exact same call twice!
test_function.assert_has_calls([
mock.call(['one', 'two']),
mock.call(['one', 'two'])
])
```

--
components: Tests
messages: 277764
nosy: Guillaume Chorn
priority: normal
severity: normal
status: open
title: Python unittest.mock.mock_calls stores references to arguments instead 
of their values
type: behavior
versions: Python 3.4

___
Python tracker 

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



Re: Save Idle Options

2016-09-30 Thread Terry Reedy

On 9/29/2016 9:33 PM, tce...@comcast.net wrote:

Win 10 pro 32, Python 3.6
I’m new to Python and installed Python with Idle, which I like as an IDE. But 
I’m mystified as to how to make interface options stick. Opened Options, 
Configure Idle. Changed font to Consolas Bold. And stopped dead. There doesn’t 
seem to be a way to save the changes. Tried reloading my file but had to exit 
the Options to do so. So lost the changes. Same issue with  highlighting 
colors. Google is hopeless. How can I do this?


Options are saved automatically when you close the dialog with OK rather 
than Cancel (or [X])  I just retested with Win 10 Pro 64 3.6.0b1.



--
Terry Jan Reedy


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


[issue28217] Add interactive console tests

2016-09-30 Thread Steve Dower

Steve Dower added the comment:

Added my work on this so far. I've only done input testing, but that's the more 
important one anyway in my opinion.

Feel free to suggest more edge cases we ought to test and I'll try and get to 
adding them before b2.

--
keywords: +patch
Added file: http://bugs.python.org/file44895/28217_1.patch

___
Python tracker 

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



Lawrence D'Oliveiro

2016-09-30 Thread Ethan Furman

Lawrence D'Oliveiro is banned from Python List until the new year.

If his posts show up somewhere else (e.g. Usenet), please ignore them.  If you 
must respond to him please trim out his text so the rest of us don't have to 
deal with him.

--
Python List Moderators
--
https://mail.python.org/mailman/listinfo/python-list


[issue28259] Ctypes bug windows

2016-09-30 Thread Aristotel

Aristotel added the comment:

I use 32-bit python on 64-bit windows

--
components:  -Windows

___
Python tracker 

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



Re: unintuitive for-loop behavior

2016-09-30 Thread Chris Angelico
On Sat, Oct 1, 2016 at 3:03 AM, Brendan Abel <007bren...@gmail.com> wrote:
>> a = 1
> if condition:
> print(a)  # UnboundLocalError: local 'a' referenced before assignment
> a += 1
>
>
> For-loops are no different. Making them their own namespace is a very
> strange thing to do, it would mean you couldn't re-bind a value inside a
> for-loop:
>
> count = 0
> for x in sequence:
> count += 1
> # raises UnboundLocalError: local 'count' referenced before assignment
>
> --
>
> That's generally not how nested scopes work, you could still reference
> objects in the outer scope from the inner scope, but the outer scope
> couldn't reference objects in the inner scope

The trouble is that, absent some sort of declaration, there's no way
for the compiler to know whether 'count' and 'a' are supposed to be
new variables in the inner scope, or the same variable as the one in
the next scope out. In Python, declarations are used when you rebind
nonlocal or global names, so these examples would have to be written
thus:

a = 1
if condition:
nonlocal a
print(a)
a += 1

count = 0
for x in sequence:
nonlocal count
count += 1

I don't think we want that. :)

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


Re: unintuitive for-loop behavior

2016-09-30 Thread Brendan Abel
> a = 1
if condition:
print(a)  # UnboundLocalError: local 'a' referenced before assignment
a += 1


For-loops are no different. Making them their own namespace is a very
strange thing to do, it would mean you couldn't re-bind a value inside a
for-loop:

count = 0
for x in sequence:
count += 1
# raises UnboundLocalError: local 'count' referenced before assignment

--

That's generally not how nested scopes work, you could still reference
objects in the outer scope from the inner scope, but the outer scope
couldn't reference objects in the inner scope

a = 1
if condition:
b = a + 2

print b # UnboundLocalError: local 'b' referenced before assignment


for x in sequence:
print x

print x  # UnboundLocalError: local 'x' referenced before assignment.


--

I wouldn't call either behavior intuitive or unintuitive.  They're just
different behaviors of different languages.


On Fri, Sep 30, 2016 at 5:33 AM, Steve D'Aprano 
wrote:

> On Fri, 30 Sep 2016 05:29 am, namenobodywa...@gmail.com wrote:
>
> > hello pythonistas
> >
> > i've had a nodding acquaintance with python for some time, and all along
> i
> > assumed that for-loops got a namespace of their own;
>
> Giving for-loops their own namespace is a grossly unintuitive and a very
> weird thing to do. Modules, classes and functions are obviously namespaces.
> Why should arbitrary syntactic structures create their own namespace?
>
> It would be terribly inconvenient and surprising for if...else blocks to be
> separate namespaces:
>
> a = 1
> if condition:
> print(a)  # UnboundLocalError: local 'a' referenced before assignment
> a += 1
>
>
> For-loops are no different. Making them their own namespace is a very
> strange thing to do, it would mean you couldn't re-bind a value inside a
> for-loop:
>
> count = 0
> for x in sequence:
> count += 1
> # raises UnboundLocalError: local 'count' referenced before assignment
>
>
> unless you declared it nonlocal or global, depending on whether your for
> loop was inside a function or not.
>
> To me, "make for-loops be their own scope" sounds like a joke feature out
> of
> joke languages like INTERCAL. I'm not aware of any sensible language that
> does anything like this.
>
> No, wait a minute, I tell a lie, I recall Chris Angelico mentioning that
> one
> of his favourite languages, Pike or REXX, does it. I forget which.
>
>
>
>
> --
> 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
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: unintuitive for-loop behavior

2016-09-30 Thread Grant Edwards
On 2016-09-30, Grant Edwards  wrote:
> On 2016-09-30, Steve D'Aprano  wrote:
>
>> To me, "make for-loops be their own scope" sounds like a joke
>> feature out of joke languages like INTERCAL. I'm not aware of any
>> sensible language that does anything like this.
>
> In C99 a for loop has its own namespac:
[...]
> I think that's an absolutely brilliant feature, and I use it a _lot_
> when writing C code.  I'm a big fan of minimizing the lifetime/scope
> of variables. I wish if/then/else did the same thing:
>
>   if ((r=some_function()) != R_SUCCESS)
> printf("some_function() failed with status %d\n",r);

The example of what I wished C did should have been this:

   if ((int r=some_function()) != R_SUCCESS)
 printf("some_function() failed with status %d\n",r);


-- 
Grant Edwards   grant.b.edwardsYow! If I pull this SWITCH
  at   I'll be RITA HAYWORTH!!
  gmail.comOr a SCIENTOLOGIST!

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


Re: unintuitive for-loop behavior

2016-09-30 Thread Chris Angelico
On Sat, Oct 1, 2016 at 12:36 AM, Grant Edwards
 wrote:
> On 2016-09-30, Steve D'Aprano  wrote:
>
>> To me, "make for-loops be their own scope" sounds like a joke feature out of
>> joke languages like INTERCAL. I'm not aware of any sensible language that
>> does anything like this.
>
> In C99 a for loop has its own namespac:
>
>   int main(void)
>   {
> for (int i=0; i<5; ++i)
>   printf("i=%d\n",i);
>   }
>
> If you try to access 'i' outside the for loop, it's an error, because
> it doesn't exist in the file, global or 'main' namespace.  It only
> exists in the for-loop's namespace.

I believe that's the same semantics as C++ uses, and I agree, it's
very convenient. Among other things, it means that nested loops behave
more like they do in Python, with independent iterators:

int main(void)
{
for (int i=0; i<5; ++i)
{
printf("%d:", i);
for (int i=0; i<3; ++i)
printf(" %d", i);
printf("\n");
}
}

Now, granted, this is not something I would ever actually recommend
doing, and code review is absolutely justified in rejecting this...
but it's a lot better than pure function-scope variables, where you'd
get stuck in an infinite loop. Obviously the inner 'i' shadows the
outer 'i', but that's the only actual conflict between them.

> I think that's an absolutely brilliant feature, and I use it a _lot_
> when writing C code.  I'm a big fan of minimizing the lifetime/scope
> of variables. I wish if/then/else did the same thing:
>
>   if ((r=some_function()) != R_SUCCESS)
> printf("some_function() failed with status %d\n",r);

No particular reason not to. Ditto 'while' loops:

while (int r=some_function())
..

I agree with minimizing scope, but only where it's practical to do so.
In Python, it simply isn't. Like C, Python has infinitely nested
scopes; unlike C, Python requires explicit 'nonlocal' declarations in
order to assign to something in an outer scope, ergo the convenience
of not declaring local variables translates into extreme inconvenience
of working with overly-narrow scopes. To put it more simply: Scope is
cheap in C, but expensive in Python.

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


[issue28269] [MinGW] Can't compile Python/dynload_win.c due to static strcasecmp

2016-09-30 Thread Steve Dower

Steve Dower added the comment:

Why not replace it entirely with stricmp? Does it behave differently?

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

___
Python tracker 

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



[issue28259] Ctypes bug windows

2016-09-30 Thread Steve Dower

Steve Dower added the comment:

Are you using 64-bit? There was an issue passing structs a while back, but I 
don't recall when or if we've merged the patch.

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

___
Python tracker 

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



[issue28277] ./Modules/_io/_iomodule.c build failure on AIX (beta1) while (a2) was fine.

2016-09-30 Thread Berker Peksag

Changes by Berker Peksag :


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



[issue28207] Use pkg-config to find dependencies

2016-09-30 Thread Xavier de Gaye

Changes by Xavier de Gaye :


--
nosy: +xdegaye

___
Python tracker 

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



[issue28288] Expose environment variable for Py_Py3kWarningFlag

2016-09-30 Thread Roy Williams

Roy Williams added the comment:

Thanks for your support!  Here's a patch to enable the `PYTHON3WARNINGS` 
environment variable.

--
keywords: +patch
Added file: http://bugs.python.org/file44894/pythonenable3kwarningsflag.patch

___
Python tracker 

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



Regarding Job Opportunity for the position Python Developer in Mc Lean, VA

2016-09-30 Thread gowri
Hi,

Here we have an immediate opening. Location will be Mc Lean, VA.
Please revert back to us if you are interested.
Need good Python experience. SAS or AWS knowledge is added advantage.

Thanks,
Gowri Shekar
972-983-3467
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28190] Detect curses headers correctly for cross-compiling

2016-09-30 Thread Xavier de Gaye

Changes by Xavier de Gaye :


--
nosy: +xdegaye

___
Python tracker 

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



[issue28199] Compact dict resizing is doing too much work

2016-09-30 Thread INADA Naoki

INADA Naoki added the comment:

Ah, I'm sorry.
I forget to remove some changes relating to inplace compaction (reusing oldkeys 
when oldsize==newsize).

--
Added file: http://bugs.python.org/file44893/dictresize2.patch

___
Python tracker 

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



[issue26351] Occasionally check for Ctrl-C in long-running operations like sum

2016-09-30 Thread Trey Hunner

Trey Hunner added the comment:

This is a problem I experience occasionally while teaching and while developing 
teaching curriculum.

I tend to close problem windows quickly enough to avoid a computer crash in 
front of a live audience, but it's still an annoyance to get the REPL state 
back to the way I had it before killing the process.

This mostly happens when I'm teaching iterators or itertools, but occasionally 
I hit a "Ctrl-C free zone" in other ways.  I believe this memory-filling 
snippet wouldn't respond to Ctrl-C either: x=[0]*2**30

I hadn't thought to report a bug on this because my use seemed niche.  I mostly 
get this error while demonstrating concepts via weird/incorrect code at the 
REPL.

--
nosy: +trey

___
Python tracker 

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



  1   2   >