[issue37977] Big red pickle security warning should stress the point even more

2019-08-30 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15297
pull_request: https://github.com/python/cpython/pull/15629

___
Python tracker 

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



[issue37977] Big red pickle security warning should stress the point even more

2019-08-30 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset daa82d019c52e95c3c57275307918078c1c0ac81 by Raymond Hettinger 
(Daniel Pope) in branch 'master':
bpo-37977: Warn more strongly and clearly about pickle security (GH-15595)
https://github.com/python/cpython/commit/daa82d019c52e95c3c57275307918078c1c0ac81


--
nosy: +rhettinger

___
Python tracker 

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



[issue37953] Fix ForwardRef equality checks

2019-08-30 Thread hongweipeng


Change by hongweipeng :


--
pull_requests: +15296
pull_request: https://github.com/python/cpython/pull/15628

___
Python tracker 

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



[issue34410] itertools.tee not thread-safe; can segfault interpreter when wrapped iterator releases GIL

2019-08-30 Thread hongweipeng


hongweipeng  added the comment:

As far as I am concerned, I prefer that like PR 9254 can be merged into old 
versions. Because it does not break the legitimate code and can prevent the 
program from crashing. It can be used as a compatible solution with old 
versions.

--

___
Python tracker 

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



[issue37990] gc.collect prints debug stats incorrectly

2019-08-30 Thread Inada Naoki


Inada Naoki  added the comment:

Thank you for finding it!

My eyes were too focused on portability issue of "%zd"...

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



[issue37990] gc.collect prints debug stats incorrectly

2019-08-30 Thread Inada Naoki


Inada Naoki  added the comment:


New changeset 97a31c7b486c45ba9c21cab5fb96337859a60275 by Inada Naoki in branch 
'3.8':
[3.8] bpo-37990: fix gc stats (GH-15626)
https://github.com/python/cpython/commit/97a31c7b486c45ba9c21cab5fb96337859a60275


--

___
Python tracker 

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



[issue37992] Change datetime.MINYEAR to allow for negative years

2019-08-30 Thread Sam Wainwright


New submission from Sam Wainwright :

The value of datetime.MINYEAR (1) seems arbitrarily restrictive. There are 
plenty of reasons why users of the standard library might want to work with 
negative years. Workarounds involving things like astropy don't work in all 
cases, particularly when you're working with other third-party libraries that 
use python dates internally and forking them is a hassle.

--

___
Python tracker 

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



[issue37992] Change datetime.MINYEAR to allow for negative years

2019-08-30 Thread Sam Wainwright


Change by Sam Wainwright :


--
components: Library (Lib)
nosy: Sam Wainwright
priority: normal
severity: normal
status: open
title: Change datetime.MINYEAR to allow for negative years
type: enhancement
versions: Python 3.7

___
Python tracker 

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



[issue37988] Issue found during language name processing in a list

2019-08-30 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

This code derived from the blurry image

lst = ['malaysian', 'malayalam', 'a']
ip = input('word ')
li = len(ip)
miss = 0
for word in lst:
if len(word) == li:
for j in range(li-1):  # skip last because of lookahead
if word[j] != ip[j] and word[j+1] != ip[j]:
 miss += 1
if miss < li/2:
print(word)

run with 3.8.0b4 on Win10 in IDLE prints the expected output.

word malayalam
malaysian
malayalam

I leave it to you to find out why you got something different and to play with 
variations. Please direct any questions to python-list or similar forums, as 
they will almost certainly be off-topic here.  And do follow the advice about 
question format and providing code as text.

Steven, the code ran without error in PyCharm, but gave no matches.  I presume 
that the 'error' was not matching 'malaysian' even though the miss count 4 is 
less than 4.5.  I must have corrected something when reading the blurs and 
polishing the code.

--
nosy: +terry.reedy
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue37989] documentation format error in Chinese version

2019-08-30 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

The translations of the docs are maintained in a separate repository by a 
separate group of people.  The sidebar on the left of the page you linked to 
has a link called '提交 Bug' to 
https://docs.python.org/zh-cn/3/bugs.html.  I am guessing that this page or one 
it links to has instruction on where to send translation bug reports.

--
nosy: +mdk, terry.reedy
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



[issue37981] Can't install Python 3.7.4 x64 on Win 8.1

2019-08-30 Thread Terry J. Reedy


Change by Terry J. Reedy :


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

___
Python tracker 

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



[issue37990] gc.collect prints debug stats incorrectly

2019-08-30 Thread Inada Naoki


Change by Inada Naoki :


--
pull_requests: +15295
pull_request: https://github.com/python/cpython/pull/15627

___
Python tracker 

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



[issue29553] Argparser does not display closing parentheses in nested mutex groups

2019-08-30 Thread Berker Peksag


Berker Peksag  added the comment:

Yes, we can. Thank you for the backport, Raymond :)

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



