Re: A regular expression question

2016-09-28 Thread Ben Finney
Cpcp Cp  writes:

> Look this
>
> >>> import re
> >>> text="asdfnbd]"
> >>> m=re.sub("n*?","?",text)
> >>> print m
> ?a?s?d?f?n?b?d?]?
>
> I don't understand the 'non-greedy' pattern.

Since ‘n*’ matches zero or more ‘n’s, it matches zero adjacent to every
actual character.

It's non-greedy because it matches as few characters as will allow the
match to succeed.

> I think the repl argument should replaces every char in text and
> outputs "".

I hope that helps you understand why that expectation is wrong :-)

Regular expression patterns are *not* an easy topic. Try experimenting
and learning with .

-- 
 \  “If I haven't seen as far as others, it is because giants were |
  `\   standing on my shoulders.” —Hal Abelson |
_o__)  |
Ben Finney

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


[issue28275] LZMADecompressor.decompress Use After Free

2016-09-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

LGTM. And may be worth to rewrite lzma test in your style.

--
resolution: fixed -> 
stage: resolved -> commit review

___
Python tracker 

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



[issue28293] Don't completely dump the regex cache when full

2016-09-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The re module now depends on the enum module, and the latter already depends on 
OrderedDict. Thus the patch doesn't introduce new dependency. Python 
implementation of OrderedDict doesn't override __getitem__ and therefore don't 
slow down the common case. I considered all this.

In contrary, Python implementation of lru_cache slows down the code (that is 
why using it was dropped in the past). But I did not object to this because 
re.sub() is less used than re.match() or re.search() and already is much slower.

--

___
Python tracker 

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



A regular expression question

2016-09-28 Thread Cpcp Cp
Look this

>>> import re
>>> text="asdfnbd]"
>>> m=re.sub("n*?","?",text)
>>> print m
?a?s?d?f?n?b?d?]?

I don't understand the 'non-greedy' pattern.

I think the repl argument should replaces every char in text and outputs 
"".

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


Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Chris Angelico
On Thu, Sep 29, 2016 at 1:53 PM, Steve D'Aprano
 wrote:
> John Cook suggests that functional programming gets harder and harder to do
> right (both for the compiler and for the programmer) as you asymptotically
> approach 100% pure, and suggests the heuristic that (say) 85% pure is the
> sweet spot: functional in the small, object oriented in the large.
>
> http://www.johndcook.com/blog/2009/03/23/functional-in-the-small-oo-in-the-large/
>
>
> I agree. I find that applying functional techniques to individual methods
> makes my classes much better:
>
> - local variables are fine;
> - global variables are not;
> - global constants are okay;
> - mutating the state of the instance should be kept to the absolute minimum;
> - and only done from a few mutator methods, not from arbitrary methods;
> - attributes should *usually* be passed as arguments to methods, not
>   treated as part of the environment.

I would agree with you. "Functional programming" is not an alternative
to imperative or object-oriented programming; it's a style, it's a set
of rules, that make small functions infinitely easier to reason about,
test, and debug. My points about practicality basically boil down to
the same thing as you were saying - 100% pure is infinitely hard.

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


Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Steve D'Aprano
On Wed, 28 Sep 2016 07:18 pm, Chris Angelico wrote:

> On Wed, Sep 28, 2016 at 6:52 PM, Gregory Ewing
>  wrote:
>> Chris Angelico wrote:
>>>
>>>
>>>  wrote:
>>>
 * No side effects (new variable bindings may be created, but
  existing ones cannot be changed; no mutable data structures).
>>>
>>>
>>> If that's adhered to 100%, the language is useless for any operation
>>> that cannot be handled as a "result at end of calculation" function.

They're useless for that too, because you, the caller, cannot see the result
of the calculation. Printing is a side-effect.

Technically you can view the program state through a debugger, but that's
exposing implementation details and besides its not very practical.

But really, this is nit-picking. It is a little like arguing that no
programming languages are actually Turing complete, since no language has
an infinite amount of memory available. Of course a programming language
needs to have *some* way of doing IO, be that print, writing to files, or
flicking the lights on and off in Morse Code, but the challenge is to wall
that off in such a way that it doesn't affect the desirable (to functional
programmers at least) "no side-effects" property.

However, there's no universally agreed upon definition of "side-effect".
Some people might disagree that printing to stdout is a side-effect in the
sense that matters, namely changes to *program* state. Changes to the rest
of the universe are fine.

Some will say that local state (local variables within a function) is okay
so long as that's just an implementation detail. Others insist that even
functions' internal implementation must be pure. After all, a function is
itself a program. If we believe that programs are easier to reason about if
they have no global mutable state (no global variables), then wrapping that
program in "define function"/"end function" tags shouldn't change that.

Others will point out that "no side-effects" is a leaky abstraction, and
like all such abstractions, it leaks. Your functional program will use
memory, the CPU will get warmer, etc.

http://www.johndcook.com/blog/2010/05/18/pure-functions-have-side-effects/

John Cook suggests that functional programming gets harder and harder to do
right (both for the compiler and for the programmer) as you asymptotically
approach 100% pure, and suggests the heuristic that (say) 85% pure is the
sweet spot: functional in the small, object oriented in the large.

http://www.johndcook.com/blog/2009/03/23/functional-in-the-small-oo-in-the-large/


I agree. I find that applying functional techniques to individual methods
makes my classes much better:

- local variables are fine;
- global variables are not;
- global constants are okay;
- mutating the state of the instance should be kept to the absolute minimum;
- and only done from a few mutator methods, not from arbitrary methods;
- attributes should *usually* be passed as arguments to methods, not 
  treated as part of the environment.


That last one is probably the most controversial. Let me explain.


Suppose I have a class with state and at least two methods:


class Robot:
def __init__(self):
self.position = (0, 0)
def move(self, x, y):
self.position[0] += x
self.position[1] += y
def report(self):
# Robot, where are you?
print("I'm at %r" % self.position)


So far so good. But what if we want to make the report() method a bit more
fancy? Maybe we want to spruce it up a bit, and allow subclasses to
customize how they actually report (print, show a dialog box, write to a
log file, whatever you like):

def report(self):
self.format()
self.display_report() 

def display_report(self):
print("I'm at %r" % self.formatted_position)
   
def format(self):
self.formatted_position = (
"x coordinate %f" % self.position[0],
"y coordinate %f" % self.position[1]
)

Now you have this weird dependency where format() communicates with report()
by side-effect, and you cannot test format() or display_report() except by
modifying the position of the Robot.

I see so much OO code written like this, and it is bad, evil, wrong, it
sucks and I don't like it! Just a little bit of functional technique makes
all the difference:

def report(self):
self.display_report(self.format(self.position)) 

def display_report(self, report):
print("I'm at %r" % report)
   
def format(self, position):
return ("x coordinate %f" % position[0],
"y coordinate %f" % position[1]
)

Its easier to understand them (less mystery state in the environment),
easier to test, and easier to convince yourself that the code is correct.



[...]
> If monads allow mutations or side effects, they are by definition not
> pure functions, and violate your bullet point. Languages like Haskell
> 

[issue28183] Clean up and speed up dict iteration

2016-09-28 Thread INADA Naoki

Changes by INADA Naoki :


Added file: http://bugs.python.org/file44874/dict_iter5.patch

___
Python tracker 

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



Re: Syncing up iterators with gaps

2016-09-28 Thread Steve D'Aprano
On Thu, 29 Sep 2016 11:38 am, Tim Chase wrote:

> This seems to discard the data's origin (data1/data2/data3) which is
> how I determine whether to use process_a(), process_b(), or
> process_c() in my original example where N iterators were returned,
> one for each input iterator.

So add another stage to your generator pipeline, one which adds a unique ID
to the output of each generator so you know where it came from.

Hint: the ID doesn't have to be an ID *number*. It can be the process_a,
process_b, process_c ... function itself. Then instead of doing:

for key, (id, stuff) in groupby(merge(data1, data2, data3), keyfunc):
for x in stuff:
if id == 1:
process_a(key, *x)
elif id == 2:
process_b(key, *x)
elif ...



or even:

DISPATCH = {1: process_a, 2: process_b, ...}

for key, (id, stuff) in groupby(merge(data1, data2, data3), keyfunc):
for x in stuff:
DISPATCH[id](key, *x)


you can do:


for key, (process, stuff) in groupby(merge(data1, data2, data3), keyfunc):
for x in stuff:
process(key, *x)





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


[issue28275] LZMADecompressor.decompress Use After Free

2016-09-28 Thread Martin Panter

Martin Panter added the comment:

Here is a patch to fix the corresponding bug in the bzip decompressor. I will 
try to commit it soon if there are no objections.

For the record, these bugs were introduced with the max_length support in Issue 
15955. The bzip code was modelled after the LZMA code.

--
assignee: serhiy.storchaka -> martin.panter
nosy: +martin.panter
status: closed -> open
Added file: http://bugs.python.org/file44873/bzip-failure.patch

___
Python tracker 

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



[issue27873] multiprocessing.pool.Pool.map should take more than one iterable

2016-09-28 Thread Davin Potts

Davin Potts added the comment:

@naught101: Thanks for the wording change -- I think your suggested doc change 
will be a good one.  I've added a comment which you can access via the "review" 
link to the right of the link for your mp.map.starmap.patch attachment.

--

___
Python tracker 

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



[issue20766] reference leaks in pdb

2016-09-28 Thread Jack Liu

Jack Liu added the comment:

Now, I have to set nosigint to True to fix the reference leaks issue for my app.

--

___
Python tracker 

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



[issue20766] reference leaks in pdb

2016-09-28 Thread Jack Liu

Jack Liu added the comment:

Will the issue be fixed in Python formal build?
I still meet the same issue with Python 3.5.1. It cost me a bit time to track 
down this issue.

I'm using pdb to debug a Python script, there are global variables in the 
script. Duo the leak of sigint_handler, calling gc.collect() doesn't release 
the global variables until calling PyOS_FiniInterrupts().

--
nosy: +Jack Liu, draghuram, gregory.p.smith, isandler, r.david.murray
versions: +Python 3.5

___
Python tracker 

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



Re: Nested for loops and print statements

2016-09-28 Thread Larry Hudson via Python-list

On 09/27/2016 09:20 PM, Steven D'Aprano wrote:

On Wednesday 28 September 2016 12:48, Larry Hudson wrote:


As they came through in the newsgroup, BOTH run correctly, because both
versions had leading spaces only.
(I did a careful copy/paste to check this.)


Copying and pasting from the news client may not be sufficient to show what
whitespace is actually used...

Exactly.  That's why I pointed out the sometime (mis)handling of tabs in newsreaders, and said 
these examples came through in MY reader (Thunderbird) as spaces only, so both examples ran 
correctly.


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


Re: Syncing up iterators with gaps

2016-09-28 Thread Tim Chase
On 2016-09-29 10:20, Steve D'Aprano wrote:
> On Thu, 29 Sep 2016 05:10 am, Tim Chase wrote:
> >   data1 = [ # key, data1
> > (1, "one A"),
> > (1, "one B"),
> > (2, "two"),
> > (5, "five"),
> > ]
> 
> So data1 has keys 1, 1, 2, 5.
> Likewise data2 has keys 1, 2, 3, 3, 3, 4 and data3 has keys 2, 4, 5.

Correct

> (data3 also has *two* values, not one, which is an additional
> complication.)

As commented towards the end, the source is set of CSV files, so each
row is a list where a particular (identifiable) item is the key.
Assume that one can use something like get_key(row) to return the key,
which in the above could be implemented as

  get_key = lambda row: row[0]

and for my csv.DictReader data, would be something like

  get_key = lambda row: row["Account Number"]

> > And I'd like to do something like
> > 
> >   for common_key, d1, d2, d3 in magic_happens_here(data1, data2,
> > data3):
> 
> What's common_key? In particular, given that data1, data2 and data3
> have the first key each of 1, 1 and 2 respectively, how do you get:
> 
> > So in the above data, the outer FOR loop would
> > happen 5 times with common_key being [1, 2, 3, 4, 5]
> 
> I'm confused. Is common_key a *constant* [1, 2, 3, 4, 5] or are you
> saying that it iterates over 1, 2, 3, 4, 5?

Your interpretation later is correct, that it each unique key once,
in-order.  So if you

  data1.append((17, "seventeen"))

the outer loop would iterate over [1,2,3,4,5,17]

(so not constant, to hopefully answer that part of your question)

The actual keys are account-numbers, so they're ascii-sorted strings
of the form "1234567-8901", ascending in order through the files.
But for equality/less-than/greater-than comparisons, they work
effectively as integers in my example.

> If the later, it sounds like you want something like a cross between
> itertools.groupby and the "merge" stage of mergesort.

That's a pretty good description at some level.  I looked into
groupby() but was having trouble getting it to do what I wanted.

> Note that I have modified data3 so instead of three columns, (key
> value value), it has two (key value) and value is a 2-tuple.

I'm cool with that.  Since they're CSV rows, you can imagine the
source data then as a generator something like

  data1 = ( (get_key(row), row) for row in my_csv_iter1 )

to get the data to look like your example input data.

> So first you want an iterator that does an N-way merge:
> 
> merged = [(1, "one A"), (1, "one B"), (1, "uno"), 
>   (2, "two"), (2, "dos"), (2, ("ii", "extra alpha")), 
>   (3, "tres x"), (3, "tres y"), (3, "tres z"),
>   (4, "cuatro"), (4, ("iv", "extra beta")),
>   (5, "five"), (5, ("v", "extra gamma")),
>   ]

This seems to discard the data's origin (data1/data2/data3) which is
how I determine whether to use process_a(), process_b(), or
process_c() in my original example where N iterators were returned,
one for each input iterator.  So the desired output would be akin to
(converting everything to tuples as you suggest below)

  [
   (1, [("one A",), ("one B",)], [1, ("uno",)], []),
   (2, [("two",)], [("dos",)], [("ii", "extra alpha")]),
   (3, [], [("tres x",), ("tres y",)], []),
   (4, [], [("cuatro",)], [("iv", "extra beta")]),
   (5, [("five",)], [], [("v", "extra gamma")]),
   ]

only instead of N list()s, having N generators that are smart enough
to yield the corresponding data.

> You might find it easier to have *all* the iterators yield (key,
> tuple) pairs, where data1 and data2 yield a 1-tuple and data3
> yields a 2-tuple.

Right.  Sorry my example obscured that shoulda-obviously-been-used
simplification.

-tkc




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


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

2016-09-28 Thread jfong
Paul  Moore at 2016/9/28 11:31:50PM wrote:
> Taking a step back from the more detailed answers, would I be right to assume 
> that you want to call this external function multiple times from Python, and 
> each call could take days to run? Or is it that you have lots of calls to 
> make and each one takes a small amount of time but the total time for all the 
> calls is in days?
> 
> And furthermore, can I assume that the external function is *not* written to 
> take advantage of multiple CPUs, so that if you call the function once, it's 
> only using one of the CPUs you have? Is it fully utilising a single CPU, or 
> is it actually not CPU-bound for a single call?
> 
> To give specific suggestions, we really need to know a bit more about your 
> issue.

Forgive me, I didn't notice these detail will infulence the answer:-)

Python will call it once. The center part of this function was written in 
assembly for performance. During its execution, this part might be called 
thousands of million times. The function was written to run in a single CPU, 
but the problem it want to solve can be easily distributed into multiple CPUs.

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


[issue28293] Don't completely dump the regex cache when full

2016-09-28 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I would rather not introduce an OrderedDict dependency to the re module while 
other implementations are using the pure python version or where the OD 
implementation is in flux.  This is a barely worth it proposal, so we should 
either make a modest, minimalistic change or just drop it.   Really, its too 
bad that the regex got contorted in a way that precluded the use of the 
lru_cache (DEBUG isn't the central feature of regex and is only minimally 
useful).

--

___
Python tracker 

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



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

2016-09-28 Thread jfong
eryk sun at 2016/9/28 1:05:32PM wrote:
> In Unix, Python's os module may have sched_setaffinity() to set the
> CPU affinity for all threads in a given process.
> 
> In Windows, you can use ctypes to call SetProcessAffinityMask,
> SetThreadAffinityMask, or SetThreadIdealProcessor (a hint for the
> scheduler). On a NUMA system you can call GetNumaNodeProcessorMask(Ex)
> to get the mask of CPUs that are on a given NUMA node. The cmd shell's
> "start" command supports "/numa" and "/affinity" options, which can be
> combined.

Seems have to dive into Windows to understand its usage:-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Steve D'Aprano
On Thu, 29 Sep 2016 03:46 am, Chris Angelico wrote:

> That's exactly how a function works in an imperative language, and
> it's exactly what the FP advocates detest: opaque state. So is the
> difference between "function" and "monad" in Haskell the same as "pure
> function" and "function" in other contexts?

Honestly Chris, what's hard to understand about this? Monads are burritos.

http://blog.plover.com/prog/burritos.html



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


Re: Syncing up iterators with gaps

2016-09-28 Thread Steve D'Aprano
On Thu, 29 Sep 2016 05:10 am, Tim Chase wrote:

> I've got several iterators sharing a common key in the same order and
> would like to iterate over them in parallel, operating on all items
> with the same key.  I've simplified the data a bit here, but it would
> be something like
> 
>   data1 = [ # key, data1
> (1, "one A"),
> (1, "one B"),
> (2, "two"),
> (5, "five"),
> ]

So data1 has keys 1, 1, 2, 5.

Likewise data2 has keys 1, 2, 3, 3, 3, 4 and data3 has keys 2, 4, 5.

(data3 also has *two* values, not one, which is an additional complication.)

> And I'd like to do something like
> 
>   for common_key, d1, d2, d3 in magic_happens_here(data1, data2, data3):

What's common_key? In particular, given that data1, data2 and data3 have the
first key each of 1, 1 and 2 respectively, how do you get:

> So in the above data, the outer FOR loop would
> happen 5 times with common_key being [1, 2, 3, 4, 5]

I'm confused. Is common_key a *constant* [1, 2, 3, 4, 5] or are you saying
that it iterates over 1, 2, 3, 4, 5?


If the later, it sounds like you want something like a cross between
itertools.groupby and the "merge" stage of mergesort. You have at least
three sorted(?) iterators, representing the CSV files, let's say they
iterate over

data1 = [(1, "one A"), (1, "one B"), (2, "two"), (5, "five")]

data2 = [(1, "uno"), (2, "dos"), (3, "tres x"), (3, "tres y"), 
 (3, "tres z"), (4, "cuatro")]

data3 = [ (2, ("ii", "extra alpha")), (4, ("iv", "extra beta")),
  (5, ("v", "extra gamma"))]


Note that I have modified data3 so instead of three columns, (key value
value), it has two (key value) and value is a 2-tuple.

So first you want an iterator that does an N-way merge:

merged = [(1, "one A"), (1, "one B"), (1, "uno"), 
  (2, "two"), (2, "dos"), (2, ("ii", "extra alpha")), 
  (3, "tres x"), (3, "tres y"), (3, "tres z"),
  (4, "cuatro"), (4, ("iv", "extra beta")),
  (5, "five"), (5, ("v", "extra gamma")),
  ]

and then you can simply call itertools.groupby to group by the common keys:

1: ["one A", "one B", "uno"]
2: ["two", "dos", ("ii", "extra alpha")]
3: ["tres x", "tres y", "tres z"]
4: ["cuatro", ("iv", "extra beta")]
5: ["five", ("v", "extra gamma")]

and then you can extract the separate columns from each value.

You might find it easier to have *all* the iterators yield (key, tuple)
pairs, where data1 and data2 yield a 1-tuple and data3 yields a 2-tuple.


If you look on ActiveState, I'm pretty sure you will find a recipe from
Raymond Hettinger for a merge sort or heap sort or something along those
lines, which you can probably adapt for an arbitrary number of inputs.




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


Re: how to automate java application in window using python

2016-09-28 Thread Lawrence D’Oliveiro
On Thursday, September 29, 2016 at 11:54:46 AM UTC+13, Emile van Sebille wrote:
> Which worked for me! You should try it. Sloppy programming has always 
> been unreliable.

So it is clear you don’t have an answer to the OP’s question after all. Just 
some vague, meaningless generalities.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28248] Upgrade installers to OpenSSL 1.0.2j

2016-09-28 Thread Shaun Walbridge

Changes by Shaun Walbridge :


--
nosy: +scw

___
Python tracker 

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



[issue26550] documentation minor issue : "Step back: WSGI" section from "HOWTO Use Python in the web"

2016-09-28 Thread Berker Peksag

Berker Peksag added the comment:

Thanks, Alejandro. Doc/howto/webservers.rst has been removed in Python 3  so I 
just fixed 2.7.

--
nosy: +berker.peksag
resolution:  -> fixed
stage:  -> resolved
status: open -> closed
type: enhancement -> behavior
versions:  -Python 3.2, 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



[issue26550] documentation minor issue : "Step back: WSGI" section from "HOWTO Use Python in the web"

2016-09-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 522506fcff88 by Berker Peksag in branch '2.7':
Issue #26550: Fix typo in webservers HOWTO
https://hg.python.org/cpython/rev/522506fcff88

--
nosy: +python-dev

___
Python tracker 

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



[issue26224] Add "version added" for documentation of asyncio.timeout for documentation of python 3.4, 3.5, 3.6

2016-09-28 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



[issue26224] Add "version added" for documentation of asyncio.timeout for documentation of python 3.4, 3.5, 3.6

2016-09-28 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the patch. asyncio.timeout() has been removed in 73a28ad66bd9.

--
nosy: +berker.peksag
resolution:  -> out of date
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



Re: Can this be easily done in Python?

2016-09-28 Thread Mario R. Osorio
I'm not sure I understand your question, but I 'think' you area talking about 
executing dynamically chunks of code. If that is the case, there are a couple 
of ways to do it. These are some links that might interest you:

http://stackoverflow.com/questions/3974554/python-how-to-generate-the-code-on-the-fly

http://stackoverflow.com/questions/32073600/python-how-to-create-a-class-name-on-the-fly

http://lucumr.pocoo.org/2011/2/1/exec-in-python/


On Tuesday, September 27, 2016 at 3:58:59 PM UTC-4, TUA wrote:
> Is the following possible in Python?
> 
> Given how the line below works
> 
> TransactionTerms = 'TransactionTerms'
> 
> 
> have something like
> 
> TransactionTerms = 
> 
> that sets the variable TransactionTerms to its own name as string 
> representation without having to specify it explicitly as in the line 
> above

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


[issue24274] erroneous comments in dictobject.c

2016-09-28 Thread Berker Peksag

Berker Peksag added the comment:

Comments have been updated by the new dict implementation in 3.6+, but the 3.5 
branch still needs to be updated.

--
nosy: +berker.peksag, inada.naoki
stage:  -> needs patch
type: enhancement -> behavior
versions: +Python 3.5

___
Python tracker 

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



Re: how to automate java application in window using python

2016-09-28 Thread Emile van Sebille

On 09/28/2016 02:52 PM, Lawrence D’Oliveiro wrote:

On Thursday, September 29, 2016 at 4:57:10 AM UTC+13, Emile van Sebille wrote:

My point was that it is possible to automate windows reliably as long as the
programming is robust.


Sounds like circular reasoning.



Which worked for me! You should try it. Sloppy programming has always 
been unreliable.


Emile

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


[issue23701] Drop extraneous comment from winreg.QueryValue's docstring

2016-09-28 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the report and for the patch, Claudiu. The part you mentioned has 
already been removed in 6e613ecd70f0. Here's the current version:

"Values in the registry have name, type, and data components. This method
retrieves the data for a key's first value that has a NULL name.
But since the underlying API call doesn't return the type, you'll
probably be happier using QueryValueEx; this function is just here for
completeness."

--
nosy: +berker.peksag
resolution:  -> out of date
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



[issue22969] Compile fails with --without-signal-module

2016-09-28 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the report, but --with(out)-signal-module option has been removed in 
d5bb5ad5a108.

--
nosy: +berker.peksag
resolution:  -> out of date
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



[issue22392] Clarify documentation of __getinitargs__

2016-09-28 Thread Berker Peksag

Berker Peksag added the comment:

https://docs.python.org/2/library/pickle.html#object.__getinitargs__ states:

"If it is desirable that the __init__() method be called on unpickling, an 
old-style class can define a method __getinitargs__(), which should return a 
tuple containing the arguments to be passed to the class constructor 
(__init__() for example)."

However, there is no mention that it only accepts positional arguments.

This is a Python 2-only change and the documentation file is located at 
Doc/library/pickle.rst in 2.7 branch.

--
keywords: +easy
nosy: +berker.peksag
stage:  -> needs patch

___
Python tracker 

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



[issue20754] distutils should use SafeConfigParser

2016-09-28 Thread Jason R. Coombs

Jason R. Coombs added the comment:

Do the changes in issue20120 address this concern?

--

___
Python tracker 

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



[issue20754] distutils should use SafeConfigParser

2016-09-28 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the report, Alex. SafeConfigParser has been renamed to ConfigParser 
in Python 3.2 and distutils already uses ConfigParser in Python 3:

>From Distribution.parse_config_files():

...
parser = ConfigParser()

For 2.7, can you try it with setuptools? Perhaps we should keep 2.7 as-is and 
let setuptools do its magic.

--
nosy: +berker.peksag, jason.coombs
resolution:  -> out of date
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



[issue27845] Optimize update_keyword_args() function

2016-09-28 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution:  -> out of date
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



[issue28293] Don't completely dump the regex cache when full

2016-09-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

It is applied cleanly on the default branch. I don't think there is a need to 
open a new issue. The last patch implements the original Raymond's intention, 
but taking into account all comments: drops the oldest item, doesn't depend on 
implementation details of dict, thread-safe.

--
resolution: rejected -> 
status: closed -> open

___
Python tracker 

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



Re: how to automate java application in window using python

2016-09-28 Thread Lawrence D’Oliveiro
On Thursday, September 29, 2016 at 4:57:10 AM UTC+13, Emile van Sebille wrote:
> My point was that it is possible to automate windows reliably as long as the
> programming is robust.

Sounds like circular reasoning.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28148] [Patch] Also stop using localtime() in timemodule

2016-09-28 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


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



[issue27100] Attempting to use class with both __enter__ & __exit__ undefined yields __exit__ attribute error

2016-09-28 Thread Spencer Brown

Spencer Brown added the comment:

Alternatively, SETUP_WITH could additionally check for the other method, and 
raise an AttributeError with a custom message mentioning both methods.

--
nosy: +Spencer Brown

___
Python tracker 

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



[issue28148] [Patch] Also stop using localtime() in timemodule

2016-09-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 3afad465b3e1 by Alexander Belopolsky in branch '3.6':
Issue #28148: Added a NEWS entry.
https://hg.python.org/cpython/rev/3afad465b3e1

--

___
Python tracker 

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



[issue21903] ctypes documentation MessageBoxA example produces error

2016-09-28 Thread Eryk Sun

Eryk Sun added the comment:

The GetWindowRect example seems fine, for the most part. The docs don't have to 
show it being called. If I were to call it, I'd use GetForegroundWindow to get 
a window handle. GetActiveWindow returns the active window attached to the 
current thread's message queue, but a console application probably doesn't own 
a window. (The console window is owned by conhost.exe.)

A more pressing matter is the GetModuleHandle examples, which need to either be 
fixed or replaced. GetModuleHandle returns a module's base address, and in a 
64-bit process the result could be truncated when returned as the default C int 
type. GetModuleHandleW.restype has to be set to a pointer type. Setting it to a 
Python function, such as the ValidHandle example, has the same truncation 
problem. In general, a ValidHandle checker would have to be implemented as an 
errcheck function.

--

___
Python tracker 

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



[issue28148] [Patch] Also stop using localtime() in timemodule

2016-09-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c81b9107ec42 by Alexander Belopolsky in branch '3.6':
Issue #28148: Stop using localtime() and gmtime() in the time module.
https://hg.python.org/cpython/rev/c81b9107ec42

--
nosy: +python-dev

___
Python tracker 

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



[issue28292] Make Calendar.itermonthdates() behave consistently in edge cases

2016-09-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

LGTM. Maybe add also itermonthdays4() that yields 4-tuples (year, month, day, 
day_of_week)? I seen a code that filters out weekends from itermonthdates().

--

___
Python tracker 

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



[issue9253] argparse: optional subparsers

2016-09-28 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
nosy: +Mariatta

___
Python tracker 

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



[issue28210] argparse with subcommands difference in python 2.7 / 3.5

2016-09-28 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
nosy: +Mariatta

___
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-28 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
nosy: +Mariatta

___
Python tracker 

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



Re: Using the Windows "embedded" distribution of Python

2016-09-28 Thread eryk sun
On Wed, Sep 28, 2016 at 2:35 PM, Paul  Moore  wrote:
> So I thought I'd try SetDllDirectory. That works for python36.dll, but if I 
> load
> python3.dll, it can't find Py_Main - the export shows as "(forwarded to
> python36.Py_Main)", maybe the forwarding doesn't handle SetDllDirectory?

It works for me. Are you calling SetDllDirectory with the
fully-qualified path? If not it's relative to the working directory,
which isn't necessarily (generally is not) the application directory,
in which case delay-loading python36.dll will fail. You can create the
fully-qualified path from the application path, i.e.
GetModuleFileNameW(NULL, ...).

That said, I prefer using LoadLibraryExW(absolute_path_to_python3,
NULL, LOAD_WITH_ALTERED_SEARCH_PATH). The alternate search substitutes
the DLL's directory for the application directory when loading
dependent DLLs, which allows loading python36.dll and vcruntime140.dll
without having to modify the DLL search path of the entire process.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Syncing up iterators with gaps

2016-09-28 Thread Peter Otten
Tim Chase wrote:

> I've got several iterators sharing a common key in the same order and
> would like to iterate over them in parallel, operating on all items
> with the same key.  I've simplified the data a bit here, but it would
> be something like
> 
>   data1 = [ # key, data1
> (1, "one A"),
> (1, "one B"),
> (2, "two"),
> (5, "five"),
> ]
> 
>   data2 = [ # key, data1
> (1, "uno"),
> (2, "dos"),
> (3, "tres x"),
> (3, "tres y"),
> (3, "tres z"),
> (4, "cuatro"),
> ]
> 
>   data3 = [ # key, data1, data2
> (2, "ii", "extra alpha"),
> (4, "iv", "extra beta"),
> (5, "v", "extra gamma"),
> ]
> 
> And I'd like to do something like
> 
>   for common_key, d1, d2, d3 in magic_happens_here(data1, data2, data3):
> for row in d1:
>   process_a(common_key, row)
> for thing in d2:
>   process_b(common_key, row)
> for thing in d3:
>   process_c(common_key, row)
> 
> which would yield the common_key, along with enough of each of those
> iterators (note that gaps can happen, but the sortable order should
> remain the same).  So in the above data, the outer FOR loop would
> happen 5 times with common_key being [1, 2, 3, 4, 5], and each of
> [d1, d2, d3] being an iterator that deals with just that data.
> 
> My original method was hauling everything into memory and making
> multiple passes filtering on the data. However, the actual sources
> are CSV-files, some of which are hundreds of megs in size, and my
> system was taking a bit of a hit.  So I was hoping for a way to do
> this with each iterator making only one complete pass through each
> source (since they're sorted by common key).
> 
> It's somewhat similar to the *nix "join" command, only dealing with
> N files.
> 
> Thanks for any hints.
> 
> -tkc

A bit messy, might try replacing groups list with a dict:

$ cat merge.py  
from itertools import groupby
from operator import itemgetter

first = itemgetter(0)
rest = itemgetter(slice(1, None))


def magic_happens_here(*columns):
grouped = [groupby(column, key=first) for column in columns]
missing = object()

def getnext(g):
nonlocal n
try:
k, g = next(g)
except StopIteration:
n -= 1
return (missing, None)
return k, g

n = len(grouped)
groups = [getnext(g) for g in grouped]
while n:
minkey = min(k for k, g in groups if k is not missing)
yield (minkey,) + tuple(
map(rest, g) if k == minkey else ()
for k, g in groups)
for i, (k, g) in enumerate(groups):
if k == minkey:
groups[i] = getnext(grouped[i])


if __name__ == "__main__":
data1 = [  # key, data1
(1, "one A"),
(1, "one B"),
(2, "two"),
(5, "five"),
]

data2 = [  # key, data1
(1, "uno"),
(2, "dos"),
(3, "tres x"),
(3, "tres y"),
(3, "tres z"),
(4, "cuatro"),
]

data3 = [  # key, data1, data2
(2, "ii", "extra alpha"),
(4, "iv", "extra beta"),
(5, "v", "extra gamma"),
]

for common_key, d1, d2, d3 in magic_happens_here(data1, data2, data3):
print(common_key)
for d in d1, d2, d3:
print("", list(d))
$ python3 merge.py 
1
 [('one A',), ('one B',)]
 [('uno',)]
 []
2
 [('two',)]
 [('dos',)]
 [('ii', 'extra alpha')]
3
 []
 [('tres x',), ('tres y',), ('tres z',)]
 []
4
 []
 [('cuatro',)]
 [('iv', 'extra beta')]
5
 [('five',)]
 []
 [('v', 'extra gamma')]


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


[issue28281] Remove year limits from calendar

2016-09-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Okay, if this is specified by ISO 8601 standard, I think we can extend calendar 
below year 1. But the meaning of non-positive years should be documented. And 
maybe even provide a way to customize the representation of year (this is a 
separate issue).

Standard Unix utilities cal and ncal support only years in range 1...

--

___
Python tracker 

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



Re: Syncing up iterators with gaps

2016-09-28 Thread Chris Kaynor
Here is a slight variation of Chris A's code that does not require
more than a single look-ahead per generator. It may be better
depending on the exact data passed in.

Chris A's version will store all of the items for each output that
have a matching key, which, depending on the expected data, could use
quite a bit of memory. This version yields a list of generators, which
then allows for never having more than a single lookahead per list.
The generators returned must be consumed immediately or they will be
emptied - I put in a safety loop that consumes them before continuing
processing.

My version is likely better if your processing does not require
storing (most of) the items and you expect there to be a large number
of common keys in each iterator. If you expect only a couple of items
per shared key per list, Chris A's version will probably perform
better for slightly more memory usage, as well as being somewhat safer
and simpler.

def magic_happens_here(*iters):
def gen(j):
while nexts[j][0] == common_key:
yield nexts[j]
nexts[j] = next(iters[j], (None,))
iters = [iter(it) for it in iters]
nexts = [next(it, (None,)) for it in iters]
while "moar stuff":
try: common_key = min(row[0] for row in nexts if row[0])
except ValueError: break # No moar stuff
outputs = [common_key]
for i in range(len(nexts)): # code smell, sorry
outputs.append(gen(i))
yield outputs
# The following three lines confirm that the generators provided
#  were consumed. This allows not exhausting the yielded generators.
#  If this is not included, and the iterator is not consumed, it can
#  result in an infinite loop.
for output in outputs[1:]:
for item in output:
pass
Chris


On Wed, Sep 28, 2016 at 12:48 PM, Chris Angelico  wrote:
> On Thu, Sep 29, 2016 at 5:10 AM, Tim Chase
>  wrote:
>> And I'd like to do something like
>>
>>   for common_key, d1, d2, d3 in magic_happens_here(data1, data2, data3):
>> for row in d1:
>>   process_a(common_key, row)
>> for thing in d2:
>>   process_b(common_key, row)
>> for thing in d3:
>>   process_c(common_key, row)
>
> Assuming that the keys are totally ordered and the data sets are
> sorted, this should work:
>
> def magic_happens_here(*iters):
> iters = [iter(it) for it in iters]
> nexts = [next(it, (None,)) for it in iters]
> while "moar stuff":
> try: common_key = min(row[0] for row in nexts if row[0])
> except ValueError: break # No moar stuff
> outputs = [common_key]
> for i in range(len(nexts)): # code smell, sorry
> output = []
> while nexts[i][0] == common_key:
> output.append(nexts[i])
> nexts[i] = next(iters[i], (None,))
> outputs.append(output)
> yield outputs
>
> Basically, it takes the lowest available key, then takes everything of
> that key and yields it as a unit.
>
> Code not tested. Use at your own risk.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Syncing up iterators with gaps

2016-09-28 Thread Chris Angelico
On Thu, Sep 29, 2016 at 5:10 AM, Tim Chase
 wrote:
> And I'd like to do something like
>
>   for common_key, d1, d2, d3 in magic_happens_here(data1, data2, data3):
> for row in d1:
>   process_a(common_key, row)
> for thing in d2:
>   process_b(common_key, row)
> for thing in d3:
>   process_c(common_key, row)

Assuming that the keys are totally ordered and the data sets are
sorted, this should work:

def magic_happens_here(*iters):
iters = [iter(it) for it in iters]
nexts = [next(it, (None,)) for it in iters]
while "moar stuff":
try: common_key = min(row[0] for row in nexts if row[0])
except ValueError: break # No moar stuff
outputs = [common_key]
for i in range(len(nexts)): # code smell, sorry
output = []
while nexts[i][0] == common_key:
output.append(nexts[i])
nexts[i] = next(iters[i], (None,))
outputs.append(output)
yield outputs

Basically, it takes the lowest available key, then takes everything of
that key and yields it as a unit.

Code not tested. Use at your own risk.

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


[issue28306] incorrect output "int division or modulo by zero" in Handling Exceptions tutorial

2016-09-28 Thread Berker Peksag

Berker Peksag added the comment:

Good catch! Thanks for the report.

--
nosy: +berker.peksag
resolution:  -> fixed
stage:  -> resolved
status: open -> closed
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



[issue28306] incorrect output "int division or modulo by zero" in Handling Exceptions tutorial

2016-09-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f60396d8f95c by Berker Peksag in branch '3.5':
Issue #28306: Update exception message of ZeroDivisionError
https://hg.python.org/cpython/rev/f60396d8f95c

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

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

--
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: Syncing up iterators with gaps

2016-09-28 Thread Terry Reedy

On 9/28/2016 3:10 PM, Tim Chase wrote:

I've got several iterators sharing a common key in the same order and
would like to iterate over them in parallel, operating on all items
with the same key.  I've simplified the data a bit here, but it would
be something like

  data1 = [ # key, data1
(1, "one A"),
(1, "one B"),
(2, "two"),
(5, "five"),
]

  data2 = [ # key, data1
(1, "uno"),
(2, "dos"),
(3, "tres x"),
(3, "tres y"),
(3, "tres z"),
(4, "cuatro"),
]

  data3 = [ # key, data1, data2
(2, "ii", "extra alpha"),
(4, "iv", "extra beta"),
(5, "v", "extra gamma"),
]

And I'd like to do something like

  for common_key, d1, d2, d3 in magic_happens_here(data1, data2, data3):
for row in d1:
  process_a(common_key, row)
for thing in d2:
  process_b(common_key, row)
for thing in d3:
  process_c(common_key, row)

which would yield the common_key, along with enough of each of those
iterators (note that gaps can happen, but the sortable order should
remain the same).  So in the above data, the outer FOR loop would
happen 5 times with common_key being [1, 2, 3, 4, 5], and each of
[d1, d2, d3] being an iterator that deals with just that data.


You just need d1, d2, d3 to be iterables, such as a list.  Write a magic 
generator that opens the three files and reads one line of each (with 
next()).  Then in while True loop, find minimum key and make 3 lists (up 
to 2 possibly empty) of the items in each file with that key.  This will 
require up to 3 inner loops.  The read-ahead makes this slightly messy. 
If any list is not empty, yield the key and 3 lists.  Otherwise break 
the outer loop.



My original method was hauling everything into memory and making
multiple passes filtering on the data. However, the actual sources
are CSV-files, some of which are hundreds of megs in size, and my
system was taking a bit of a hit.  So I was hoping for a way to do
this with each iterator making only one complete pass through each
source (since they're sorted by common key).

It's somewhat similar to the *nix "join" command, only dealing with
N files.


It is also somewhat similar to a 3-way mergesort.

--
Terry Jan Reedy

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


[issue8844] Condition.wait() doesn't raise KeyboardInterrupt

2016-09-28 Thread Gregory P. Smith

Gregory P. Smith added the comment:

As a data point confirming that: we tried backporting the much nicer 
non-polling condition implementation 
(https://github.com/python/cpython/commit/15801a1d52c25fa2a19d649ea2671080f138fca1.patch)
 to our Python 2.7 interpreter at work but ran into actual code that failed as 
a result of the interruption behavior changing.

While it is a nice goal, it is a non-trivial change.  Not something we could 
ever do within a stable release (2.7).

--

___
Python tracker 

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



[issue28306] incorrect output "int division or modulo by zero" in Handling Exceptions tutorial

2016-09-28 Thread Viorel Tabara

New submission from Viorel Tabara:

I'm reading the Python 3.5.2 documentation at:
  
   https://docs.python.org/3/tutorial/errors.html#handling-exceptions

which shows the following example:

   >>> def this_fails():
   ... x = 1/0
   ...
   >>> try:
   ... this_fails()
   ... except ZeroDivisionError as err:
   ... print('Handling run-time error:', err)
   ...
   Handling run-time error: int division or modulo by zero 

Running the code as a script produces:

   $ python3 -V
   Python 3.5.2
   $ python3 p.py
   Handling run-time error: division by zero

   $ python2 -V
   Python 2.7.12
   $ python2 p.py
   ('Handling run-time error:', ZeroDivisionError('integer division or modulo 
by zero',))
   
The same output is listed for 3.6 and 3.7 tutorials but I don't have those 
versions installed on my system.

--
assignee: docs@python
components: Documentation
messages: 277657
nosy: docs@python, viorel
priority: normal
severity: normal
status: open
title: incorrect output "int division or modulo by zero" in Handling Exceptions 
tutorial
type: behavior
versions: Python 3.5

___
Python tracker 

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



[issue28305] Make error for Python3.6 on Cygwin

2016-09-28 Thread R. David Murray

R. David Murray added the comment:

If you can't please report it on that issue.

--

___
Python tracker 

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



[issue28305] Make error for Python3.6 on Cygwin

2016-09-28 Thread Ron Barak

Ron Barak added the comment:

Can I apply 
http://bugs.python.org/file44208/3.5-issue21085-struct_siginfo-2.patch to 3.6 
as is?

--

___
Python tracker 

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



[issue27100] Attempting to use class with both __enter__ & __exit__ undefined yields __exit__ attribute error

2016-09-28 Thread Ned Deily

Changes by Ned Deily :


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



[issue28305] Make error for Python3.6 on Cygwin

2016-09-28 Thread R. David Murray

R. David Murray added the comment:

cygwin used to be fully supported, but support broke because there was no one 
around that was maintaining it.  There has been renewed interest, and some 
progress toward fixing cygwin support (more help is appreciated), but it cannot 
be called a supported platform at the moment because there is no maintainer on 
our team and there is no buildbot.  There are hopes that both of these 
deficiencies will be remedied.

This issue is a duplicate of issue 21085, and there is a patch in that issue 
that has not been applied yet.

--
nosy: +r.david.murray

___
Python tracker 

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



Syncing up iterators with gaps

2016-09-28 Thread Tim Chase
I've got several iterators sharing a common key in the same order and
would like to iterate over them in parallel, operating on all items
with the same key.  I've simplified the data a bit here, but it would
be something like

  data1 = [ # key, data1
(1, "one A"),
(1, "one B"),
(2, "two"),
(5, "five"),
]

  data2 = [ # key, data1
(1, "uno"),
(2, "dos"),
(3, "tres x"),
(3, "tres y"),
(3, "tres z"),
(4, "cuatro"),
]

  data3 = [ # key, data1, data2
(2, "ii", "extra alpha"),
(4, "iv", "extra beta"),
(5, "v", "extra gamma"),
]

And I'd like to do something like

  for common_key, d1, d2, d3 in magic_happens_here(data1, data2, data3):
for row in d1:
  process_a(common_key, row)
for thing in d2:
  process_b(common_key, row)
for thing in d3:
  process_c(common_key, row)

which would yield the common_key, along with enough of each of those
iterators (note that gaps can happen, but the sortable order should
remain the same).  So in the above data, the outer FOR loop would
happen 5 times with common_key being [1, 2, 3, 4, 5], and each of
[d1, d2, d3] being an iterator that deals with just that data.

My original method was hauling everything into memory and making
multiple passes filtering on the data. However, the actual sources
are CSV-files, some of which are hundreds of megs in size, and my
system was taking a bit of a hit.  So I was hoping for a way to do
this with each iterator making only one complete pass through each
source (since they're sorted by common key).

It's somewhat similar to the *nix "join" command, only dealing with
N files.

Thanks for any hints.

-tkc



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


[issue28305] Make error for Python3.6 on Cygwin

2016-09-28 Thread Ron Barak

Ron Barak added the comment:

Re: Cygwin is an unsupported platform. 

Currently, from the contents of Python-3.6.0b1, one may be led to believe that 
Cygwin _is_ supported, e.g. - see the references to Cygwin in the README file:

$ grep -i cygwin README
On Unix, Linux, BSD, OSX, and Cygwin:
find out more.  On OSX and Cygwin, the executable is called python.exe;

--

___
Python tracker 

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



[issue2504] Add gettext.pgettext() and variants support

2016-09-28 Thread Antti Haapala

Antti Haapala added the comment:

*wow* isn't this in Python 3 yet (I've been using Zope translationstrings 
lately so I didn't know that pgettext is still not supported).

--
nosy: +ztane

___
Python tracker 

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



[issue28305] Make error for Python3.6 on Cygwin

2016-09-28 Thread R. David Murray

Changes by R. David Murray :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> compile error Python3.3 on Cygwin

___
Python tracker 

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



[issue28305] Make error for Python3.6 on Cygwin

2016-09-28 Thread Christian Heimes

Christian Heimes added the comment:

Cygwin is an unsupported platform. It seems like Cygwin broke siginfo_t. The 
struct must have a si_band member, see 
http://man7.org/linux/man-pages/man2/rt_sigaction.2.html .

--
nosy: +christian.heimes

___
Python tracker 

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



[issue2504] Add gettext.pgettext() and variants support

2016-09-28 Thread Leonid Suprun

Changes by Leonid Suprun :


--
nosy: +Leonid Suprun

___
Python tracker 

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



[issue28305] Make error for Python3.6 on Cygwin

2016-09-28 Thread Ron Barak

New submission from Ron Barak:

Successfully did:

$ gunzip Python-3.6.0b1.tgz
$ tar xvf Python-3.6.0b1.tar
$ pushd Python-3.6.0b1
$ ./configure --disable-ipv6 --with-optimizations

However, when trying to do:

$ make profile-opt

I get:

...

gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall 
-Wstrict-prototypes-std=c99 -Wextra -Wno-unused-result 
-Wno-unused-parameter -Wno-missing-field-initializers -fprofile-generate   -I. 
-IInclude -I./Include-DPy_BUILD_CORE  -c ./Modules/signalmodule.c -o 
Modules/signalmodule.o
In file included from Include/Python.h:85:0,
 from ./Modules/signalmodule.c:6:
./Modules/signalmodule.c: In function 'fill_siginfo':
./Modules/signalmodule.c:960:60: error: 'siginfo_t {aka struct }' 
has no member named 'si_band'
 PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(si->si_band));
^
Include/tupleobject.h:62:75: note: in definition of macro 'PyTuple_SET_ITEM'
 #define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)
   ^
./Modules/signalmodule.c:960:5: note: in expansion of macro 
'PyStructSequence_SET_ITEM'
 PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(si->si_band));
 ^
make[2]: *** [Makefile:1731: Modules/signalmodule.o] Error 1
make[2]: Leaving directory '/home/Administrator/python/3.6/Python-3.6.0b1'
make[1]: *** [Makefile:511: build_all_generate_profile] Error 2
make[1]: Leaving directory '/home/Administrator/python/3.6/Python-3.6.0b1'
make: *** [Makefile:496: profile-opt] Error 2

--
components: Build
files: python3.6Make.err.txt
messages: 277650
nosy: ronbarak
priority: normal
severity: normal
status: open
title: Make error for Python3.6 on Cygwin
type: compile error
versions: Python 3.6
Added file: http://bugs.python.org/file44872/python3.6Make.err.txt

___
Python tracker 

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



Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Chris Angelico
On Thu, Sep 29, 2016 at 2:43 AM, Random832  wrote:
> On Wed, Sep 28, 2016, at 11:41, Paul Moore wrote:
>> What "allows side effects" in languages like Haskell is the fact that the
>> runtime behaviour of the language is not defined as "calculating the
>> value of the main function" but rather as "making the process that the
>> main functon defines as an abstract monad actually happen".
>
> Well, from another point of view, the output (that is, the set of
> changes to files, among other things, that is defined by the
> monad-thingy) is *part of* the value of the main function. And the state
> of the universe prior to running it is part of the input is part of the
> arguments.

That's exactly how a function works in an imperative language, and
it's exactly what the FP advocates detest: opaque state. So is the
difference between "function" and "monad" in Haskell the same as "pure
function" and "function" in other contexts?

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


[issue28255] TextCalendar.prweek/month/year outputs an extra whitespace character

2016-09-28 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
nosy: +belopolsky

___
Python tracker 

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



Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Chris Angelico
On Thu, Sep 29, 2016 at 2:33 AM, Steve D'Aprano
 wrote:
 Procedural programming under another name...
>>>
>>> Only in the sense that procedural programming is unstructured programming
>>> under another name. What is a procedure call but a disguised GOSUB, and
>>> what is GOSUB but a pair of GOTOs?
>>
>> Continuation-passing style is only GOTOs. Instead of returning to the
>> caller, procedures pass control to the continuation, together with the
>> values that the continuation is expecting from the procedure.
>>
>> I guess you can think of it as a way to disguise a GOSUB.
>
>
> Really, if you think about it, both functional and procedural programming
> are exactly the same as programming in assembly language. Returning a value
> from a function pushes that value onto the function call stack, which is
> really just a disguised assembly MOV command.

http://xkcd.com/435/

Also relevant to this conversation:

https://xkcd.com/1270/

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


[issue26869] unittest longMessage docs

2016-09-28 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
nosy: +Mariatta

___
Python tracker 

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



[issue28281] Remove year limits from calendar

2016-09-28 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
nosy: +Mariatta

___
Python tracker 

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



[issue27322] test_compile_path fails when python has been installed

2016-09-28 Thread Chris Angelico

Chris Angelico added the comment:

Also working for me. Thanks!

--

___
Python tracker 

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



[issue27322] test_compile_path fails when python has been installed

2016-09-28 Thread STINNER Victor

STINNER Victor added the comment:

Thanks for your fix :-)

--

___
Python tracker 

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



[issue27322] test_compile_path fails when python has been installed

2016-09-28 Thread Berker Peksag

Berker Peksag added the comment:

The buildbot is now green. Closing this as fixed.

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



Re: How to call this method from main method

2016-09-28 Thread Peter Pearson
On Tue, 27 Sep 2016 23:44:11 -0700 (PDT), prasanthk...@gmail.com wrote:
[snip]
>
> if __name__ == '__main__':
>   
> GenAccessToken("This_is_a_Test_QED_MAC_Key_Which_Needs_to_be_at_Least_32_Bytes_Long",
>  "default", "default", 6,
>"g,m,a,s,c,p,d")
>
> When i am calling the above method from main method it is not
> returning the value but when i use print it is showing the value. Is
> there any wrong in returning the value from a method.

How do you know it's not returning a value?  You don't save the return
value anywhere.

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


Re: Can this be easily done in Python?

2016-09-28 Thread Peter Pearson
On Tue, 27 Sep 2016 12:58:40 -0700 (PDT), TUA  wrote:
> Is the following possible in Python?
>
> Given how the line below works
>
> TransactionTerms = 'TransactionTerms'
>
>
> have something like
>
> TransactionTerms = 
>
> that sets the variable TransactionTerms to its own name as string
> representation without having to specify it explicitly as in the line
> above


You say "variable", but the use of that word often signals a 
misunderstanding about Python.

Python has "objects".  An object often has a name, and in fact often
has several names.  Attempting to associate an object with "its name"
looks like a Quixotic quest to me.

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


Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Random832
On Wed, Sep 28, 2016, at 11:41, Paul Moore wrote:
> What "allows side effects" in languages like Haskell is the fact that the
> runtime behaviour of the language is not defined as "calculating the
> value of the main function" but rather as "making the process that the
> main functon defines as an abstract monad actually happen".

Well, from another point of view, the output (that is, the set of
changes to files, among other things, that is defined by the
monad-thingy) is *part of* the value of the main function. And the state
of the universe prior to running it is part of the input is part of the
arguments.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28304] Condition.wait() doesn't raise KeyboardInterrupt

2016-09-28 Thread Berker Peksag

Berker Peksag added the comment:

Per Victor's comment in issue 8844 
(http://bugs.python.org/issue8844#msg277640), I'm closing this as 'wont fix'. 
Thanks for the report!

--
nosy: +berker.peksag
resolution:  -> wont fix
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: Is there a way to change the closure of a python function?

2016-09-28 Thread Steve D'Aprano
On Wed, 28 Sep 2016 11:05 pm, Jussi Piitulainen wrote:

> Steve D'Aprano writes:
> 
>> On Wed, 28 Sep 2016 08:03 pm, Lawrence D’Oliveiro wrote:
>>
>>> On Wednesday, September 28, 2016 at 9:53:05 PM UTC+13, Gregory Ewing
>>> wrote:
 Essentially you write the whole program in continuation-
 passing style, with a state object being passed down an
 infinite chain of function calls.
>>> 
>>> Procedural programming under another name...
>>
>> Only in the sense that procedural programming is unstructured programming
>> under another name. What is a procedure call but a disguised GOSUB, and
>> what is GOSUB but a pair of GOTOs?
> 
> Continuation-passing style is only GOTOs. Instead of returning to the
> caller, procedures pass control to the continuation, together with the
> values that the continuation is expecting from the procedure.
> 
> I guess you can think of it as a way to disguise a GOSUB.


Really, if you think about it, both functional and procedural programming
are exactly the same as programming in assembly language. Returning a value
from a function pushes that value onto the function call stack, which is
really just a disguised assembly MOV command.



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


[issue27740] Fix doc of Py_CompileStringExFlags

2016-09-28 Thread Berker Peksag

Changes by Berker Peksag :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
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



[issue27740] Fix doc of Py_CompileStringExFlags

2016-09-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset ee76e84f115f by Berker Peksag in branch '3.5':
Issue #27740: Fix typo in Py_CompileStringExFlags
https://hg.python.org/cpython/rev/ee76e84f115f

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

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

--
nosy: +python-dev

___
Python tracker 

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



[issue12743] C API marshalling doc contains XXX

2016-09-28 Thread Berker Peksag

Changes by Berker Peksag :


--
versions: +Python 3.7
Added file: http://bugs.python.org/file44871/issue12743_v2.diff

___
Python tracker 

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



[issue28292] Make Calendar.itermonthdates() behave consistently in edge cases

2016-09-28 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

I would like to take the #1 approach, and also implement an itermonthdays3() 
generator that would be like  itermonthdates(), but return 3-tuples (year, 
month, day) instead of datetime.date objects.

The name "itermonthdays3" is subject to discussion, but it fits with the 
existing "itermonthdays" and "itermonthdays2" that yield integers and 2-tuples 
respectively.  An alternative, but slightly longer name would be 
"itermonthdatetuples".

itermonthdates() can then be reimplemented as

def itermonthdates(self, year, month):
for y, m, d in self.itermonthdays3(year, month):
yield datetime.date(y, m, d)

with the obvious out of bounds behavior.

--

___
Python tracker 

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



[issue28303] [PATCH] Fix broken grammar in "pydoc3 unittest"

2016-09-28 Thread Shlomi Fish

Shlomi Fish added the comment:

You're welcome, and thanks for applying the patch so quickly.

--

___
Python tracker 

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



[issue28300] [PATCH] Fix misspelled "implemented" word

2016-09-28 Thread Shlomi Fish

Shlomi Fish added the comment:

You're welcome and thanks for applying it (and so quickl).

--

___
Python tracker 

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



[issue28281] Remove year limits from calendar

2016-09-28 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

The proposed interpretation of nonpositive years is not arbitrary, it is a 
natural extension of the same formulas that we use for positive years.  On the 
other hand 1- limits are arbitrary.  If we wanted to restrict calendars to 
4-digit years we would limit years to the 1000- range.

Note that interpreting year 0 as 1 BCE is not without a precedent.  ISO 8601 
standard does exactly that with the caveat that "values in the range [] 
through [1582] shall only be used by mutual agreement of the partners in 
information interchange." Furthermore, "an expanded year representation 
[±Y] must have an agreed-upon number of extra year digits beyond the 
four-digit minimum, and it must be prefixed with a + or − sign instead of the 
more common AD/BC (or BCE/CE) notation; by convention 1 BC is labelled +, 2 
BC is labeled -0001, and so on."  See 
 citing ISO 8601:2004 sections 
3.4.2, 4.1.2.4 and Annex B.1.1.

Furthermore, documenting the existing limits is not an easy task.  For example

>>> from calendar import *
>>> cal = TextCalendar(1)
>>> cal.prmonth(1, 1)
 January 1
Tu We Th Fr Sa Su Mo
   1
 2  3  4  5  6  7  8
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31

displays 6 days in December of 1 BCE as blanks.  Similarly itermonthdays() and 
itermonthdays2() generators yield objects corresponding to these days.  Are 
these days within the calendar limits or not?

Note that I am not proposing to extend the range of the datetime.date objects.  
Doing that would be a much more difficult task, but defining calendars for out 
of range years as those for year % 400 is trivial and much easier than to 
figure out and document the edge behaviors.

--

___
Python tracker 

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



[issue8844] Condition.wait() doesn't raise KeyboardInterrupt

2016-09-28 Thread STINNER Victor

STINNER Victor added the comment:

> Is it possible to backport this patch to 2.7?

No.

Python 2.7 supports many implementations of threads:

$ ls Python/thread_*h -1
Python/thread_atheos.h
Python/thread_beos.h
Python/thread_cthread.h
Python/thread_foobar.h
Python/thread_lwp.h
Python/thread_nt.h
Python/thread_os2.h
Python/thread_pth.h
Python/thread_pthread.h
Python/thread_sgi.h
Python/thread_solaris.h
Python/thread_wince.h

Supporting signals on all implementations would be a huge work.

Handling correctly signals is also a complex task. For example, the PEP 475 
changed how Python 3.5 handles signals (retry interrupted syscall), the change 
is larger than just the threading module. This PEP has an impact on the whole 
CPython code base (C and Python).

In Python, unit tests are important. The change b750c45a772c added many unit 
tests, I expect that it will be tricky to make them reliable on all platforms 
supported by Python 2.7. I dislike the idea of backporting the feature just for 
a few platforms.

I mean that the change b750c45a772c alone is not enough, this change depends on 
many earlier changes used to cleanup/prepare the code to support this change. 
It is also followed by many changes to enhance how Python handles signals. It 
took multiple years to fix all subtle issues, race conditions, etc.

There is also a significant risk of breaking applications relying on the 
current behaviour of Python 2.7 (locks are not interrupted by signals).

--

___
Python tracker 

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



Re: how to automate java application in window using python

2016-09-28 Thread Emile van Sebille

On 09/23/2016 05:02 PM, Lawrence D’Oliveiro wrote:

On Thursday, September 22, 2016 at 8:34:20 AM UTC+12, Emile wrote:

Hmm, then I'll have to wait longer to experience the unreliability as
the handful of automated gui tools I'm running has only been up 10 to 12
years or so.


You sound like you have a solution for the OP, then.



My solution was to automate one of the then available windows gui 
scripting tools. I've stopped doing windows in the meantime and no 
longer know what's available.  My point was that it is possible to 
automate windows reliably as long as the programming is robust. You 
indicated you found automating unreliable -- I disagree.


Emile


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


[issue28304] Condition.wait() doesn't raise KeyboardInterrupt

2016-09-28 Thread Adam Roberts

New submission from Adam Roberts:

This was fixed for Python 3 in https://bugs.python.org/issue8844 but needs to 
be backported.

--
components: Library (Lib)
messages: 277639
nosy: Adam Roberts
priority: normal
severity: normal
status: open
title: Condition.wait() doesn't raise KeyboardInterrupt
type: behavior
versions: Python 2.7

___
Python tracker 

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



Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Paul Moore
On Wednesday, 28 September 2016 10:19:01 UTC+1, Chris Angelico  wrote:
> If monads allow mutations or side effects, they are by definition not
> pure functions, and violate your bullet point. Languages like Haskell
> have them not because they are an intrinsic part of functional
> programming languages, but because they are an intrinsic part of
> practical/useful programming languages.

Monads don't "allow" mutations or side effects. However, they allow you to 
express the *process* of making mutations or side effects in an abstract manner.

What "allows side effects" in languages like Haskell is the fact that the 
runtime behaviour of the language is not defined as "calculating the value of 
the main function" but rather as "making the process that the main functon 
defines as an abstract monad actually happen".

That's a completely informal and personal interpretation of what's going on, 
and Haskell users might not agree with it[1]. But for me the key point in 
working out what Haskell was doing was when I realised that their execution 
model wasn't the naive "evaluate the main function" model that I'd understood 
from when I first learned about functional programming.

Paul

[1] One of the problems with modern functional programming is that they 
typically have major problems explaining their interpretation of what's going 
on, with the result that they generally lose their audience long before they 
manage to explain the actually useful things that come from their way of 
thinking.
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2016-09-28 Thread Paul Moore
On Tuesday, 27 September 2016 02:49:08 UTC+1, jf...@ms4.hinet.net  wrote:
> This function is in a DLL. It's small but may run for days before complete. I 
> want it takes 100% core usage. Threading seems not a good idea for it shares 
> the core with others. Will the multiprocessing module do it? Any suggestion?

Taking a step back from the more detailed answers, would I be right to assume 
that you want to call this external function multiple times from Python, and 
each call could take days to run? Or is it that you have lots of calls to make 
and each one takes a small amount of time but the total time for all the calls 
is in days?

And furthermore, can I assume that the external function is *not* written to 
take advantage of multiple CPUs, so that if you call the function once, it's 
only using one of the CPUs you have? Is it fully utilising a single CPU, or is 
it actually not CPU-bound for a single call?

To give specific suggestions, we really need to know a bit more about your 
issue.

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


Re: Is there a way to change the closure of a python function?

2016-09-28 Thread alister
On Wed, 28 Sep 2016 21:48:20 +1000, Steve D'Aprano wrote:

> On Wed, 28 Sep 2016 08:03 pm, Lawrence D’Oliveiro wrote:
> 
>> On Wednesday, September 28, 2016 at 9:53:05 PM UTC+13, Gregory Ewing
>> wrote:
>>> Essentially you write the whole program in continuation-
>>> passing style, with a state object being passed down an infinite chain
>>> of function calls.
>> 
>> Procedural programming under another name...
> 
> Only in the sense that procedural programming is unstructured
> programming under another name. What is a procedure call but a disguised
> GOSUB, and what is GOSUB but a pair of GOTOs?

by this analysis isn't any function call the same?

are not loops just stylised  conditional gotos?




-- 
We only support a 28000 bps connection.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28247] Add an option to zipapp to produce a Windows executable

2016-09-28 Thread Brett Cannon

Brett Cannon added the comment:

Only backport if you want; it's not a bug fix so technically it doesn't need to 
be backported.

--

___
Python tracker 

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



[issue28217] Add interactive console tests

2016-09-28 Thread Steve Dower

Changes by Steve Dower :


--
assignee:  -> steve.dower

___
Python tracker 

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



[issue27565] Offer error context manager for code.interact

2016-09-28 Thread Berker Peksag

Berker Peksag added the comment:

Hi Claudiu, thanks for the report, but I don't think this is a common use case 
that needs to be supported in the standard library. Other people may prefer to 
use different solutions in a similar case (e.g. using a debugger) Plus, it's 
not hard to implement this as a custom context manager in your code.

--
nosy: +berker.peksag
resolution:  -> rejected
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



[issue28295] PyUnicode_AsUCS4 doc and impl conflict on exception

2016-09-28 Thread Xiang Zhang

Xiang Zhang added the comment:

Here is the patch.

--
keywords: +patch
stage:  -> patch review
Added file: http://bugs.python.org/file44870/PyUnicode_AsUCS4.patch

___
Python tracker 

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



[issue23520] test_os failed (python-3.4.3, Linux SuSE)

2016-09-28 Thread Berker Peksag

Berker Peksag added the comment:

This is a duplicate of issue 11341.

--
nosy: +berker.peksag
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> test_os fails

___
Python tracker 

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



[issue28281] Remove year limits from calendar

2016-09-28 Thread Raymond Hettinger

Raymond Hettinger added the comment:

> Under my proposal year=-1 is 2 B.C. and year 0 is a leap year

We should refuse the temptation to guess (i.e. make up our own arbitrary 
interpretations).   Instead, just document the known limits.

--
nosy: +rhettinger

___
Python tracker 

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



[issue27435] ctypes library loading and AIX - also for 2.7.X (and later)

2016-09-28 Thread Michael Felt

Changes by Michael Felt :


Added file: http://bugs.python.org/file44869/_aix.py

___
Python tracker 

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



[issue28300] [PATCH] Fix misspelled "implemented" word

2016-09-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset ce19dcce84fe by Berker Peksag in branch '3.5':
Issue #28300: Fix typos, patch by Shlomi Fish
https://hg.python.org/cpython/rev/ce19dcce84fe

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

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

--
nosy: +python-dev

___
Python tracker 

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



  1   2   3   >