[issue34999] copy.copy and deepcopy do return same logger objects in 3.7

2018-10-17 Thread Vinay Sajip


Vinay Sajip  added the comment:

Loggers are singletons, so the pickling operation just pickles the name. 
Unpickling just leads to getting the pickled name and calling getLogger(name), 
which will return the same object that was pickled (I'd forgotten about 
issue30520).

I suggest as a workaround that a context manager approach could be used to save 
and restore part of the logging configuration around various operations (at 
least levels and handlers), as outlined here:

https://docs.python.org/3/howto/logging-cookbook.html#using-a-context-manager-for-selective-logging

This would avoid the need for making copies just to save and restore state.

--

___
Python tracker 

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



[issue35011] expat: Restore the use of pyexpatns.h to avoid link time conflicts vs other versions

2018-10-17 Thread Benjamin Peterson


Benjamin Peterson  added the comment:

Sorry for breaking that, and thanks for the fix!

I'm curious, though, why are you still using the embedded expat rather than 
linking everything against the same expat?

--

___
Python tracker 

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



[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Would be worth to add a wrapper in functools which revert the sorting order?

class reverted_order:
def __init__(self, value):
self.value = value
def __lt__(self, other):
if isinstance(other, reverted_order):
other = other.value
return self.value.__ge__(other)
# __le__, __gt__, __ge__, __eq__, __ne__, __hash__

Then you could use key=lambda x: (x['url'], reverted_order(x['user'])).

--

___
Python tracker 

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



[issue34670] Add set_post_handshake_auth for TLS 1.3

2018-10-17 Thread Nathaniel Smith


Nathaniel Smith  added the comment:

FYI Christian, your "typical scenario for HTTP" doesn't make sense to me... you 
can't send HTTP Connection Upgrade in the middle of a regular request/response 
cycle. I feel like the typical scenario ought to be more like:

* client
  * send ``HTTP GET /path``
* server
  * recv
  * verify_client_post_handshake (maybe... via calling SSL_do_handshake again?)
* client
  * recv
  * send upgrade confirmation (emits Certificate, CertificateVerify, Finish 
message)
* server
  * recv
  * verify certificate
  * send either the requested response, or a 401 Unauthorized depending

But I don't really understand the underlying design here, either at the TLS 1.3 
level or the openssl level, and haven't found very useful docs yet, so I could 
be wrong.

--
nosy: +njs

___
Python tracker 

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



[issue30999] statistics module: add "key" keyword argument to median, mode, ...

2018-10-17 Thread Michal Nowikowski


Michal Nowikowski  added the comment:

What is the progress of this issue?
I'm also interested in this feature.
I expected that these functions will behave as built-in min and max.
They have key argument, see here: 
https://docs.python.org/3/library/functions.html#max

--
nosy: +godfryd

___
Python tracker 

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



[issue34909] StrEnum subclasses cannot be created

2018-10-17 Thread Ethan Furman


Ethan Furman  added the comment:

Okay, the patch is here:

https://github.com/ethanfurman/cpython/tree/enum_news_entry

But I managed to screw something up, and my wife just got hit by a car so this 
is now a really low priority.

Ned, if you could grab the relevant pieces from the wreck that is that branch I 
would be grateful.

--

___
Python tracker 

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



[issue34370] Tkinter scroll issues on macOS

2018-10-17 Thread Kevin Walzer


Kevin Walzer  added the comment:

Release of Tk 8.6.9 very soon; includes fixes for Mac scrolling as well as 
support for 10.14 macOS, with Dark Mode.

--

___
Python tracker 

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



[issue35011] expat: Restore the use of pyexpatns.h to avoid link time conflicts vs other versions

2018-10-17 Thread Gregory P. Smith


Change by Gregory P. Smith :


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

___
Python tracker 

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



[issue35011] expat: Restore the use of pyexpatns.h to avoid link time conflicts vs other versions

2018-10-17 Thread miss-islington


miss-islington  added the comment:


New changeset 35ae99d7b394af0ce01460f7bccd7449a82289ad by Miss Islington (bot) 
in branch '3.7':
[3.7] bpo-35011: Restore use of pyexpatns.h in libexpat (GH-9939) (GH-9940)
https://github.com/python/cpython/commit/35ae99d7b394af0ce01460f7bccd7449a82289ad


--

___
Python tracker 

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



[issue35011] expat: Restore the use of pyexpatns.h to avoid link time conflicts vs other versions

2018-10-17 Thread miss-islington


miss-islington  added the comment:


New changeset 4bfecb9298d447d5599ea76f3f68f772c38b8fd0 by Miss Islington (bot) 
in branch '3.6':
[3.6] bpo-35011: Restore use of pyexpatns.h in libexpat (GH-9939) (GH-9941)
https://github.com/python/cpython/commit/4bfecb9298d447d5599ea76f3f68f772c38b8fd0


--
nosy: +miss-islington

___
Python tracker 

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



[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Sorry to comment on the closed issue. I think the multisort recipe [0] is 
pretty neat can be added to the sorting howto page instead of being lost in the 
mailing list thread. It was suggested for addition later in the thread but 
never got added.

I guess I will open up a separate issue for the open PR and possibly add the 
recipe with the PR if it's okay. Thoughts?

Thanks much for the explanation Tim :)

[0] https://mail.python.org/pipermail/python-ideas/2016-October/043045.html

--

___
Python tracker 

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



[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Tim Peters


Tim Peters  added the comment:

This comes up every few years, but that's about it.  Here's the iteration from 
2 years ago:

https://mail.python.org/pipermail/python-ideas/2016-October/043039.html

Follow the thread.  It contains easy-to-use wrappers for both "do it in 
multiple simple passes" and "do it in one messy pass" approaches.  It's 
impossible for an implementation to guess in advance which will be faster - it 
depends on the data, which only the user can know about in advance.  There's 
nothing the implementation could do to improve O() behavior regardless.

If there were "real" demand for this, someone by now would have packaged those 
wrappers and made them available on PyPI.  Since that seems not to have 
happened, I agree with Raymond rejecting this idea for the core at this time.  
There would be a higher-than-usual bar for that anyway, because the sorting 
code is already highly complex, and building in the wrappers would be a 
tedious, long-winded exercise in recoding in C what's _easily_ coded in Python 
already.

--

___
Python tracker 

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



[issue35011] expat: Restore the use of pyexpatns.h to avoid link time conflicts vs other versions

2018-10-17 Thread miss-islington


Change by miss-islington :


--
pull_requests: +9292

___
Python tracker 

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



[issue35011] expat: Restore the use of pyexpatns.h to avoid link time conflicts vs other versions

2018-10-17 Thread miss-islington


Change by miss-islington :


--
pull_requests: +9291

___
Python tracker 

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



[issue35011] expat: Restore the use of pyexpatns.h to avoid link time conflicts vs other versions

2018-10-17 Thread Gregory P. Smith


Gregory P. Smith  added the comment:


New changeset 9d4712bc8f26bf1d7e626b53ab092fe030bcd68d by Gregory P. Smith in 
branch 'master':
bpo-35011: Restore use of pyexpatns.h in libexpat (GH-9939)
https://github.com/python/cpython/commit/9d4712bc8f26bf1d7e626b53ab092fe030bcd68d


--

___
Python tracker 

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



[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Raymond Hettinger


Change by Raymond Hettinger :


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



[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Cyker, thank you for the suggestion, but we're going to decline.   The sorting 
HOWTO docs show how to exploit sort stability with multiple passes to handle a 
mix of ascending and descending steps.  It would complicate the API to have an 
array of key functions, each with their own ascending and descending flag. 
Likewise, it would also complicate the implementation.  

The added complexity just isn't worth it when we already have a reasonable 
solution and when the use case itself isn't very common.

--
assignee:  -> rhettinger
nosy: +rhettinger
resolution:  -> rejected

___
Python tracker 

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



[issue35005] argparse should accept json and yaml argument types

2018-10-17 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Bob, do you prefer the current arrange where the user needs to write their own 
"type" function to handle JSON and YAML, or would you like to add this as a 
built-in option?

--
assignee:  -> bob.ippolito
nosy: +bob.ippolito, rhettinger

___
Python tracker 

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



[issue35011] expat: Restore the use of pyexpatns.h to avoid link time conflicts vs other versions

2018-10-17 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
keywords: +patch
pull_requests: +9290
stage: needs patch -> patch review

___
Python tracker 

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



[issue35011] expat: Restore the use of pyexpatns.h to avoid link time conflicts vs other versions

2018-10-17 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

This appears to not have been shipped in a release yet.  It is new in 3.6.7.  
cc'ing ned daily to see if he wants to include the fix (the PR is trivial, 
coming ASAP).

I don't have a good feel for how this impacts the real world or not.

We noticed because we embed CPython in larger applications that use a different 
copy of libexpat on their own.

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

___
Python tracker 

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



[issue35011] expat: Restore the use of pyexpatns.h to avoid link time conflicts vs other versions

2018-10-17 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

Not a release blocker as most users probably do not run into this problem, but 
the pyexpatns.h mechanics should be restored.

--
assignee:  -> gregory.p.smith
components: +Build, Extension Modules
nosy: +benjamin.peterson
stage:  -> needs patch
title: Update to expat removed the pyexpatns.h, causing link time symbol 
conflicts vs other versions in an application -> expat: Restore the use of 
pyexpatns.h to avoid link time conflicts vs other versions
type:  -> compile error

___
Python tracker 

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



[issue35011] Update to expat removed the pyexpatns.h, causing link time symbol conflicts vs other versions in an application

2018-10-17 Thread Gregory P. Smith


New submission from Gregory P. Smith :

These lines used to exist in Modules/expat/expat_external.h:

/* Namespace external symbols to allow multiple libexpat version to
   co-exist. */
#include "pyexpatns.h"

https://github.com/python/cpython/commit/5dc3f23b5fb0b510926012cb3732dae63cddea60#diff-3afaf7274c90ce1b7405f75ad825f545

removed them during an expat upgrade.

This causes link time conflicts when embedding Python using its own expat in an 
application that also uses libexpat from the C/C++ side on its own.

--
messages: 327919
nosy: gregory.p.smith
priority: normal
severity: normal
status: open
title: Update to expat removed the pyexpatns.h, causing link time symbol 
conflicts vs other versions in an application
versions: Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue24658] open().write() fails on 2 GB+ data (OS X)

2018-10-17 Thread Stéphane Wirtel

Change by Stéphane Wirtel :


--
pull_requests: +9289

___
Python tracker 

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



[issue24568] Misc/NEWS: "free-after-use" -> "use-after-free"

2018-10-17 Thread Stéphane Wirtel

Change by Stéphane Wirtel :


--
pull_requests: +9288

___
Python tracker 

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



[issue24658] open().write() fails on 2 GB+ data (OS X)

2018-10-17 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset a5ebc205beea2bf1501e4ac33ed6e81732dd0604 by Victor Stinner 
(Stéphane Wirtel) in branch '3.6':
[3.6] bpo-24658: Fix read/write greater than 2 GiB on macOS (GH-1705) (GH-9937)
https://github.com/python/cpython/commit/a5ebc205beea2bf1501e4ac33ed6e81732dd0604


--

___
Python tracker 

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



[issue24658] open().write() fails on 2 GB+ data (OS X)

2018-10-17 Thread Stéphane Wirtel

Change by Stéphane Wirtel :


--
pull_requests: +9287

___
Python tracker 

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



[issue24658] open().write() fails on 2 GB+ data (OS X)

2018-10-17 Thread STINNER Victor


Change by STINNER Victor :


--
versions: +Python 2.7, Python 3.7, Python 3.8 -Python 3.5

___
Python tracker 

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



[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

> And you are free to use whatever sorting algorithms in its implementation for 
> this kind of task.

That's very kind of you *wink*

At this point, I don't think there's much more point to discussing this further 
until Tim Peters weighs in and lets us know what he thinks. If he loves the 
idea, and is able to implement it, it may happen; if he is luke-warm or hates 
it, probably not.

(My own *personal* view is that unless there is an obvious and consistent 
performance win from adding this, adding the extra complexity to both the sort 
implementation and the interface isn't worth the effort. Not every simple 
helper function needs to be a builtin.)

--

___
Python tracker 

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



[issue24658] open().write() fails on 2 GB+ data (OS X)

2018-10-17 Thread miss-islington


Change by miss-islington :


--
pull_requests: +9286

___
Python tracker 

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



[issue24658] open().write() fails on 2 GB+ data (OS X)

2018-10-17 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset 74a8b6ea7e0a8508b13a1c75ec9b91febd8b5557 by Victor Stinner 
(Stéphane Wirtel) in branch 'master':
bpo-24658: Fix read/write greater than 2 GiB on macOS (GH-1705)
https://github.com/python/cpython/commit/74a8b6ea7e0a8508b13a1c75ec9b91febd8b5557


--

___
Python tracker 

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



[issue27405] Ability to trace Tcl commands executed by Tkinter

2018-10-17 Thread Cheryl Sabella


Cheryl Sabella  added the comment:

Seems like this didn't make 3.7.  Would it be good to make a PR targeting 3.8?

--
nosy: +cheryl.sabella

___
Python tracker 

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



[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Cyker Way


Cyker Way  added the comment:

As for performance, I think both single-pass and multi-pass sorts have 
worst-case time complexity `m * n * log(n)`, assuming the number of items is 
`n` and each item has dimension `m`. Whichever is faster seems to be 
data-dependent. So I made a more comprehensive performance evaluation in 
`performance-1.py`. It turns out either single-pass or multi-pass can be 
80-100% faster than the other, on different inputs.

Since single-pass and multi-pass sorts are good at different inputs and there 
is currently no statistics on real application data supporting either, both 
look OK to me. But I hope you can add something in the interface of sorting 
functions (mainly `sorted` and `list.sort`) so that users don't have to write 
that multi-pass sort again and again. If the `keyspec` format is deemed too 
complicated, `keys` and `reverses` also look good to me:

sorted(items, keys=(key0, key1, key2), reverses=(True, False, True))

And you are free to use whatever sorting algorithms in its implementation for 
this kind of task.

--
Added file: https://bugs.python.org/file47877/performance-1.py

___
Python tracker 

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



[issue20582] socket.getnameinfo() does not document flags

2018-10-17 Thread Cheryl Sabella


Change by Cheryl Sabella :


--
keywords: +easy
stage:  -> needs patch
type:  -> enhancement
versions: +Python 3.8 -Python 2.7, Python 3.3, Python 3.4

___
Python tracker 

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



[issue14911] generator.throw() documentation inaccurate

2018-10-17 Thread Cheryl Sabella


Cheryl Sabella  added the comment:

It seems that this patch was close to being merged.  Would it be helpful for me 
to create a PR for it over 3.8?  Thanks!

--
nosy: +cheryl.sabella

___
Python tracker 

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



[issue24658] open().write() fails on 2 GB+ data (OS X)

2018-10-17 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

Hi all,

Could you test the PR with Windows? I don't have a Windows computer.

Thank you,

Stéphane

--

___
Python tracker 

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



[issue32892] Remove specific constant AST types in favor of ast.Constant

2018-10-17 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +9285

___
Python tracker 

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



[issue35006] itertools.combinations has wrong type when using the typing package

2018-10-17 Thread Brett Cannon


Change by Brett Cannon :


--
resolution:  -> third party
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue35005] argparse should accept json and yaml argument types

2018-10-17 Thread paul j3


paul j3  added the comment:

If I define a 'type' function like:

def readdata(astr):
if astr.startswith('@'):
with open(astr[1:], 'r') as f:
d = json.load(f)
return d
else:
return astr

I can use it to load a json file, or use the string directly:

In [59]: parser = argparse.ArgumentParser()
In [60]: parser.add_argument('-d','--data', type=readdata);
In [61]: parser.parse_args(['-d','@foo.json'])
Out[61]: Namespace(data={'foo': 12, 'bar': 'twelve'})
In [62]: parser.parse_args(['-d','xxx'])
Out[62]: Namespace(data='xxx')

This seems to behave as the 'curl' and 'ansible' examples you give, where the 
interpretation of the '@' is option specific.

A fully functional version of this type function needs to catch possible errors 
(not a file, not proper json, etc) and raise a ValueError or 
argparse.ArgumentTypeError.

The fact that 'curl -d' uses the '@', and 'fromfile_prefix_args' uses '@' in 
the documentation, should be seen as purely coincidental.  argparse would be 
just as happy using '#' or '%' as fromfile-prefix characters, just so long as 
the shell passes them unchanged to 'sys.argv'.  Conversely a type function can 
pay attention to special characters without needing to define them in the 
parser definition.

argparse doesn't define many custom 'type' functions.  Mostly it depends on 
people using stock Python functions like 'int' and 'float', or writing their 
own functions.  This keeps things simple for the common uses, while giving more 
advanced users a lot of flexibility.

This '@file' sensitivity could also be built into a custom Action subclass.  
There too, argparse has defined a set of common cases, but lets the users 
customize to their heart's content.

--

___
Python tracker 

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



[issue34995] functools.cached_property does not maintain the wrapped method's __isabstractmethod__

2018-10-17 Thread Matt Wilber


Matt Wilber  added the comment:

To add some more context, the existing Python documentation is a little 
misleading in this situation:

https://docs.python.org/3/library/abc.html#abc.abstractmethod

It shows that labeling a method with

@property
@abstractmethod

ought to be done in the order above, but this ordering currently breaks the 
abstract method check if you swap our @property for @cached_property. The 
documentation also says

"In order to correctly interoperate with the abstract base class machinery, the 
descriptor must identify itself as abstract using __isabstractmethod__." which 
@cached_property does not do, but as the documentation then shows, @property 
does do this properly.

--

___
Python tracker 

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



[issue34623] _elementtree.c doesn't call XML_SetHashSalt()

2018-10-17 Thread Charalampos Stratakis


Change by Charalampos Stratakis :


--
pull_requests: +9284

___
Python tracker 

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



[issue34901] Missing isolated (-I) flag in sys.flags table

2018-10-17 Thread Danish Prakash


Change by Danish Prakash :


--
pull_requests: +9283

___
Python tracker 

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



[issue34901] Missing isolated (-I) flag in sys.flags table

2018-10-17 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

In spite of what is said above, PR 9708 was merged before the auto-backport.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue34995] functools.cached_property does not maintain the wrapped method's __isabstractmethod__

2018-10-17 Thread Matt Wilber


Matt Wilber  added the comment:

I agree, a comment can serve the same purpose. But for the same reasons it's 
useful to express typing hints in Python with real syntax, and the reasons it's 
useful to have the abc module in the first place, I think it is useful to be 
able to annotate an abstract method with @cachedproperty.

The purpose of this change is not to add code developers would try to use at 
runtime, it is to allow developers to communicate their intentions to static 
code analysis tools and to other developers, using standard decorators from 
builtins that do not break one another. Indeed, abstract methods should not be 
executed (on purpose), but Python still supports abstract methods to protect 
developers who want to explicitly label their code as "do not execute".

Therefore, please do not think of this change as something someone would try to 
execute. It is for hinting functionality, and it is to protect developers who 
would decorate a method with @cached_property and @abstractmethod and find that 
abc's functionality was unexpectedly broken.

--

___
Python tracker 

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



[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Cyker Way


Cyker Way  added the comment:

Previous upload `example.py` was missing `__eq__`. Updated in `example-1.py`.

--
Added file: https://bugs.python.org/file47876/example-1.py

___
Python tracker 

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



[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


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

___
Python tracker 

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



[issue34814] makesetup: must link C extensions to libpython when compiled in shared mode

2018-10-17 Thread Ned Deily


Ned Deily  added the comment:

Perhaps you should bring up this proposed change in distutils-sig before 
committing.  It's probably an OK change but it would be good to try to get some 
feedback from the downstream users who might be affected by it.

--
nosy: +ned.deily

___
Python tracker 

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



[issue31900] localeconv() should decode numeric fields from LC_NUMERIC encoding, not from LC_CTYPE encoding

2018-10-17 Thread STINNER Victor


STINNER Victor  added the comment:

Victor:
> The technical issue here is that the libc has no "stateless" function to 
> process bytes and text with one specific locale.

Andreas Schwab:
> That's not true.  There is a rich set of *_l functions that take a locale_t 
> object and operate on that locale.

Oh. Do you want to work on a patch to use these functions? If yes, please open 
a new issue to enhance the code.

--

___
Python tracker 

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



[issue30670] pprint for dict in sorted order or insert order?

2018-10-17 Thread Jan-Hein Bührman

Jan-Hein Bührman  added the comment:

@terry.reedy - If I understand correctly, this issue was closed by you awaiting 
what would happen with the dict insertion order after 3.6.

It has been decided that dict insertion will stay for now and in the future. 
>>> Should this issue now be reopened?

And I would favor backward compatibility (key sort order) with an additional 
keyword for pprint to display it "unsorted" order (from pprint perspective, 
insertion order for dicts and OrderedDicts, and whatever other order for 
whatever other dicts).

--
nosy: +Jan-Hein Bührman

___
Python tracker 

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



[issue32892] Remove specific constant AST types in favor of ast.Constant

2018-10-17 Thread STINNER Victor


STINNER Victor  added the comment:

> This change broke two templating engines:
> * Genshi: https://github.com/python/performance/issues/46

upstream issue: https://genshi.edgewall.org/ticket/612

> * Chameleon: https://github.com/python/performance/issues/47

upstream issue: https://github.com/malthe/chameleon/issues/272

--

___
Python tracker 

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



[issue32892] Remove specific constant AST types in favor of ast.Constant

2018-10-17 Thread STINNER Victor


STINNER Victor  added the comment:

This change broke two templating engines:

* Genshi: https://github.com/python/performance/issues/46
* Chameleon: https://github.com/python/performance/issues/47

--

___
Python tracker 

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



[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

The ``sorted`` docs links to the Sorting HOWTO, the ``list.sort`` docs should 
do the same.

https://docs.python.org/3/library/functions.html#sorted

https://docs.python.org/3/library/stdtypes.html#list.sort

--

___
Python tracker 

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



[issue34996] Add name to process and thread pool

2018-10-17 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

Hi Raz,

1. Please could you sign the CLA?
2. About the name, why did you use these names? Is there a discussion somewhere 
about the names?

Thank you

--
nosy: +matrixise

___
Python tracker 

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



[issue34035] Several AttributeError in zipfile seek() methods

2018-10-17 Thread Dariush Azimi


Dariush Azimi  added the comment:

Had the same issue with python 3.7 and went back to python 3.6. There are no 
issues with python 3.6.4

--
nosy: +Dariush Azimi

___
Python tracker 

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



[issue35005] argparse should accept json and yaml argument types

2018-10-17 Thread Robert Benson


Robert Benson  added the comment:

What I'm talking about is reading a single arg (of a dictionary or collection 
type) that can be split across multiple lines, rather than a single line 
containing multiple args

My motivation was that reading args from a file should behave in a manner 
similar to other command-line utilities, such as the `-d` option for `curl` and 
the `-e` option for `ansible`. These take the entire file you give it and store 
it as one dictionary or object, not by merging it with the rest of the 
namespace but by taking the dictionary as the value of just that arg. So:

argument_parser.add_argument("-d", "--data", type=argparse.JsonType)  # just 
for example

if I call the program with `--data @foo.json`
I want argument_parser.parse_args().data to be the dict that is in foo.json, 
whether foo.json is pretty-printed or not.

I haven't done an exhaustive search of StackOverflow, but seeing a couple top 
answers indicated that this was not readily available without the user at least 
having to call `json.loads` on a string argument themselves, when it seems 
logical that it would be built into the library to parse the json into a 
dictionary

--

___
Python tracker 

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



[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Cyker Way


Cyker Way  added the comment:

Multi-pass stable sorts should produce the correct result. But as the number of 
columns grow the code gets messy. For brevity this example only has 2 columns 
but it may be 10 or more in a real application. Furthermore, in some cases the 
application may need to remember which columns are sorted asc/desc so you have 
to keep that piece of data (termed `keyspec` but can be any meaningful name) 
anyway. It would be ideal if a builtin function can directly operate on this 
data instead of manually writing a multi-pass sorting logic;

The proposed prototype (`c.py`) is aimed at minimizing the amount of code 
needed to illustrate the problem and is not optimized for performance. There is 
a performance hit where it wraps one object into another, but this should be 
able to be avoided. If you want to compare real performance between single- and 
multi-pass sorts, you can run this script `performance.py` instead. My test 
result is that multi-pass sorting takes 75% more time, YMMV.

--
Added file: https://bugs.python.org/file47875/performance.py

___
Python tracker 

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



[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

@Serhiy I just checked the docs to add an example and it's explained with an 
example at [0] :)


```

Sorts are guaranteed to be stable. That means that when multiple records have 
the same key, their original order is preserved.

This wonderful property lets you build complex sorts in a series of sorting 
steps. For example, to sort the student data by descending grade and then 
ascending age, do the age sort first and then sort again using grade:

>>> s = sorted(student_objects, key=attrgetter('age')) # sort on secondary 
>>> key
>>> sorted(s, key=attrgetter('grade'), reverse=True)   # now sort on 
>>> primary key, descending
[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]

The Timsort algorithm used in Python does multiple sorts efficiently because it 
can take advantage of any ordering already present in a dataset.

```

As noted TimSort makes this efficient by taking advantage of the sorting in the 
first run though it was not done as a single pass. If I am bench marking 
correctly in the attached file then for a list with 400 items using multiple 
pass sort is 4-5x faster than the suggested sorting in Python 3.7 and also more 
readable (though my lambda call is messy :)

Multiple pass sort :
3.871509724
Suggested sort :
17.237952677


[0] 
https://docs.python.org/3/howto/sorting.html#sort-stability-and-complex-sorts

--
Added file: https://bugs.python.org/file47874/bpo35010_1.py

___
Python tracker 

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



[issue23420] python -m cProfile -s fails with non informative message

2018-10-17 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

welcome

--

___
Python tracker 

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



[issue23420] python -m cProfile -s fails with non informative message

2018-10-17 Thread STINNER Victor

STINNER Victor  added the comment:

Thanks Robert Kuska for the bug report and the initial patch, thanks Stéphane 
Wirtel for the PR (with the NEWS entry and the new test ;-))

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.7, Python 3.8 -Python 3.5

___
Python tracker 

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



[issue24564] shutil.copytree fails when copying NFS to NFS

2018-10-17 Thread Charlie Dyson


Change by Charlie Dyson :


--
nosy: +cdyson37

___
Python tracker 

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



[issue23420] python -m cProfile -s fails with non informative message

2018-10-17 Thread miss-islington

miss-islington  added the comment:


New changeset 6e57382464101d2669a425622e19fff57586b2ff by Miss Islington (bot) 
(Stéphane Wirtel) in branch '2.7':
[2.7] bpo-23420: Verify the value of '-s' when execute the CLI of cProfile 
(GH-9925) (GH-9928)
https://github.com/python/cpython/commit/6e57382464101d2669a425622e19fff57586b2ff


--

___
Python tracker 

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



[issue23420] python -m cProfile -s fails with non informative message

2018-10-17 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset 669fa8b6376ee8703ae4383536dfcc0e96e51b78 by Victor Stinner 
(Stéphane Wirtel) in branch '3.6':
[3.6] bpo-23420: Verify the value of '-s' when execute the CLI of cProfile 
(GH-9925) (GH-9927)
https://github.com/python/cpython/commit/669fa8b6376ee8703ae4383536dfcc0e96e51b78


--

___
Python tracker 

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



[issue23420] python -m cProfile -s fails with non informative message

2018-10-17 Thread miss-islington

miss-islington  added the comment:


New changeset 657e3f9a2c0d620807dd81882d566ad8f1ae423e by Miss Islington (bot) 
(Stéphane Wirtel) in branch '3.7':
[3.7] bpo-23420: Verify the value of '-s' when execute the CLI of cProfile 
(GH-9925) (GH-9926)
https://github.com/python/cpython/commit/657e3f9a2c0d620807dd81882d566ad8f1ae423e


--
nosy: +miss-islington

___
Python tracker 

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



[issue23420] python -m cProfile -s fails with non informative message

2018-10-17 Thread Stéphane Wirtel

Change by Stéphane Wirtel :


--
pull_requests: +9281

___
Python tracker 

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



[issue23420] python -m cProfile -s fails with non informative message

2018-10-17 Thread Stéphane Wirtel

Change by Stéphane Wirtel :


--
pull_requests: +9280

___
Python tracker 

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



[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Would be nice to add an example in the documentation.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

There was some discussion about it : 
https://lists.gt.net/python/python/539896#539896 . As suggested by Raymond in 
the thread the below can be used to get the desired output

items.sort(key=lambda r: r['user'], reverse=True)
items.sort(key=lambda r: r['url'])

--
nosy: +xtreak

___
Python tracker 

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



[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Since sort is guaranteed to be stable, can't you sort in two runs?


py> values = ['bc', 'da', 'ba', 'abx', 'ac', 'ce', 'dc', 'ca', 'aby']
py> values.sort(key=itemgetter(1), reverse=True)
py> values.sort(key=itemgetter(0))
py> values
['ac', 'abx', 'aby', 'bc', 'ba', 'ce', 'ca', 'dc', 'da']


Its not as efficient as doing a single sort, but its easier to understand than 
a complex API to specify each item's sort direction individually, and therefore 
probably less likely to mess it up and get it wrong.

--
nosy: +steven.daprano, tim.peters

___
Python tracker 

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



[issue23420] python -m cProfile -s fails with non informative message

2018-10-17 Thread Stéphane Wirtel

Change by Stéphane Wirtel :


--
pull_requests: +9279

___
Python tracker 

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



[issue24307] [Python 2] pip error on windows whose current user name contains non-ascii characters

2018-10-17 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

@Victor I think this is an issue with optparse where it can't handle non-ASCII 
strings for %default that is exposed by pip. I can see similar places where 
non-ASCII strings can cause issue in argparse for unicode choices (issue35009). 
I think this is a general issue where str() is used where non-ASCII strings 
throw this error. I am quite new to unicode so I don't know if this issue needs 
to be fixed in Python 2.7 or it's an error from the user end where their script 
needs to be fixed?

--

___
Python tracker 

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



[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Cyker Way


New submission from Cyker Way :

The current `sorted` function is somewhat limited and doesn't cover a use case 
that frequently occurs in real applications: sort by a tuple of keys where each 
key can be in asc or desc order.

For example, you may have a list of site configs where each of specify which 
user on which site gets how much quota. This data may be loaded from a SQL 
table where there are 3 columns: url, user, quota. Often you may want to sort 
by url, but when you want to check which users have been allocated most quota, 
you probably want to sort by quota. Even more likely, when you are sorting by 
quota, you still want to sort by url for those having the same quota.

Unfortunately, current `sorted` function doesn't allow you to sort by desc 
quota and asc url at the same time, because the `reverse` parameter acts on the 
final result, regardless of columns. For numeric columns, there is a trick of 
using minus sign on the data. But this approach usually doesn't apply to other 
types of data.

The general solution is to enhance the key function, allowing users to specify 
each column to be considered, with an asc/desc flag:

keyspec = [
(itemgetter('url'), False),
(itemgetter('user'), True),
]

An example is worth 1k words. The full example is provided in the attachment.

It's not a lot of code to write but making this feature builtin can save a lot 
of work since sorting a SQL table or other sheet data is quite common in real 
applications.

--
components: Library (Lib)
files: c.py
messages: 327886
nosy: cykerway
priority: normal
severity: normal
status: open
title: sort by partially reversed key tuple
type: enhancement
versions: Python 3.8
Added file: https://bugs.python.org/file47873/c.py

___
Python tracker 

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



[issue35001] ImportFrom level cannot be optional

2018-10-17 Thread thautwarm


thautwarm  added the comment:

Firstly, allowing to construct ImportFrom without `level` specified could be 
the result of referring Python-asdl.

Secondly, in C level, `level` is always an integer.

Last but not the least, when you can access `level` from an ImportFrom AST, it 
must be an integer, not None.

--

___
Python tracker 

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



[issue23420] python -m cProfile -s fails with non informative message

2018-10-17 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset fcd5e84a515e19409840c570730f0728e9fcfc83 by Victor Stinner 
(Stéphane Wirtel) in branch 'master':
 bpo-23420: Verify the value of '-s' when execute the CLI of cProfile (GH-9925)
https://github.com/python/cpython/commit/fcd5e84a515e19409840c570730f0728e9fcfc83


--

___
Python tracker 

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



[issue24307] [Python 2] pip error on windows whose current user name contains non-ascii characters

2018-10-17 Thread STINNER Victor


STINNER Victor  added the comment:

pip is not part of Python 2, so I suggest to close this issue as "third party".

I dislike changing optparse just for pip. For me, the bug should be fixed in 
pip, not in optparse. I see a high risk of breaking applications which 
currently work as expected. If the default value is a non-ASCII string, 
unicode() will raise a UnicodeDecodeError.

--
nosy: +vstinner

___
Python tracker 

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



[issue35001] ImportFrom level cannot be optional

2018-10-17 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

The level argument of ast.ImportFrom is optional. If it is not specified or 
None is passes, the corresponding attribute is set to the default value 0.

Type hints are not used in the stdlib. If this is a bug in mypy, this is not 
the proper tracker for reporting it.

--

___
Python tracker 

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



[issue24307] [Python 2] pip error on windows whose current user name contains non-ascii characters

2018-10-17 Thread STINNER Victor


Change by STINNER Victor :


--
title: pip error on windows whose current user name contains non-ascii 
characters -> [Python 2] pip error on windows whose current user name contains 
non-ascii characters

___
Python tracker 

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



[issue24307] pip error on windows whose current user name contains non-ascii characters

2018-10-17 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I suppose there is a similar issue in Python 3 with bytes default.

Using unicode() in Python 2 will make the help string an Unicode string, and 
this can cause an issue with translated help string. And this will cause an 
issue with non-ASCII 8-bit strings.

Using repr() looks a right way of solving such issues, but this will change the 
output for 8-bit strings.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue34995] functools.cached_property does not maintain the wrapped method's __isabstractmethod__

2018-10-17 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

The comment can serve the same purpose.

The caching affects the behavior at run time. Abstract methods should not be 
executed. The cached_property decorator is not inherited by overriding 
properties. I don't think that combining the cached_property and the 
@abstractmethod decorators should be supported.

--

___
Python tracker 

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



[issue34814] makesetup: must link C extensions to libpython when compiled in shared mode

2018-10-17 Thread Xavier de Gaye


Change 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



[issue34814] makesetup: must link C extensions to libpython when compiled in shared mode

2018-10-17 Thread Xavier de Gaye


Change by Xavier de Gaye :


--
Removed message: https://bugs.python.org/msg326509

___
Python tracker 

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



[issue35009] argparse throws UnicodeEncodeError for printing help with unicode choices

2018-10-17 Thread Karthikeyan Singaravelan

New submission from Karthikeyan Singaravelan :

argparse module uses str() in a few places where passing unicode strings will 
throw UnicodeDecodeError. In Python 3 these scripts run fine since Python 3 has 
unicode strings by default. I am working on this along with finding more places 
where this can throw error along with adding relevant tests for those 
scenarios. I couldn't find any related issues for this in the bug tracker. Feel 
free to close this if it's a duplicate. 

# foo_argparse.py with unicode choices

```
# -*- coding: utf-8 -*-

import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--foo', help='foo help', choices=[u"早上好", u"早上好 早上好"])
args = parser.parse_args()

```

# printing help causes error since str is used for choices

$ ./python.exe ../backups/foo_argparse.py --help
Traceback (most recent call last):
  File "../backups/foo_argparse.py", line 5, in 
parser.add_argument('--foo', help='foo help', choices=[u"早上好", u"早上好 早上好"])
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/argparse.py", 
line 1308, in add_argument
self._get_formatter()._format_args(action, None)
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/argparse.py", 
line 578, in _format_args
get_metavar = self._metavar_formatter(action, default_metavar)
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/argparse.py", 
line 565, in _metavar_formatter
choice_strs = [str(choice) for choice in action.choices]
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: 
ordinal not in range(128)


In case we use unicode() for the above and then also fix the place where 
comparison is done then using the correct choice passes. But using wrong choice 
throws an error where exception string is formed using str that causes error


$ ./python.exe ../backups/foo_argparse_unicode.py --foo 早上好 # passes
$ ./python.exe ../backups/foo_argparse_unicode.py --help # passes
usage: foo_argparse_unicode.py [-h] [--foo {早上好,早上好 早上好}]

optional arguments:
  -h, --help   show this help message and exit
  --foo {早上好,早上好 早上好}  foo help


$ ./python.exe ../backups/foo_argparse_unicode.py --foo 1 # Fails
Traceback (most recent call last):
  File "../backups/foo_argparse_unicode.py", line 7, in 
args = parser.parse_args()
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/argparse.py", 
line 1705, in parse_args
args, argv = self.parse_known_args(args, namespace)
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/argparse.py", 
line 1744, in parse_known_args
self.error(str(err))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 49-51: 
ordinal not in range(128)

--
components: Library (Lib)
messages: 327879
nosy: xtreak
priority: normal
severity: normal
status: open
title: argparse throws UnicodeEncodeError for printing help with unicode choices
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



[issue34979] Python throws “SyntaxError: Non-UTF-8 code start with \xe8...” when parse source file

2018-10-17 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

This is a part of more general issue25643. I'll try to revive that issue.

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

___
Python tracker 

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



[issue34876] Python3.8 changes how decorators are traced

2018-10-17 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Ned, please look at PR 9731. Does it fixes the issue to you?

Georg, you had added the original code for patching the lineno of decorated 
function. Are your good to remove this patch and to move updating the first 
line number at the code generation stage?

--

___
Python tracker 

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



[issue23420] python -m cProfile -s fails with non informative message

2018-10-17 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

Hi,

Just used the content of the patch and apply it on master,
Add a unittest and the blurb entry.

--
nosy: +matrixise

___
Python tracker 

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



[issue23420] python -m cProfile -s fails with non informative message

2018-10-17 Thread Stéphane Wirtel

Change by Stéphane Wirtel :


--
pull_requests: +9278

___
Python tracker 

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



[issue35008] Leaks xml.etree.ElementTree.Element.__setsate__()

2018-10-17 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +eli.bendersky, scoder

___
Python tracker 

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



[issue35008] Leaks xml.etree.ElementTree.Element.__setsate__()

2018-10-17 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue12782] Multiple context expressions do not support parentheses for continuation across lines

2018-10-17 Thread thautwarm


thautwarm  added the comment:

How about:

with_stmt: 'with' (with_items | '(' with_items ')') ':' suite
ignored: INDENT | NEWLINE | DEDENT
with_items: with_item (ignored* ',' ignored* with_item)*

--
nosy: +thautwarm

___
Python tracker 

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



[issue34979] Python throws “SyntaxError: Non-UTF-8 code start with \xe8...” when parse source file

2018-10-17 Thread susaki


Change by susaki :


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

___
Python tracker 

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



[issue35008] Leaks xml.etree.ElementTree.Element.__setsate__()

2018-10-17 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

When call the __setstate__() method of xml.etree.ElementTree.Element in the C 
implementation for already initialized element it leaks old children.

--
assignee: serhiy.storchaka
components: Extension Modules
messages: 327873
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Leaks xml.etree.ElementTree.Element.__setsate__()
type: resource usage
versions: Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue34998] Logging formatter validation breaks backward ducktyping

2018-10-17 Thread P.C. Kroon


P.C. Kroon  added the comment:

Hi Vinay,

thanks for the feedback. I agree with your arguments and find an alternative 
solution.

Peter

--

___
Python tracker 

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



[issue34999] copy.copy and deepcopy do return same logger objects in 3.7

2018-10-17 Thread sebix


sebix  added the comment:

Oh, that's something different than I initially thought.

Using copy.deepcopy gives the same result as with copy.copy.

--
title: Different behavior of copied loggers in 3.7 -> copy.copy and deepcopy do 
return same logger objects in 3.7
type:  -> behavior

___
Python tracker 

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



[issue35001] ImportFrom level cannot be optional

2018-10-17 Thread thautwarm


thautwarm  added the comment:

@Anthony

> I don't think mypy has an annotation for "sometimes has an attribute"

Yes.. The annotation for an attribute that **maybe exist** cannot be expressed 
by mypy..

--

___
Python tracker 

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



[issue34973] Crash in bytes constructor with mutating list

2018-10-17 Thread Xiang Zhang


Xiang Zhang  added the comment:

I carefully read both the two PRs. The first one, easy to understand. The 
second one, I spend some time to figure out why the test doesn't crash, why we 
need to have reference count checks in two places and make some experiments to 
test in different cases, how the reference counts will be. I am afraid I have 
to repeat this procedure after some time when reading the code again. :-( And 
while in some cases the second approach increases performance. But in others 
cases it might hurt. Codes storing the array in a variable will go into the 
iterator branch.

--
nosy: +xiang.zhang

___
Python tracker 

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



[issue35001] ImportFrom level cannot be optional

2018-10-17 Thread thautwarm


thautwarm  added the comment:

Hi, Serhiy, for Python-asdl has made `level` able to optional, certainly we 
could construct an ImportFrom AST without giving `level`.

Moreover, this might evidence that `level` cannot be optional in fact:

https://github.com/python/cpython/blob/8e73ad38ab7d218b9ef8976032865928dfad00f1/Python/compile.c#L2918

--

___
Python tracker 

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



[issue34475] functools.partial objects have no __qualname__ attribute

2018-10-17 Thread Chris Jerdonek


Chris Jerdonek  added the comment:

Okay, I thought a partial object was supposed to "look" like a function.

I'm okay with closing this.

--
resolution:  -> rejected

___
Python tracker 

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



[issue35005] argparse should accept json and yaml argument types

2018-10-17 Thread paul j3


paul j3  added the comment:

The results of reading one of these @-prefix files are just spliced into the 
`argv` list before it is parsed.  This is done early in the parsing method, in 
the 

_read_args_from_files

method.  The documentation illustrates how this file reading can be modified to 
take several strings from each line:

https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.convert_arg_line_to_args

That shouldn't be taken as the only possible modification.

That said, I don't see how reading from a JSON or YAML file fits with this 
mechanism.  Presumably those would define some dictionary like key:value pairs. 
 I assume you'd want to enter those directly into the Namespace, not the argv 
list that will be parsed.  Or otherwise merged with a dictionary produced by 
parsing the other commandline strings.

So what you want to do with a JSON file, and how that relates to argparse is 
not clear.  You need to elaborate before we can discuss this issue further.

You might want to search on Stackoverflow with the tags '[argparse] [json]' to 
see how others have tried to use the two together.

--

___
Python tracker 

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



[issue34909] StrEnum subclasses cannot be created

2018-10-17 Thread Ethan Furman


Ethan Furman  added the comment:

Working on getting that news entry.

--

___
Python tracker 

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



[issue34996] Add name to process and thread pool

2018-10-17 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Thanks for the report. I think using current_thread().name gives thread name 
with number that is useful. I don't know the exact use case or maybe I am 
misunderstanding the use case and perhaps adding a script where your PR applies 
with the output will be helpful. I will resort to feedback from others. Adding 
Antoine as per the expert index for multiprocessing module. Antoine, feel free 
to remove yourself if this is irrelevant.


# bpo34720.py

from multiprocessing.pool import ThreadPool

def f(x):
from threading import current_thread
print(current_thread().name)
return x*x

if __name__ == '__main__':
with ThreadPool(5) as p:
print(p.map(f, [1, 2, 3]))


$ ./python.exe ../backups/bpo34720.py
Thread-1
Thread-1
Thread-2
[1, 4, 9]


# With PR and name as "custom-name" for ThreadPool

from multiprocessing.pool import ThreadPool

def f(x):
from threading import current_thread
print(current_thread().name)
return x*x

if __name__ == '__main__':
with ThreadPool(5, name="custom-name") as p:
print(p.map(f, [1, 2, 3]))

git:(pr_9906) ./python.exe ../backups/bpo34720.py
custom-name-Worker-0
custom-name-Worker-1
custom-name-Worker-2
[1, 4, 9]

--
nosy: +pitrou, xtreak

___
Python tracker 

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



[issue35006] itertools.combinations has wrong type when using the typing package

2018-10-17 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Thanks for the report. I agree with Josh. I propose closing this as third-party 
and raising an issue in typeshed GitHub repo.

--
nosy: +xtreak

___
Python tracker 

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