[issue37990] gc.collect prints debug stats incorrectly

2019-08-30 Thread Inada Naoki


Inada Naoki  added the comment:


New changeset 013e52fd340d9ef558013b546f25456f94ee1804 by Inada Naoki in branch 
'master':
bpo-37990: fix gc stats (GH-15626)
https://github.com/python/cpython/commit/013e52fd340d9ef558013b546f25456f94ee1804


--

___
Python tracker 

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



[issue37781] Use "z" for PY_FORMAT_SIZE_T

2019-08-30 Thread Inada Naoki


Change by Inada Naoki :


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



[issue37781] Use "z" for PY_FORMAT_SIZE_T

2019-08-30 Thread Inada Naoki


Inada Naoki  added the comment:


New changeset d765d81b8fb5ab707bfe8b079348e5038c298aa3 by Inada Naoki in branch 
'master':
bpo-37781: use "z" for PY_FORMAT_SIZE_T (GH-15156)
https://github.com/python/cpython/commit/d765d81b8fb5ab707bfe8b079348e5038c298aa3


--

___
Python tracker 

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



[issue37990] gc.collect prints debug stats incorrectly

2019-08-30 Thread Inada Naoki


Change by Inada Naoki :


--
keywords: +patch
pull_requests: +15294
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/15626

___
Python tracker 

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



[issue37991] What is this? What is problem?

2019-08-30 Thread Steve Dower


Steve Dower  added the comment:

Python 64-bit requires a 64-bit operating system, otherwise it doesn't have any 
way to support the processor.

You should install 32-bit Python instead. The latest release is at 
https://www.python.org/ftp/python/3.7.4/python-3.7.4-webinstall.exe but if you 
really need 3.5.3 for some reason you can find it at 
https://www.python.org/downloads/release/python-353/ (select the "x86" 
installer, not "x86-64")

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
type: compile error -> 

___
Python tracker 

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



[issue34410] itertools.tee not thread-safe; can segfault interpreter when wrapped iterator releases GIL

2019-08-30 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +15293
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/15625

___
Python tracker 

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



[issue37991] What is this? What is problem?

2019-08-30 Thread Yusif


Yusif  added the comment:

problem is 0x80070661

--

___
Python tracker 

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



[issue37991] What is this? What is problem?

2019-08-30 Thread Yusif


New submission from Yusif :

Windows 10
32-bit operating system,x64-based processor

--
components: Windows
files: Python 3.5.3 (64-bit)_20190831024317.log
messages: 350896
nosy: paul.moore, steve.dower, tim.golden, yusif, zach.ware
priority: normal
severity: normal
status: open
title: What is this? What is problem?
type: compile error
versions: Python 3.5
Added file: https://bugs.python.org/file48577/Python 3.5.3 
(64-bit)_20190831024317.log

___
Python tracker 

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



[issue29553] Argparser does not display closing parentheses in nested mutex groups

2019-08-30 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

The backport is done.

Can we close this now (and PR 120 which is still shown as open)?

--

___
Python tracker 

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



[issue29553] Argparser does not display closing parentheses in nested mutex groups

2019-08-30 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset bd8ca9aaccef0569c4b5c2e6dad0feb869ffd6c5 by Raymond Hettinger in 
branch '3.8':
[3.8] bpo-29553: Fix ArgumentParser.format_usage() for mutually exclusive 
groups (GH-14976) (GH-15494) (GH-15624)
https://github.com/python/cpython/commit/bd8ca9aaccef0569c4b5c2e6dad0feb869ffd6c5


--

___
Python tracker 

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



[issue29553] Argparser does not display closing parentheses in nested mutex groups

2019-08-30 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
pull_requests: +15292
stage: backport needed -> patch review
pull_request: https://github.com/python/cpython/pull/15624

___
Python tracker 

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



[issue37990] gc.collect prints debug stats incorrectly

2019-08-30 Thread Ned Deily


Ned Deily  added the comment:

Thanks for the report.  It looks like this regression was introduced by the 
changes for Issue37729.

--
assignee:  -> inada.naoki
keywords: +3.8regression
nosy: +inada.naoki, ned.deily
priority: normal -> high
stage:  -> needs patch
versions: +Python 3.8

___
Python tracker 

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



[issue37729] gc: stats from multi process are mixed up

2019-08-30 Thread Ned Deily


Ned Deily  added the comment:

See Issue37990 for a report of a regression introduced by these changes.

--
nosy: +ned.deily

___
Python tracker 

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



[issue29553] Argparser does not display closing parentheses in nested mutex groups

2019-08-30 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Okay, I'll do the backport.

--

___
Python tracker 

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



[issue37990] gc.collect prints debug stats incorrectly

2019-08-30 Thread Hubert Jasudowicz


Change by Hubert Jasudowicz :


--
type:  -> behavior

___
Python tracker 

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



[issue37990] gc.collect prints debug stats incorrectly

2019-08-30 Thread Hubert


New submission from Hubert :

Example:

Python 3.9.0a0 (heads/master:39d87b5471, Aug 30 2019, 23:19:13) 
[GCC 9.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gc
>>> gc.set_debug(gc.DEBUG_STATS)
>>> gc.collect()
gc: collecting generation 2...
gc: objects in each generation: 589 4120 0
gc: objects in permanent generation: 0
gc: done, 0 unreachable, 0 uncollectable, %.4fs elapsed
0

--
components: Interpreter Core
messages: 350890
nosy: chivay
priority: normal
severity: normal
status: open
title: gc.collect prints debug stats incorrectly
versions: Python 3.9

___
Python tracker 

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



[issue37705] winerror_to_errno implementation

2019-08-30 Thread Zackery Spytz


Zackery Spytz  added the comment:

I have created a pull request for this issue. Please take a look.

--
nosy: +ZackerySpytz
versions:  -Python 3.8

___
Python tracker 

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



[issue37705] winerror_to_errno implementation

2019-08-30 Thread Zackery Spytz


Change by Zackery Spytz :


--
keywords: +patch
pull_requests: +15291
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/15623

___
Python tracker 

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



[issue15999] Using new 'bool' format character

2019-08-30 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +15290
pull_request: https://github.com/python/cpython/pull/15622

___
Python tracker 

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



[issue15999] Using new 'bool' format character

2019-08-30 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +15289
pull_request: https://github.com/python/cpython/pull/15621

___
Python tracker 

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



[issue29553] Argparser does not display closing parentheses in nested mutex groups

2019-08-30 Thread Berker Peksag


Berker Peksag  added the comment:

da27d9b9dc44913ffee8f28d9638985eaaa03755 needs to be manually backported to 3.8.

--
stage: patch review -> backport needed
versions: +Python 3.8 -Python 2.7, Python 3.5

___
Python tracker 

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



[issue37939] os.path.normpath change some characters of a path into kinda 'hex number'

2019-08-30 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

3.5 (and 3.6) only gets security fixes.  From the report, the bug is fixed in 
3.7.

FWIW, I agree about the 9-bit octal thing.  There is another issue about this.

--
nosy: +terry.reedy
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



[issue36409] plistlib old API should be removed

2019-08-30 Thread Jon Janzen


Change by Jon Janzen :


--
pull_requests: +15288
pull_request: https://github.com/python/cpython/pull/15615

___
Python tracker 

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



[issue35737] crypt AuthenticationError introduced with new Linux kernel

2019-08-30 Thread Brett R


Brett R  added the comment:

I'm marking this closed. We're past the issue, and won't be providing any more 
details or chasing this further. Feel free to reopen if others want to push it. 
Thanks for the tips.

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



[issue37985] WFERR_UNMARSHALLABLE breaks recursion limit

2019-08-30 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It should be against master or the the newest version in which the problem 
exists. After merging this pull request the changes will be backported to older 
versions.

3.6 and 3.5 are open for security fixes only.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue37140] ctypes change made clang fail to build

2019-08-30 Thread STINNER Victor


STINNER Victor  added the comment:

Ok, the regression is now fixed. I close the issue.

Thanks Petr Viktorin for the bug report, Paul Monson for the fix proposed fix, 
and serge-sans-paille for your help on investigating this complex bug.

--
priority: release blocker -> 
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



[issue37961] Tracemalloc traces do not include original stack trace length

2019-08-30 Thread STINNER Victor


STINNER Victor  added the comment:

With the following change, traceback_t size changes from 24 bytes to 32 bytes:

diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c
index ee32ac29b7..8a820db907 100644
--- a/Modules/_tracemalloc.c
+++ b/Modules/_tracemalloc.c
@@ -79,6 +79,7 @@ __attribute__((packed))
 typedef struct {
 Py_uhash_t hash;
 int nframe;
+int length;
 frame_t frames[1];
 } traceback_t;
 
@@ -1640,6 +1641,8 @@ PyInit__tracemalloc(void)
 if (tracemalloc_init() < 0)
 return NULL;
 
+printf("sizeof(traceback_t) = %zu bytes\n", sizeof(traceback_t));
+
 return m;
 }


The following structure size is 24 bytes, so no change:

typedef struct {
Py_uhash_t hash;
short nframe;
short length;
frame_t frames[1];
} traceback_t;

The short approach is promising :-)

--

___
Python tracker 

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



[issue37918] What about an enum for open() modes?

2019-08-30 Thread Marco Sulla


Marco Sulla  added the comment:

@vstinner Note that I wrote about os.fdopen(), not os.open().

--

___
Python tracker 

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



[issue37918] What about an enum for open() modes?

2019-08-30 Thread Marco Sulla


Marco Sulla  added the comment:

Well, I'll discuss it in python-ideas. Let me do the testament before... :D

@serhiy.storchaka thank you for the StrEnum tip, but no PyPi package please. It 
has no sense to add an addional package only for having an enum that should be 
built-in as in all other languages.

And at most I'll do it myself, thank you ;)

--

___
Python tracker 

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



[issue37986] Improve perfomance of PyLong_FromDouble()

2019-08-30 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +mark.dickinson

___
Python tracker 

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



[issue37944] Adjacent escape character in json.load()

2019-08-30 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

There is no a bug.

"\\\"" is the same as r"\\" -- a 2-charackter string consisting of a backslash 
character and a doublequote character. r"\\\"" is a different string, it 
contains 3 backslash characters.

>>> print("\\\"")
\"
>>> print(repr("\\\""))
'\\"'

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue37918] What about an enum for open() modes?

2019-08-30 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

No modification of open() is needed. Just make your enum class a subclass of 
str.

This idea does not look particularly attractive to me, but you can create a 
package on PyPi with your OpenMode class and test how popular it will be.

--
nosy: +serhiy.storchaka
resolution:  -> rejected
status: open -> closed

___
Python tracker 

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



[issue37980] regression when passing numpy bools to sorted(..., reverse=r)

2019-08-30 Thread Sebastian Berg


Sebastian Berg  added the comment:

I applaud the stricter rules in general, as Mark noted nicely, the issue is 
that `__index__` is maybe a strange way to achieve that for bools (it is not 
like `123` is a clean bool)? `__nonzero__` coerces to bools, there is no 
`__bool__` to convert to bool safely.

Basically: this seems to force numpy to back down from saying that 
`list[np.True_]` will be invalid in the future. (And we cannot just get rid of 
our bools unfortunately).

--

___
Python tracker 

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



[issue37140] ctypes change made clang fail to build

2019-08-30 Thread miss-islington


miss-islington  added the comment:


New changeset 17f61ed25a856ed673ad6f2e9782c3d5e556f151 by Miss Islington (bot) 
in branch '3.8':
bpo-37140: Fix StructUnionType_paramfunc() (GH-15612)
https://github.com/python/cpython/commit/17f61ed25a856ed673ad6f2e9782c3d5e556f151


--
nosy: +miss-islington

___
Python tracker 

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



[issue37961] Tracemalloc traces do not include original stack trace length

2019-08-30 Thread Julien Danjou


Julien Danjou  added the comment:

> In fact, I didn't check: maybe traceback_t size is not change by your PR, 
> because of memory aligment and padding.

It is changed. The current size is should be determined by sizeof(Py_uhash_t + 
int + int) which is 4 + 4 + 4, so 12 aligned/padded.

Using a short will add 2 bytes and potentially some space for 2 more bytes in 
the future. :)

--

___
Python tracker 

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



[issue37140] ctypes change made clang fail to build

2019-08-30 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15287
pull_request: https://github.com/python/cpython/pull/15613

___
Python tracker 

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



[issue37140] ctypes change made clang fail to build

2019-08-30 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 96b4087ce784ee7434dffdf69c475f5b40543982 by Victor Stinner in 
branch 'master':
bpo-37140: Fix StructUnionType_paramfunc() (GH-15612)
https://github.com/python/cpython/commit/96b4087ce784ee7434dffdf69c475f5b40543982


--

___
Python tracker 

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



[issue37980] regression when passing numpy bools to sorted(..., reverse=r)

2019-08-30 Thread Mark Dickinson


Mark Dickinson  added the comment:

Victor

> The purpose of the DeprecationWarning is to give time to numpy developers to 
> update the bool_() type, before it becomes an error.

No, that's not what's happening: currently, np.bool_ *does* support __index__. 
In the future, it won't. The NumPy developers are deliberately removing 
__index__ from np.bool_, for reasons described in the relevant NumPy issues. 
The DeprecationWarning is coming from NumPy, not Python. See 
https://github.com/numpy/numpy/pull/9685

--

___
Python tracker 

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



[issue37988] Issue found during language name processing in a list

2019-08-30 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

It may help if you read this:

http://sscce.org/

It is written for Java programmers but it applies to Python as well.

Don't expect us to re-type your code from a hard-to-read, out-of-focus, 
low-resolution photo of your monitor. Copy and paste the code into a .py file 
and attach that to this issue.

Don't expect us to guess what the error is. Copy and paste the entire 
traceback, if there is one. If there is no traceback, explain why you think 
there is an error:

- what data did you use?
- what results did you expect?
- what results did you get?
- what reason do you have for saying that it is a bug in Python rather than a 
bug in your own code?

--
nosy: +steven.daprano

___
Python tracker 

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



[issue37988] Issue found during language name processing in a list

2019-08-30 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Can you please attach the code snippet as text instead of screenshot so that it 
would be helpful to copy paste and run. In the issue please add a description 
of what's the output you are expecting and what's the actual output?

Thanks

--
nosy: +xtreak

___
Python tracker 

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



[issue37987] retrun collection item in for cycle with finally continue

2019-08-30 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Thank you for your report, but this has been fixed in issue37830. Try 3.8.0b4!

--
resolution:  -> out of date
stage:  -> resolved
status: open -> closed
superseder:  -> continue and break in finally with return in try results with 
segfault

___
Python tracker 

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



[issue37980] regression when passing numpy bools to sorted(..., reverse=r)

2019-08-30 Thread STINNER Victor


STINNER Victor  added the comment:

> DeprecationWarning: In future, it will be an error for 'np.bool_' scalars to 
> be interpreted as an index

That sounds like an issue in numpy: np.bool_ should define the __index__() 
method, no?

$ python3
Python 3.7.4 (default, Jul  9 2019, 16:32:37) 
>>> import numpy
>>> b=numpy.bool_(True)
>>> b.__int__()
1
>>> b.__index__()
__main__:1: DeprecationWarning: In future, it will be an error for 'np.bool_' 
scalars to be interpreted as an index
1

The purpose of the DeprecationWarning is to give time to numpy developers to 
update the bool_() type, before it becomes an error.

I'm not sure of the purpose of this issue, is it just to notice core developers 
that numpy should be updated? Or do you consider that type.__index__() must 
continue to fallback on type.__int__() if __index__() is not defined?

In the past, Python was tolerant in term of accepted types. It was hidding some 
bugs sometimes. We would like to make Python more strict to reduce the risk of 
bugs. Sadly, it requires to modify your Python code. It's like bytes/str which 
was strictly separeted in Python 3.0, except that here there is longer and 
smoother transition period :-)

--

___
Python tracker 

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



[issue37988] Issue found during language name processing in a list

2019-08-30 Thread SYAM PARAKASH,AJAY KUMAR


New submission from SYAM PARAKASH,AJAY KUMAR :

I found an error in processing language name like Malayalam,English.. in a list 
created using Python 3.6.1

--
files: IMG_20190830_162306__1567162571_88362.jpg
messages: 350869
nosy: AjaySyam
priority: normal
severity: normal
status: open
title: Issue found during language name processing in a list
type: behavior
Added file: 
https://bugs.python.org/file48576/IMG_20190830_162306__1567162571_88362.jpg

___
Python tracker 

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



[issue37987] retrun collection item in for cycle with finally continue

2019-08-30 Thread Иван Косматых

New submission from Иван Косматых :

https://bugs.python.org/issue32489
This closed issue allow continue in finally clasue but now it can lead to crash 
in below case.

def crash():
for i in [1, 2, 3]:
try:
return i
finally:
continue


crash()

I try use Python 3.8.0b3 (default, Aug  1 2019, 21:20:41) on ubuntu Linux 
4.15.0-55-generic #60~16.04.2-Ubuntu SMP Thu Jul 4 09:03:09 UTC 2019 x86_64 
x86_64 x86_64 GNU/Linux

--
components: Interpreter Core
messages: 350867
nosy: serhiy.storchaka, Иван Косматых
priority: normal
severity: normal
status: open
title: retrun collection item in for cycle with finally continue
type: crash
versions: Python 3.8

___
Python tracker 

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



[issue37918] What about an enum for open() modes?

2019-08-30 Thread STINNER Victor


STINNER Victor  added the comment:

The open() function is very commonly used, so modifying it requires a lot of 
discussion. In Python, we prefer to discuss such changes ("feature request" if 
you want) on python-ideas, rather than on the bug tracker, to get more reviews 
and feedback.

open() modes and os.open() modes are very different. IMHO it's ok and simple to 
add enums for os.open() modes, but I'm not sure about open() modes which are 
strings. I don't think that enum supports mode1 | mode1 if mode values are 
strings. Moreover, for backward compatibility, enums should behaves a the str 
type. I don't think that it's possible neither, whereas IntEnum would fit 
nicely for os.open() modes (integers).

Usability and backward compatibility deserves a long discussion.

Note: there is python-ideas mailing and the Ideas category of 
discuss.python.org. I'm not sure which one is preferred.

https://mail.python.org/mailman3/lists/python-ideas.python.org/
https://discuss.python.org/c/ideas

--

___
Python tracker 

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



[issue37961] Tracemalloc traces do not include original stack trace length

2019-08-30 Thread STINNER Victor


STINNER Victor  added the comment:

I'm fine with limiting MAX_NFRAME to USHRT_MAX and change traceback_t.nframe 
type to unsigned short (16 bits). Storing 65536 should be way enough. It would 
be great if you manage to add your new field without making traceback_t larger.

In fact, I didn't check: maybe traceback_t size is not change by your PR, 
because of memory aligment and padding.

By the way, first I taught that your modified trace_t: no, you modified 
traceback_t. _tracemalloc ensures that a traceback_t instance is allocated 
exactly once in the heap memory, to reduce the memory footprint. So making 
traceback_t larger should impact less the memory than making trace_t larger.

--

___
Python tracker 

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



[issue37140] ctypes change made clang fail to build

2019-08-30 Thread STINNER Victor


STINNER Victor  added the comment:

Ok, it took me a while to understand the subtle ctypes internals. 
serge-sans-paille and me read the C code and run a debugger (gdb) on it to 
undertand how passing a structure by copy work in ctypes.

The root function is StructUnionType_paramfunc(): it copies the structure if 
it's larger than sizeof(void*) bytes.

StructUnionType_paramfunc() creates a new internal object which is stored into 
parg->obj. The only purpose of this object is to release the memory copy 
allocated by PyMem_Malloc().

This issue is a problem with the internal object: if the struture has a 
finalizer, the finalizer is called twice. First, it is called on the internal 
object which is more and less a full copy of the structure. Second, it is 
called on the structure (once the last reference to the structure is removed).

The code behaves as if the the finalizer is called twice. Even if it's two 
separated Python object, in fact the two objects contain the same structure 
values. For example, if the structure contains a pointer to memory block and 
the finalizer calls free(ptr): free(ptr) will be called twice with the same ptr 
value.

This surprising behavior comes from this code:

void *new_ptr = PyMem_Malloc(self->b_size);
if (new_ptr == NULL)
return NULL;
memcpy(new_ptr, self->b_ptr, self->b_size);
copied_self = (CDataObject *)PyCData_AtAddress(
(PyObject *)Py_TYPE(self), new_ptr);
copied_self->b_needsfree = 1;

copied_self reuses the exact same type of the structure. If the structure has a 
finalizer defined in Python, it will be called.

copied_self finalized is called at the "cleanup:" label of  _ctypes_callproc():

for (i = 0; i < argcount; ++i)
Py_XDECREF(args[i].keep);

--

Trying to duplicate self isn't needed. All we need is to call PyMem_Free(ptr) 
at the _ctypes_callproc() exit.

My PR 15612 introduces a new internal StructParam_Type type which has exactly 
one purpose: call PyMem_Free(ptr) in its deallocator. The type has no finalizer.

--

___
Python tracker 

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



[issue37944] Adjacent escape character in json.load()

2019-08-30 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue37140] ctypes change made clang fail to build

2019-08-30 Thread STINNER Victor


Change by STINNER Victor :


Added file: https://bugs.python.org/file48575/point.py

___
Python tracker 

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



[issue37140] ctypes change made clang fail to build

2019-08-30 Thread STINNER Victor


STINNER Victor  added the comment:

I was surprised by the following test in StructUnionType_paramfunc():

if ((size_t)self->b_size > sizeof(void*)) {
   ... copy the structure ...
} else {
   ... pass by reference (?) ...
}

So I wrote a simple C library with the structure: typedef struct Point { int x; 
int y; } and functions modifying this structure, structured passed by copy or 
structure passed by reference.

I'm surprised: ctypes works as expected :-)

Try attached point.c and point.py:

$ gcc -c point.c -fpic && gcc -shared -o libpoint.so point.o && python3 point.py
p = 
p = 
p = 
ok
sizeof(Point) = 16 bytes

Modify CoordType in point.c and point.py to test different sizes, on x86-64, I 
get:

* c_byte: 2 bytes
* c_short: 4 bytes
* c_int: 8 bytes
* c_long: 16 bytes

--
keywords: +3.8regression
versions: +Python 3.9
Added file: https://bugs.python.org/file48574/point.c

___
Python tracker 

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



[issue37140] ctypes change made clang fail to build

2019-08-30 Thread STINNER Victor


STINNER Victor  added the comment:

It's a Python 3.8 regression, so I mark it as a release blocker.

--
nosy: +lukasz.langa
priority: normal -> release blocker

___
Python tracker 

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



[issue37140] ctypes change made clang fail to build

2019-08-30 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +15286
pull_request: https://github.com/python/cpython/pull/15612

___
Python tracker 

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



[issue37834] readlink on Windows cannot read app exec links

2019-08-30 Thread Łukasz Langa

Change by Łukasz Langa :


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



[issue37986] Improve perfomance of PyLong_FromDouble()

2019-08-30 Thread Sergey Fedoseev


New submission from Sergey Fedoseev :

This patch simplifies fast path for floats that fit into C long and moves it 
from float.__trunc__ to PyLong_FromDouble().

+-+-+--+
| Benchmark   | long-from-float-ref | long-from-float  |
+=+=+==+
| int(1.) | 39.5 ns | 37.3 ns: 1.06x faster (-6%)  |
+-+-+--+
| int(2.**20) | 46.4 ns | 45.6 ns: 1.02x faster (-2%)  |
+-+-+--+
| int(2.**30) | 52.5 ns | 49.0 ns: 1.07x faster (-7%)  |
+-+-+--+
| int(2.**60) | 50.0 ns | 49.2 ns: 1.02x faster (-2%)  |
+-+-+--+
| int(-2.**63)| 76.6 ns | 48.6 ns: 1.58x faster (-37%) |
+-+-+--+
| int(2.**80) | 77.1 ns | 72.5 ns: 1.06x faster (-6%)  |
+-+-+--+
| int(2.**120)| 91.5 ns | 87.7 ns: 1.04x faster (-4%)  |
+-+-+--+
| math.ceil(1.)   | 57.4 ns | 32.9 ns: 1.74x faster (-43%) |
+-+-+--+
| math.ceil(2.**20)   | 60.5 ns | 41.3 ns: 1.47x faster (-32%) |
+-+-+--+
| math.ceil(2.**30)   | 64.2 ns | 43.9 ns: 1.46x faster (-32%) |
+-+-+--+
| math.ceil(2.**60)   | 66.3 ns | 42.3 ns: 1.57x faster (-36%) |
+-+-+--+
| math.ceil(-2.**63)  | 67.7 ns | 43.1 ns: 1.57x faster (-36%) |
+-+-+--+
| math.ceil(2.**80)   | 66.6 ns | 65.6 ns: 1.01x faster (-1%)  |
+-+-+--+
| math.ceil(2.**120)  | 79.9 ns | 80.5 ns: 1.01x slower (+1%)  |
+-+-+--+
| math.floor(1.)  | 58.4 ns | 31.2 ns: 1.87x faster (-47%) |
+-+-+--+
| math.floor(2.**20)  | 61.0 ns | 39.6 ns: 1.54x faster (-35%) |
+-+-+--+
| math.floor(2.**30)  | 64.2 ns | 43.9 ns: 1.46x faster (-32%) |
+-+-+--+
| math.floor(2.**60)  | 62.1 ns | 40.1 ns: 1.55x faster (-35%) |
+-+-+--+
| math.floor(-2.**63) | 64.1 ns | 39.9 ns: 1.61x faster (-38%) |
+-+-+--+
| math.floor(2.**80)  | 62.2 ns | 62.7 ns: 1.01x slower (+1%)  |
+-+-+--+
| math.floor(2.**120) | 77.0 ns | 77.8 ns: 1.01x slower (+1%)  |
+-+-+--+

I'm going to speed-up conversion of larger floats in a follow-up PR.

--
components: Interpreter Core
files: bench-long-from-float.py
messages: 350861
nosy: sir-sigurd
priority: normal
pull_requests: 15285
severity: normal
status: open
title: Improve perfomance of PyLong_FromDouble()
type: performance
versions: Python 3.9
Added file: https://bugs.python.org/file48573/bench-long-from-float.py

___
Python tracker 

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



[issue37980] regression when passing numpy bools to sorted(..., reverse=r)

2019-08-30 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

See more general issue issue15999.

--

___
Python tracker 

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



[issue15999] Using new 'bool' format character

2019-08-30 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +15284
pull_request: https://github.com/python/cpython/pull/15610

___
Python tracker 

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



[issue15999] Using new 'bool' format character

2019-08-30 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +15283
pull_request: https://github.com/python/cpython/pull/15609

___
Python tracker 

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



[issue37968] Add a turtle module function to draw a circle centered at the turtle

2019-08-30 Thread Yehuda Katz


Yehuda Katz  added the comment:

Eric, thank you, I'm sorry.
Yehuda

On Thu, Aug 29, 2019 at 11:47 PM Eric V. Smith 
wrote:

>
> Eric V. Smith  added the comment:
>
> It's turtle.circle:
>
> https://docs.python.org/3.5/library/turtle.html#turtle.circle
>
> @Yehuda: this isn't the appropriate place for help on how the turtle
> module works. Please consider the python-tutor list. See
> https://mail.python.org/mailman/listinfo/tutor
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue37980] regression when passing numpy bools to sorted(..., reverse=r)

2019-08-30 Thread Mark Dickinson


Mark Dickinson  added the comment:

Since this particular issue is about "sort", I'm adding Tim and Raymond to the 
nosy list.

--
nosy: +rhettinger, tim.peters

___
Python tracker 

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



[issue37980] regression when passing numpy bools to sorted(..., reverse=r)

2019-08-30 Thread Mark Dickinson


Mark Dickinson  added the comment:

Yes, I think there's a lot of history here that obscures the picture.

We have mechanisms in Python to allow 3rd party objects to be interpreted as 
floats (via __float__) or as integers (via __index__). 

So np.int64 (for example) doesn't subclass int (on Python 3), but is usable as 
an integer almost everywhere that that makes sense because it defines __index__ 
(and __int__, but it's __index__ that really matters here).

If you're writing something bool-like in a 3rd party library, and you want it 
to be duck-typeable as a boolean in calls that expect a boolean flag, what 
special method should you implement? It seems clear to me that the answer 
should be __bool__, but the current error message appears to be telling the 
NumPy folks that if they want this to work then np.bool_ should (continue to) 
implement __index__. That feels odd to me: it's a completely legitimate and 
sensible choice on NumPy's part to decide that np.bool_ objects *aren't* 
integers, and shouldn't implement __index__.

The NumPy bug report demonstrates that the concern isn't hypothetical: np.bool_ 
really *is* a boolean type, and it's easy and natural for a NumPy user to end 
up passing an np.bool_ instance instead of a bool instance where a flag is 
expected, and then rather surprising when that doesn't work as expected. I've 
run into this myself on occasion (turns out that PyQt doesn't like np.bool_ 
objects either, but that's another story).

The one disadvantage that I can see of allowing arbitrary objects to be used as 
flags is the potential for surprising failure modes when a function is 
accidentally misused. For example, it could be surprising if something like:

> "aaaXbbbXccc".splitlines("X")

returned ["aaaXbbbXccc"] instead of raising as it currently does. But many 
flags are keyword-only, which would make it harder to run into this sort of 
thing accidentally.
 
In short, I think this particular case _is_ a bug that should be fixed.

--

___
Python tracker 

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



[issue18943] argparse: default args in mutually exclusive groups

2019-08-30 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
pull_requests:  -5593

___
Python tracker 

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



[issue9625] argparse: Problem with defaults for variable nargs when using choices

2019-08-30 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
priority: high -> normal
versions: +Python 3.9 -Python 2.7, Python 3.5, Python 3.6

___
Python tracker 

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



[issue37976] zip() shadows TypeError raised in __iter__() of source iterable

2019-08-30 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 27f418640cf39c035114f29cc2d628775b43c0f9 by Raymond Hettinger 
(Miss Islington (bot)) in branch '3.8':
bpo-37976: Prevent shadowing of TypeError in zip() (GH-15592) (GH-15608)
https://github.com/python/cpython/commit/27f418640cf39c035114f29cc2d628775b43c0f9


--

___
Python tracker 

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



[issue25061] Add native enum support for argparse

2019-08-30 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Even with the proposed converter class, I don't see a straight-forward way to 
meet the OP's goal of just specifying type=EnumConverter(MyEnum)
to get all of:

* display all possible values in help
* display them in lowercase
* accept them in lowercase
* and convert them back to the correct case before casting to Enum 
* interact meaningfully with "default"
* and not interact badly with "choices"

--
resolution:  -> rejected
stage:  -> resolved
status: open -> closed
versions: +Python 3.9

___
Python tracker 

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



[issue10190] Can argparse._AttributeHolder._get_kwargs become a public API?

2019-08-30 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Marking this as out-of-date.  It seems that the desired functionality has 
already been added in types.SimpleNamespace:

# Capabilities of _AttributeHolder
>>> ah = _AttributeHolder()
>>> ah
AttributeHolder()
>>> ah.raymond='Red'
>>> ah
AttributeHolder(raymond='Red')
>>> ah.raymond
'Red'
>>> ah.rachel='blue'
>>> ah
AttributeHolder(rachel='blue', raymond='Red')
>>> ah._get_kwargs()
[('rachel', 'blue'), ('raymond', 'Red')]

# Capabilities of SimpleNamespace
>>> import types
>>> ah = types.SimpleNamespace()
>>> ah.raymond='Red'
>>> ah
namespace(raymond='Red')
>>> ah.rachel='blue'
>>> ah
namespace(rachel='blue', raymond='Red')
>>> vars(ah).items()
dict_items([('raymond', 'Red'), ('rachel', 'blue')])

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



[issue25061] Add native enum support for argparse

2019-08-30 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Depending on how you want to expose enums to end-users, some reasonable options 
already exist:

import argparse
from enum import Enum

class Shake(Enum):
VANILLA = 7
CHOCOLATE = 4
COOKIES = 9
MINT = 3

# Option 1
ap = argparse.ArgumentParser()
ap.add_argument('shakes', nargs=2, choices=Shake, type=Shake.__getitem__)
ns = ap.parse_args(['VANILLA', 'MINT'])
print(ns)

# Option 2
ap = argparse.ArgumentParser()
ap.add_argument('shakes', nargs=2, choices=Shake.__members__)
ns = ap.parse_args(['VANILLA', 'MINT'])
ns.shakes = [Shake[name] for name in ns.shakes]
print(ns)

In Option 1, the user sees choices of:
{Shake.VANILLA,Shake.CHOCOLATE,Shake.COOKIES,Shake.MINT}

In Option 2, the user sees choices of:
{VANILLA,CHOCOLATE,COOKIES,MINT}

--

___
Python tracker 

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