[issue38085] Interrupting class creation in __init_subclass__ may lead to incorrect isinstance() and issubclass() results

2020-12-25 Thread xitop


xitop  added the comment:

Python 3.9.1 is affected too.

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



[issue42737] PEP 563: drop annotations for complex assign targets

2020-12-25 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
keywords: +patch
pull_requests: +22799
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/23952

___
Python tracker 

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



[issue42748] test_asdl_parser: load_module() method is deprecated

2020-12-25 Thread Batuhan Taskaya


New submission from Batuhan Taskaya :

Running test_asdl_parser raises a deprecation warning:
0:00:26 load avg: 1.05 [ 23/426] test_asdl_parser
:283: DeprecationWarning: the load_module() method 
is deprecated and slated for removal in Python 3.12; use exec_module() instead

probably related with this line:
https://github.com/python/cpython/blob/ea251806b8d11b30d2182af1e589caf88acf/Lib/test/test_asdl_parser.py#L29

--
messages: 383795
nosy: BTaskaya
priority: normal
severity: normal
status: open
title: test_asdl_parser: load_module() method is deprecated

___
Python tracker 

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



[issue42687] tokenize module does not recognize Barry as FLUFL

2020-12-25 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

I concur with Terry.

--
nosy: +BTaskaya

___
Python tracker 

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



[issue16396] Importing ctypes.wintypes on Linux gives a ValueError instead of an ImportError

2020-12-25 Thread Shantanu


Change by Shantanu :


--
nosy: +hauntsaninja
nosy_count: 12.0 -> 13.0
pull_requests: +22798
pull_request: https://github.com/python/cpython/pull/23951

___
Python tracker 

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



[issue42733] io's r+ mode truncate(0)

2020-12-25 Thread Steven D'Aprano

Steven D'Aprano  added the comment:

On Sat, Dec 26, 2020 at 02:19:55AM +, Terry J. Reedy wrote:

> "Enhancements" (non-bugfix feature changes) can only be applied to 
> future versions.  However, you are asking for the reversion of an 
> intentional feature change made in a 'bugfix' release# for (I believe) 
> 3.1.  Before the change, as I remember, truncating to 0 *did* move the 
> file pointer back to 0.  As I remember, Guide von Rossum requested the 
> change and Antoine Pitrou made it.

Thanks for that insight Terry. I think the current behaviour is correct. 
Sparse files can have holes in them, and non-sparse files have to be 
filled with NUL bytes, so this has to work:

f.truncate(0)
f.seek(10)
f.write('x')
# File is now ten NUL bytes and a single 'x'

If you swap the order of the truncate and the seek, the behaviour 
shouldn't change: truncate is documented as not moving the file 
position, so changing this will be backwards incompatible and will 
probably break a lot of code that expects the current behaviour.

https://docs.python.org/3/library/io.html#io.IOBase.truncate

I agree with Terry rejecting this feature request. If 施文峰 (Shīwén 
Fēng according to Google translate) wishes to disagree, this will have 
to be discussed on the Python-Ideas mailing list first.

--
title: [issue] io's r+ mode truncate(0) -> io's r+ mode truncate(0)

___
Python tracker 

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



[issue42735] "trace_at_recursion_limit.py" should be removed from "Python/Lib/test/crashers"

2020-12-25 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
nosy: +serhiy.storchaka
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



[issue42733] [issue] io's r+ mode truncate(0)

2020-12-25 Thread Steven D'Aprano

Steven D'Aprano  added the comment:

On Fri, Dec 25, 2020 at 01:31:51PM +, 施文峰 wrote:

> first test have a problem,you didn’t use r+ mode

I did, I copied your `test()` function exactly, however I did make a 
mistake. I tried again with this:

>>> with open(FILE_PATH, 'r') as f:
... print(repr(f.read()))
... 
'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00{"how_dare_you":
 
"how_dare_you"}'

so you are correct, the file is padded with NUL characters.

Here is a simpler demonstration of the behaviour.

```
FILE_PATH = 'example.data'

# create a file
with open(FILE_PATH, 'w') as f:
f.write('abc\n')

# Truncate using r+ mode.
with open(FILE_PATH, 'r+') as f:
assert f.tell() == 0
assert f.read() == 'abc\n'
assert f.tell() == 4  # File position is now at end of file.
f.truncate(0)
assert f.tell() == 4  # File position has not changed.
assert f.read() == ''  # Nothing remaining to read.
f.write('xyz\n')
f.flush()
assert f.tell() == 8
assert f.read() == ''  # Nothing remaining to read.
# Return the file position to start of file.
f.seek(0)
assert f.read() == '\0\0\0\0xyz\n'

```

All the assertions pass.

I think this is standard and correct behaviour. Do you have examples of 
other programming languages that behave differently? PHP seems to do the 
same thing:

https://www.php.net/manual/en/function.ftruncate.php

--
title: io's r+ mode truncate(0) -> [issue] io's r+ mode truncate(0)

___
Python tracker 

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



[issue42733] io's r+ mode truncate(0)

2020-12-25 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

"Enhancements" (non-bugfix feature changes) can only be applied to future 
versions.  However, you are asking for the reversion of an intentional feature 
change made in a 'bugfix' release# for (I believe) 3.1.  Before the change, as 
I remember, truncating to 0 *did* move the file pointer back to 0.  As I 
remember, Guide von Rossum requested the change and Antoine Pitrou made it.  

https://docs.python.org/3/library/io.html#io.IOBase.seek
new says "The current stream position isn’t changed."

If you also want to change the stream position, do it with seek(), perhaps 
before the truncate.

# This change in a bugfix release, a violation the rule stated above, broke the 
code of multiple people.  (We thereafter strengthened the  policy.)  To fix my 
code, I had to add a seek(0).  I put it before truncate(0), so I know that this 
works.

--
nosy: +terry.reedy
resolution:  -> rejected
stage:  -> resolved
status: open -> closed
title: [issue] io's r+ mode truncate(0) -> io's r+ mode truncate(0)
versions: +Python 3.10 -Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue40521] [subinterpreters] Make free lists and unicode caches per-interpreter

2020-12-25 Thread STINNER Victor


STINNER Victor  added the comment:

> bpo-40521: Per-interpreter interned strings (GH-20085)

That one wasn't easy, but it's now done! I close the issue.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.10 -Python 3.9

___
Python tracker 

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



[issue40521] [subinterpreters] Make free lists and unicode caches per-interpreter

2020-12-25 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset ea251806b8d11b30d2182af1e589caf88acf by Victor Stinner in 
branch 'master':
bpo-40521: Per-interpreter interned strings (GH-20085)
https://github.com/python/cpython/commit/ea251806b8d11b30d2182af1e589caf88acf


--

___
Python tracker 

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



[issue42713] Segmentation fault in running eval() with large expression size.

2020-12-25 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Segmentation fault in running ast.literal_eval() with large 
expression size.

___
Python tracker 

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



[issue42714] Segmentation fault in running compile() with large expression size.

2020-12-25 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Segmentation fault in running ast.literal_eval() with large 
expression size.

___
Python tracker 

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



[issue42715] Segmentation fault in running exec() with large expression size.

2020-12-25 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Segmentation fault in running ast.literal_eval() with large 
expression size.

___
Python tracker 

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



[issue42716] Segmentation fault in running ast.parse() with large expression size.

2020-12-25 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Segmentation fault in running ast.literal_eval() with large 
expression size.

___
Python tracker 

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



[issue42257] platform.libc_ver() doesn't consider in case of executable is empty string

2020-12-25 Thread Ned Deily


Change by Ned Deily :


--
nosy: +lemburg

___
Python tracker 

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



[issue42694] Failed test_new_curses_panel in test_curses

2020-12-25 Thread STINNER Victor


Change by STINNER Victor :


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



[issue42694] Failed test_new_curses_panel in test_curses

2020-12-25 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 993e88cf08994f7c1e0f9f62fda4ed32634ee2ad by Victor Stinner in 
branch 'master':
bpo-42694: Prevent creating _curses_panel.panel (GH-23948)
https://github.com/python/cpython/commit/993e88cf08994f7c1e0f9f62fda4ed32634ee2ad


--

___
Python tracker 

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



[issue42687] tokenize module does not recognize Barry as FLUFL

2020-12-25 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I strongly disagree.  '<>' is not a legal operator any more.  It is a 
parse-time syntax error.  Whatever historical artifact is left in the CPython 
tokenizer, recognizing '<>' is not exposed to Python code.

>>> p = ast.parse('a <> b')
Traceback (most recent call last):
...
a <> b
^
SyntaxError: invalid syntax  

When '<>' was legal, we may presume that tokenizer recognized it, so that not 
recognizing it was an intentional change.  Reverting this would be a 
dis-service to users.  

I think that the PR and this issue should be closed.  If the historical 
artifact bothers you, propose removing it instead on introducing a bug into 
tokenizer.

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



[issue42745] [subinterpreters] Make the type attribute lookup cache per-interpreter

2020-12-25 Thread STINNER Victor


Change by STINNER Victor :


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



[issue42745] [subinterpreters] Make the type attribute lookup cache per-interpreter

2020-12-25 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 41010184880151d6ae02a226dbacc796e5c90d11 by Victor Stinner in 
branch 'master':
bpo-42745: Make the type cache per-interpreter (GH-23947)
https://github.com/python/cpython/commit/41010184880151d6ae02a226dbacc796e5c90d11


--

___
Python tracker 

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



[issue42694] Failed test_new_curses_panel in test_curses

2020-12-25 Thread mohamed koubaa


Change by mohamed koubaa :


--
nosy: +koubaa
nosy_count: 2.0 -> 3.0
pull_requests: +22797
pull_request: https://github.com/python/cpython/pull/21986

___
Python tracker 

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



[issue1635741] Py_Finalize() doesn't clear all Python objects at exit

2020-12-25 Thread STINNER Victor


STINNER Victor  added the comment:

> These changes introduced a regression in test_curses (see issue42694). And I 
> afraid then introduced regressions in other modules for which there were not 
> purposed tests.

In my experience, when a type is modified to prevent creating an instance using 
type(), there is a test for that. The issue with bpo-42694 is that test_curses 
is skipped by default, and it might be skipped on buildbots which don't have 
curses.

(I wrote a fix for bpo-42694, but let's discuss it there.)

--

___
Python tracker 

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



[issue42694] Failed test_new_curses_panel in test_curses

2020-12-25 Thread STINNER Victor


STINNER Victor  added the comment:

I can reproduce the issue with the command:

./python -m test -u all test_curses

I wrote PR 23948 to fix the regression.

Note: "./python -m test test_curses" doesn't fail since the test is skipped.

--

___
Python tracker 

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



[issue42694] Failed test_new_curses_panel in test_curses

2020-12-25 Thread STINNER Victor


Change by STINNER Victor :


--
keywords: +patch
pull_requests: +22796
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/23948

___
Python tracker 

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



[issue39465] [subinterpreters] Design a subinterpreter friendly alternative to _Py_IDENTIFIER

2020-12-25 Thread STINNER Victor


STINNER Victor  added the comment:

Ok, it should now be fixed. I close the issue.

See PR 20085 "Per-interpreter interned strings" of bpo-40521 for the follow-up.

--

___
Python tracker 

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



[issue39465] [subinterpreters] Design a subinterpreter friendly alternative to _Py_IDENTIFIER

2020-12-25 Thread STINNER Victor


Change by STINNER Victor :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.10

___
Python tracker 

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



[issue42747] Remove Py_TPFLAGS_HAVE_VERSION_TAG flag?

2020-12-25 Thread STINNER Victor


New submission from STINNER Victor :

Since the PyTypeObject structure is excluded from the limited C API and the 
stable ABI on purpose (PEP 384), I don't see the purpose of the 
Py_TPFLAGS_HAVE_VERSION_TAG flag.

Moreover, a new flag was added recently:

#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A
/* Type has am_send entry in tp_as_async slot */
#define Py_TPFLAGS_HAVE_AM_SEND (1UL << 21)
#endif

Should it be also removed?


For example, Py_TPFLAGS_HAVE_FINALIZE was deprecated in bpo-32388 by:

commit ada319bb6d0ebcc68d3e0ef2b4279ea061877ac8
Author: Antoine Pitrou 
Date:   Wed May 29 22:12:38 2019 +0200

bpo-32388: Remove cross-version binary compatibility requirement in 
tp_flags (GH-4944)

It is now allowed to add new fields at the end of the PyTypeObject struct 
without having to allocate a dedicated compatibility flag i
n tp_flags.

This will reduce the risk of running out of bits in the 32-bit tp_flags 
value.


By the way, is it worth it to remove Py_TPFLAGS_HAVE_FINALIZE? Or is it going 
to break too many extension modules?

--
components: C API
messages: 383782
nosy: petr.viktorin, pitrou, vstinner
priority: normal
severity: normal
status: open
title: Remove Py_TPFLAGS_HAVE_VERSION_TAG flag?
versions: Python 3.10

___
Python tracker 

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



[issue39465] [subinterpreters] Design a subinterpreter friendly alternative to _Py_IDENTIFIER

2020-12-25 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset ba3d67c2fb04a7842741b1b6da5d67f22c579f33 by Victor Stinner in 
branch 'master':
bpo-39465: Fix _PyUnicode_FromId() for subinterpreters (GH-20058)
https://github.com/python/cpython/commit/ba3d67c2fb04a7842741b1b6da5d67f22c579f33


--

___
Python tracker 

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



[issue40512] [subinterpreters] Meta issue: per-interpreter GIL

2020-12-25 Thread STINNER Victor


STINNER Victor  added the comment:

> Type method cache is shared.

I created bpo-42745: "[subinterpreters] Make the type attribute lookup cache 
per-interpreter".

--

___
Python tracker 

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



[issue42746] python3.7.3 - ssl.SSLContext() - "Killed"

2020-12-25 Thread yaksha nyx


New submission from yaksha nyx :

I got a very strange issue with my Python3.7.3.
I use ssl module with urllin.request , when I visit some https website my 
script always die .so I got this :

***
Python 3.7.3 (default, Dec 26 2020, 06:35:45)
[GCC 6.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl 
>>> >>> ssl.OPENSSL_VERSION
'LibreSSL 3.1.1'
>>> ssl.SSLContext()
Killed
***

Just "Killed" , no more infomation . 
How to check this problem ?

--
assignee: christian.heimes
components: SSL
messages: 383779
nosy: christian.heimes, hgmmym
priority: normal
severity: normal
status: open
title: python3.7.3 - ssl.SSLContext() - "Killed"
type: crash
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



[issue42745] [subinterpreters] Make the type attribute lookup cache per-interpreter

2020-12-25 Thread STINNER Victor


Change by STINNER Victor :


--
keywords: +patch
pull_requests: +22795
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/23947

___
Python tracker 

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



[issue42745] [subinterpreters] Make the type attribute lookup cache per-interpreter

2020-12-25 Thread STINNER Victor


Change by STINNER Victor :


--
title: [subinterpreters] Make the type lookup cache per-interpreter -> 
[subinterpreters] Make the type attribute lookup cache per-interpreter

___
Python tracker 

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



[issue42741] Sync 3.9's whatsnew document in 3.10 with 3.9 branch

2020-12-25 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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



[issue36876] [subinterpreters] Global C variables are a problem

2020-12-25 Thread Eric Snow


Eric Snow  added the comment:


New changeset 5ae9be68d9f1a628fdc920b647257f94afb77887 by Eric Snow in branch 
'master':
bpo-36876: [c-analyzer tool] Additional CLI updates for "capi" command. 
(gh-23929)
https://github.com/python/cpython/commit/5ae9be68d9f1a628fdc920b647257f94afb77887


--

___
Python tracker 

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



[issue42745] [subinterpreters] Make the type lookup cache per-interpreter

2020-12-25 Thread STINNER Victor


New submission from STINNER Victor :

Currently, the type lookup cache is shared by all interpreter which causes 
multiple issues:

* The version tag is currently protected by the GIL, but it would require a new 
lock if the GIL is made per interpreter (bpo-40512)

* Clearing the cache in an interpreter clears the cache in all interpreters

* The cache has a fixed size of 4096 entries. The cache misses increase with 
the number of interpreters, since each interpreter has its own types.

I propose to make the type lookup cache per interpreter.

--
components: Interpreter Core, Subinterpreters
messages: 383777
nosy: vstinner
priority: normal
severity: normal
status: open
title: [subinterpreters] Make the type lookup cache per-interpreter
versions: Python 3.10

___
Python tracker 

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



[issue42222] Modernize integer test/conversion in randrange()

2020-12-25 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

There is another randrange() oddity.  If stop is None, the step argument is 
ignored:

>>> randrange(100, stop=None, step=10)
4

If we want to fully harmonize with range(), then randrange() should only accept 
positional arguments and should not allow None for the stop argument.  That 
would leave the unoptimized implementation equivalent to:

def randrange(self, /, *args):
return self.choice(range(*args))

The actual implementation can retain its fast paths and have a nicer looking 
signature perhaps using __text_signature__.

--

___
Python tracker 

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



[issue42318] [tkinter] surrogate pairs in Tcl/Tk string when pasting an emoji in a text widget

2020-12-25 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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



[issue42318] [tkinter] surrogate pairs in Tcl/Tk string when pasting an emoji in a text widget

2020-12-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 4d840e428ab1a2712f219c5e4008658cbe15892e by Miss Islington (bot) 
in branch '3.8':
[3.8] bpo-42318: Fix support of non-BMP characters in Tkinter on macOS 
(GH-23281). (GH-23784) (GH-23787)
https://github.com/python/cpython/commit/4d840e428ab1a2712f219c5e4008658cbe15892e


--

___
Python tracker 

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



[issue42742] Add abc.Mapping to dataclass

2020-12-25 Thread Anton Abrosimov


Anton Abrosimov  added the comment:

Thanks for the good offer, I will definitely use it.

--

___
Python tracker 

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



[issue42737] PEP 563: drop annotations for complex assign targets

2020-12-25 Thread Guido van Rossum


Guido van Rossum  added the comment:

So the distinction between simple and complex is to define what goes into 
`__annotations__`. As long as we don't disturb that I think it's fine not to 
evaluate anything. (There's also the effect on what's considered a local 
variable, inside functions.)

--

___
Python tracker 

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



[issue40494] collections.abc.Callable and type variables

2020-12-25 Thread Guido van Rossum


Guido van Rossum  added the comment:

Indeed. Thanks!

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



[issue42742] Add abc.Mapping to dataclass

2020-12-25 Thread Eric V. Smith


Eric V. Smith  added the comment:

I'm just warning you that I probably won't accept it. I haven't heard of any 
demand for this feature.

You might want to bring it up on python-ideas if you want to generate support 
for the proposal.

--

___
Python tracker 

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



[issue42742] Add abc.Mapping to dataclass

2020-12-25 Thread Anton Abrosimov


Anton Abrosimov  added the comment:

This Mixin only works with dataclass objects. And uses the private 
functionality of the dataclasses. So dataclasses.py is the right place for 
this. I think I can do enough tests.

And I think that this is too little for a standalone project.

--

___
Python tracker 

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



[issue38649] tkinter messagebox is sloppy

2020-12-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I agree that there is a problem. tkinter.messagebox is poorly documented. 
Different functions can return True, False, None or the name of the button, and 
it is not specified which function what returns. Set of acceptable values for 
type and icon are not documented. And there are no tests, so we cannot be sure 
that all works as expected on all platforms.

I am working on it.

--
assignee: docs@python -> serhiy.storchaka
components: +Tests
nosy: +serhiy.storchaka
versions: +Python 3.10 -Python 3.6

___
Python tracker 

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



[issue39177] In tkinter, simple dialogs, askstrings, etc. with flexible coordinates and no viewable parent.

2020-12-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Issue42685 improved positioning of dialog windows. Now they are centered at the 
parent window or screen if there is no parent. It corresponds to behavior of Tk 
message boxes.

Issue42721 made dialogs be usable without default root window. Temporary hidden 
root window can be creat3ed for the time of life of the dialog.

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



[issue42742] Add abc.Mapping to dataclass

2020-12-25 Thread Eric V. Smith


Eric V. Smith  added the comment:

I don't think this belongs in dataclasses itself, at least not until it's been 
vetted widely. You might want to put it on PyPI first as a standalone project.

--

___
Python tracker 

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



[issue42742] Add abc.Mapping to dataclass

2020-12-25 Thread Anton Abrosimov


Anton Abrosimov  added the comment:

I think the second option looks better.
More pythonic.
No need to create new classes
No typing hacks.
Mixin can be easily expanded.

Yes, I will do refactoring, typing, documentation and tests in PR.

--

___
Python tracker 

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



[issue39171] Missing default root in tkinter simpledialog.py

2020-12-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Issue42721 made possible to use these dialogs without default root window. A 
temporary hidden root window is created for the time of life of a dialog and it 
is not set as default root window.

Positioning dialog wit5hout parent was improved in issue42685.

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



[issue42742] Add abc.Mapping to dataclass

2020-12-25 Thread Anton Abrosimov


Anton Abrosimov  added the comment:

An alternative way:

from collections.abc import Mapping
from dataclasses import dataclass, fields, _FIELDS, _FIELD

class DataclassMappingMixin(Mapping):
def __iter__(self):
return (f.name for f in fields(self))

def __getitem__(self, key):
field = getattr(self, _FIELDS)[key]
if field._field_type is not _FIELD:
raise KeyError(f"'{key}' is not a dataclass field.")
return getattr(self, field.name)

def __len__(self):
return len(fields(self))


@dataclass
class MyDataclass(DataclassMappingMixin):
a: int = 1
b: int = 2


my_dataclass = MyDataclass(a='3')
print(my_dataclass.__class__.__mro__)
print(my_dataclass.__class__.__name__)
print(my_dataclass['a'])
print(my_dataclass['b'])
print(dict(my_dataclass))
print(dict(**my_dataclass))
print(fields(my_dataclass))


Result:
(,
 ,
 ,
 ,
 ,
 ,
 ,
 )
MyDataclass
3
2
{'a': '3', 'b': 2}
{'a': '3', 'b': 2}
(Field(name='a',type=, ...),
 Field(name='b',type=, ...))

--

___
Python tracker 

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



[issue35728] Tkinter font nametofont requires default root

2020-12-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 36a779e64c580519550aa6478c5aa8c58b8fa7b6 by Desmond Cheong in 
branch 'master':
bpo-35728: Add root parameter to tkinter.font.nametofont() (GH-23885)
https://github.com/python/cpython/commit/36a779e64c580519550aa6478c5aa8c58b8fa7b6


--

___
Python tracker 

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



[issue42742] Add abc.Mapping to dataclass

2020-12-25 Thread Eric V. Smith


Eric V. Smith  added the comment:

Something like that. You'd have to write some tests and try it out.

--

___
Python tracker 

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



[issue15303] Minor revision to the method in Tkinter

2020-12-25 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.10 -Python 3.6

___
Python tracker 

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



[issue42734] Outdated CodeType call in "bogus_code_obj.py"

2020-12-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

To be honest, I was not sure that replace() exists in 3.8 and I was too lazy to 
write different code for different versions. Next time when bogus_code_obj.py 
become outdated again we will use replace().

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



[issue42721] Using of simple dialogs without default root window

2020-12-25 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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



[issue42744] pkg_resources seems to treat python 3.10 as python 3.1

2020-12-25 Thread RhinosF1


New submission from RhinosF1 :

As seen in 
https://github.com/MirahezeBots/MirahezeBots/pull/380/checks?check_run_id=1609121656,
 pkg_resources is throwing errors about version conflicts as it seems it thinks 
3.10 is 3.1 or similar. This was fixed for PyPA/Pip in 
https://github.com/pypa/pip/issues/6730 so it installs from pip fine.

--
components: Installation
messages: 383760
nosy: RhinosF1
priority: normal
severity: normal
status: open
title: pkg_resources seems to treat python 3.10 as python 3.1
type: compile error
versions: Python 3.10

___
Python tracker 

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



[issue42734] Outdated CodeType call in "bogus_code_obj.py"

2020-12-25 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

To make it slightly more readable and future-proof so such things don't become 
outdated again in the future, you could use the CodeType.replace() method.

See also https://bugs.python.org/issue42422

--
nosy: +Dennis Sweeney

___
Python tracker 

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



[issue42742] Add abc.Mapping to dataclass

2020-12-25 Thread Anton Abrosimov


Anton Abrosimov  added the comment:

Thanks for the answer, I agree.
The implementation should be like this?


from collections.abc import Mapping
from dataclasses import dataclass, fields, _FIELDS, _FIELD

class _DataclassMappingMixin(Mapping):
def __iter__(self):
return (f.name for f in fields(self))

def __getitem__(self, key):
fields = getattr(self, _FIELDS)
f = fields[key]
if f._field_type is not _FIELD:
raise KeyError(f"'{key}' is not a dataclass field.")
return getattr(self, f.name)

def __len__(self):
return len(fields(self))


def dataclass_mapping(cls=None, **kwargs):
def apply_dataclass(cls):
dataclass_wrap = dataclass(**kwargs)
return dataclass_wrap(cls)

def check_mapping_attrs(cls):
mapping_attrs = (i for i in dir(_DataclassMappingMixin) if i[0] != '_')
for key in mapping_attrs:
if hasattr(cls, key):
raise AttributeError(f"'{key}' is the Mapping reserved 
attribute.")

def apply_mapping(cls):
return type(cls.__name__ + 'Mapping',
(cls, _DataclassMappingMixin),
{})

def wrap(cls):
check_mapping_attrs(cls)
cls_dataclass = apply_dataclass(cls)
return apply_mapping(cls_dataclass)

# See if we're being called as @dataclass or @dataclass().
if cls is None:
# We're called with parens.
return wrap

# We're called as @dataclass without parens.
return wrap(cls)


@dataclass_mapping
class MyDataclass:
a: int = 1
b: int = 2


my_dataclass = MyDataclass(b='3')
print(my_dataclass.__class__.__name__)
print(my_dataclass['a'])
print(my_dataclass['b'])
print(dict(my_dataclass))
print(dict(**my_dataclass))

--

___
Python tracker 

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



[issue42736] Add support for making Linux prctl(...) calls to subprocess

2020-12-25 Thread Benjamin Peterson


Benjamin Peterson  added the comment:

I wonder if a dedicated datatype should be created for all os-specific 
parameters like https://golang.org/pkg/syscall/#SysProcAttr. Popen already has 
way too many parameters. And prctl is a very general interface; probably 98% of 
prctls would never need to be called pre-exec.

(Separately, os.prctl should be created to expose prctl in all its multiplexed 
glory?)

(Also, but PDEATHSIG has an infamous footgun where the the signal is sent on 
exit of the forking thread, which is not necessarily the exit of the invoking 
process.)

--
nosy: +benjamin.peterson

___
Python tracker 

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



[issue42721] Using of simple dialogs without default root window

2020-12-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 675c97eb6c7c14c6a68ebf476c52931c1e5c1220 by Serhiy Storchaka in 
branch 'master':
bpo-42721: Improve using simple dialogs without root window (GH-23897)
https://github.com/python/cpython/commit/675c97eb6c7c14c6a68ebf476c52931c1e5c1220


--

___
Python tracker 

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



[issue42742] Add abc.Mapping to dataclass

2020-12-25 Thread Eric V. Smith


Eric V. Smith  added the comment:

You'd need to return a different class in order to add the 
collections.abc.Mapping base class. Currently, dataclasses by design always 
return the same class that's passed in.

I'd suggest adding this as a stand-alone decorator.

--
assignee:  -> eric.smith
nosy: +eric.smith

___
Python tracker 

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



[issue28964] AST literal_eval exceptions provide no information about line number

2020-12-25 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


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



[issue28964] AST literal_eval exceptions provide no information about line number

2020-12-25 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:


New changeset 586f3dbe15139cafb2a6ffb82cea146906561844 by Irit Katriel in 
branch 'master':
bpo-28964: add line number of node (if available) to ast.literal_eval error 
messages (GH-23677)
https://github.com/python/cpython/commit/586f3dbe15139cafb2a6ffb82cea146906561844


--

___
Python tracker 

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



[issue42743] pdb vanishing breakpoints

2020-12-25 Thread Daniel Schreck


New submission from Daniel Schreck :

Using pdb, breakpoints disappear when stepping into a function in another 
module. They're not hit from then on. HOWEVER, if any new breakpoint is 
entered, all the breakpoints reappear. They vanish every time the debugger 
steps across the module, and only reappear with a new breakpoint entry. 
Behavior is reproducible.

--
messages: 383753
nosy: ds2606
priority: normal
severity: normal
status: open
title: pdb vanishing breakpoints
type: behavior
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



[issue42742] Add abc.Mapping to dataclass

2020-12-25 Thread Anton Abrosimov


New submission from Anton Abrosimov :

I want to add `abc.Mapping` extension to `dataclasses.dataclass`.

Motivation:

1. `asdict` makes a deep copy of the `dataclass` object. If I only want to 
iterate over the `field` attributes, I don't want to do a deep copy.
2. `dict(my_dataclass)` can be used as a `dict` representation of 
`my_dataclass` class without deep copying.
3. `myfunc(**my_dataclass)` looks better and is faster then 
`myfunc(**asdict(my_dataclass))`.
4. `len(my_dataclass) == len(asdict(my_dataclass))` is expected behavior.
5. `my_dataclass.my_field is my_dataclass['my_field']` is expected behavior.


Looks like a prototype:

from collections.abc import Mapping
from dataclasses import dataclass, fields, _FIELDS, _FIELD


@dataclass  # `(mapping=True)` creates such a class:
class MyDataclass(Mapping):
a: int = 1
b: int = 2

# In `dataclasses._process_class`:
# if `mapping` is `True`.
# Make sure 'get', 'items', 'keys', 'values' is not in `MyDataclass` fields.

def __iter__(self):
return (f.name for f in fields(self))

def __getitem__(self, key):
fields = getattr(self, _FIELDS)
f = fields[key]
if f._field_type is not _FIELD:
raise KeyError(f"'{key}' is not a field of the dataclass.")
return getattr(self, f.name)

def __len__(self):
return len(fields(self))


my_dataclass = MyDataclass(b=3)
print(my_dataclass['a'])
print(my_dataclass['b'])
print(dict(my_dataclass))
print(dict(**my_dataclass))

Stdout:
1
3
{'a': 1, 'b': 3}
{'a': 1, 'b': 3}


Realisation:

Updating the `dataclasses.py`: `dataclass`, `_process_class`, 
`_DataclassParams`.
Set `mapping` argument to default `False`.


Can this enhancement be accepted?

--
components: Library (Lib)
messages: 383752
nosy: abrosimov.a.a
priority: normal
severity: normal
status: open
title: Add abc.Mapping to dataclass
type: enhancement
versions: Python 3.10

___
Python tracker 

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



[issue42727] [Enum] EnumMeta.__prepare__ needs to accept **kwds

2020-12-25 Thread Ethan Furman


Change by Ethan Furman :


--
pull_requests:  -22792

___
Python tracker 

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



[issue42727] [Enum] EnumMeta.__prepare__ needs to accept **kwds

2020-12-25 Thread miss-islington


miss-islington  added the comment:


New changeset fbffda25b4b5f537e651eaab4ca1ec4cde800709 by Miss Islington (bot) 
in branch '3.9':
bpo-42727: [Enum] use super() and include **kwds (GH-23927)
https://github.com/python/cpython/commit/fbffda25b4b5f537e651eaab4ca1ec4cde800709


--

___
Python tracker 

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



[issue42741] Sync 3.9's whatsnew document in 3.10 with 3.9 branch

2020-12-25 Thread Ken Jin


Change by Ken Jin :


--
keywords: +patch
pull_requests: +22794
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/23943

___
Python tracker 

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



[issue42741] Sync 3.9's whatsnew document in 3.10 with 3.9 branch

2020-12-25 Thread Ken Jin


New submission from Ken Jin :

On the 3.10 branch, the what's new document for 3.9 isn't synced with the one 
on the 3.9 branch.

Currently it's missing two entries:

macOS 11.0 (Big Sur) and Apple Silicon Mac support
issue41100

(next one's my fault, sorry)
collections.abc.Callable changes
issue42195

--
assignee: docs@python
components: Documentation
messages: 383750
nosy: docs@python, kj, lukasz.langa, pablogsal
priority: normal
severity: normal
status: open
title: Sync 3.9's whatsnew document in 3.10 with 3.9 branch
versions: Python 3.10

___
Python tracker 

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



[issue42740] typing.py get_args and get_origin should support PEP 604 and 612

2020-12-25 Thread Ken Jin


Change by Ken Jin :


--
keywords: +patch
pull_requests: +22793
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/23942

___
Python tracker 

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



[issue42727] [Enum] EnumMeta.__prepare__ needs to accept **kwds

2020-12-25 Thread Desmond Cheong


Change by Desmond Cheong :


--
nosy: +desmondcheongzx
nosy_count: 3.0 -> 4.0
pull_requests: +22792
pull_request: https://github.com/python/cpython/pull/23885

___
Python tracker 

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



[issue42734] Outdated CodeType call in "bogus_code_obj.py"

2020-12-25 Thread miss-islington


miss-islington  added the comment:


New changeset 51f502914656a1f8e8ffdf6e1b06f670d8fea8ed by Miss Islington (bot) 
in branch '3.9':
bpo-42734: Fix crasher bogus_code_obj.py (GH-23939)
https://github.com/python/cpython/commit/51f502914656a1f8e8ffdf6e1b06f670d8fea8ed


--

___
Python tracker 

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



[issue42734] Outdated CodeType call in "bogus_code_obj.py"

2020-12-25 Thread miss-islington


miss-islington  added the comment:


New changeset 0178a6b67ca3e782443f311e953509ca3eb4aacf by Miss Islington (bot) 
in branch '3.8':
bpo-42734: Fix crasher bogus_code_obj.py (GH-23939)
https://github.com/python/cpython/commit/0178a6b67ca3e782443f311e953509ca3eb4aacf


--

___
Python tracker 

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



[issue42740] typing.py get_args and get_origin should support PEP 604 and 612

2020-12-25 Thread Ken Jin


New submission from Ken Jin :

Currently get_args doesn't work for PEP 604 Union:

>>> get_args(int | str)

or new Callables with PEP 612:

>>> P = ParamSpec('P)
>>> get_args(Callable[P, int])
([~P], )

get_origin doesn't work with PEP 604 Unions:

>>> get_origin(int | str)


PS: the fix has to be backported partly to 3.9. Because get_args doesn't handle 
collections.abc.Callable either.

--
components: Library (Lib)
messages: 383747
nosy: gvanrossum, kj, levkivskyi
priority: normal
severity: normal
status: open
title: typing.py get_args and get_origin should support PEP 604 and 612
type: behavior
versions: Python 3.10, Python 3.9

___
Python tracker 

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



[issue15303] Minor revision to the method in Tkinter

2020-12-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset bb70b2afe39ad4334a9f3449cddd28149bd628b6 by Serhiy Storchaka in 
branch 'master':
bpo-15303: Support widgets with boolean value False in Tkinter (GH-23904)
https://github.com/python/cpython/commit/bb70b2afe39ad4334a9f3449cddd28149bd628b6


--

___
Python tracker 

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



[issue42734] Outdated CodeType call in "bogus_code_obj.py"

2020-12-25 Thread miss-islington


Change by miss-islington :


--
pull_requests: +22791
pull_request: https://github.com/python/cpython/pull/23941

___
Python tracker 

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



[issue42734] Outdated CodeType call in "bogus_code_obj.py"

2020-12-25 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 2.0 -> 3.0
pull_requests: +22790
pull_request: https://github.com/python/cpython/pull/23940

___
Python tracker 

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



[issue42734] Outdated CodeType call in "bogus_code_obj.py"

2020-12-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 954a7427ba9c2d02faed32c02090caeca873aeca by Serhiy Storchaka in 
branch 'master':
bpo-42734: Fix crasher bogus_code_obj.py (GH-23939)
https://github.com/python/cpython/commit/954a7427ba9c2d02faed32c02090caeca873aeca


--

___
Python tracker 

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



[issue40494] collections.abc.Callable and type variables

2020-12-25 Thread Ken Jin


Ken Jin  added the comment:

Now that issue42195 has been resolved by subclassing types.GenericAlias, can 
this be closed?

On 3.9 and 3.10:

>>> import typing, collections.abc
>>> T = typing.TypeVar('T')
>>> C2 = collections.abc.Callable[[T], T]
>>> C2[int]
collections.abc.Callable[[int], int]

It seems to be fixed :).

--
nosy: +kj

___
Python tracker 

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



[issue42733] [issue] io's r+ mode truncate(0)

2020-12-25 Thread 施文峰

施文峰  added the comment:

hi Steven

thanks for check my post

first test have a problem,you didn’t use r+ mode
step is 
1. f.read
2. f.truncate(0)
3. f.write(something)

my test msg tell you

“
tell after delete content 33
content 0 
tell after write 65
“

so you know after truncate f.tell =33
but no content in file
and after you write something into file
msg tell you f.tell =65
but “ {"how_dare_you": "how_dare_you"}” is only 33 length 
so you know must have someing in file

please use editor open the file
you will find it

--

___
Python tracker 

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



[issue42733] [issue] io's r+ mode truncate(0)

2020-12-25 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

You say:

>  after process python3 test_case.py
>  json file's content like this
>  
>  @@{"how_dare_you": "how_dare_you"}


I cannot replicate that result.


I created a "data.json" with the following content:


```
>>> with open(FILE_PATH, 'w') as f:
... f.write('{"how_dare_you": "how_dare_you"}\n')
... 
33
>>> with open(FILE_PATH, 'r') as f:
... print(f.read())
... 
{"how_dare_you": "how_dare_you"}

```


Then I ran your `test` function and the only result was to delete the newline 
at the end of the file:


```
>>> test()
beginning tell 0
tell after read 33
tell after delete content 33
content 0 
tell after write 65
content 0 
>>> 
>>> with open(FILE_PATH, 'r') as f:
... print(f.read())
... 
{"how_dare_you": "how_dare_you"}
>>> 
```

So I cannot replicate your reported bug. There is no sign of any garbage 
characters inserted at the start of the file as you state.

--
nosy: +steven.daprano

___
Python tracker 

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



[issue42739] Crash when try to disassemble bogus code object

2020-12-25 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

>>> def f(): pass
... 
>>> co = f.__code__.replace(co_linetable=b'')
>>> import dis
>>> dis.dis(co)
python: Objects/codeobject.c:1185: PyLineTable_NextAddressRange: Assertion 
`!at_end(range)' failed.
Aborted (core dumped)

It is expected that executing bogus code object can crash (or cause any other 
effect). But it is surprising that just inspecting it causes a crash.

--
components: Interpreter Core
messages: 383741
nosy: Mark.Shannon, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Crash when try to disassemble bogus code object
type: crash
versions: Python 3.10

___
Python tracker 

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



[issue38435] Start the deprecation cycle for subprocess preexec_fn

2020-12-25 Thread STINNER Victor


STINNER Victor  added the comment:

I just created bpo-42738: "subprocess: don't close all file descriptors by 
default (close_fds=False)".

--

___
Python tracker 

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



[issue42738] subprocess: don't close all file descriptors by default (close_fds=False)

2020-12-25 Thread STINNER Victor


New submission from STINNER Victor :

To make subprocess faster, I propose to no longer close all file descriptors by 
default in subprocess: change Popen close_fds parameter default to False 
(close_fds=False).

Using close_fds=False, subprocess can use posix_spawn() which is safer and 
faster than fork+exec. For example, on Linux, the glibc implements it as a 
function using vfork which is faster than fork if the parent allocated a lot of 
memory. On macOS, posix_spawn() is even a syscall.

The main drawback is that close_fds=False reopens a security vulnerability if a 
file descriptor is not marked as non-inheritable. The PEP 446 "Make newly 
created file descriptors non-inheritable" was implemented in Python 3.4: Python 
should only create non-inheritable FDs, if it's not the case, Python should be 
fixed. Sadly, 3rd party Python modules may not implement the PEP 446. In this 
case, close_fds=True should be used explicitly, or these modules should be 
fixed. os.set_inheritable() can be used to make FDs as non-inheritable.

close_fds=True has a cost on subprocess performance. When the maximum number of 
file descriptors is larger than 10,000 and Python has no way to list open file 
descriptors, calling close(fd) once per file descriptor can take several 
milliseconds. When I wrote the PEP 446 (in 2013), on a FreeBSD buildbot with 
MAXFD=655,000, closing all FDs took 300 ms (see bpo-11284 "slow close file 
descriptors").

FreeBSD has been fixed recently by using closefrom() function which makes 
_posixsubprocess and os.closerange() faster.

In 2020, my Red Hat colleagues still report the issue in Linux containers 
using... Python 2.7, since Python 2.7 subprocess also close all file 
descriptors in a loop (there was no code to list open file descriptors). The 
problem still exists in Python 3 if subprocess cannot open /proc/self/fd/ 
directory, when /proc pseudo filesystem is not mounted (or if the access is 
blocked, ex: by a sandbox). The problem is that some containers are created a 
very high limit for the maximum number of FDs: os.sysconf("SC_OPEN_MAX") 
returns 1,048,576. Calling close() more than 1 million of times is slow...

See also related issue bpo-38435 "Start the deprecation cycle for subprocess 
preexec_fn".

--

Notes about close_fds=True.

Python 3.9 can now use closefrom() function on FreeBSD: bpo-38061.

Linux 5.10 has a new closerange() syscall: https://lwn.net/Articles/789023/

Linux 5.11 (not released yet) will add a new CLOSE_RANGE_CLOEXEC flag to 
close_range(): https://lwn.net/Articles/837816/

--

History of the close_fds parameter default value.

In Python 2.7, subprocess didn't close all file descriptors by default: 
close_fds=False by default.

Dec 4, 2010: In Python 3.2 (bpo-7213, bpo-2320), subprocess.Popen started to 
emit a deprecating warning when close_fds was not specified explicitly (commit 
d23047b62c6f885def9020bd9b304110f9b9c52d):

+if close_fds is None:
+# Notification for http://bugs.python.org/issue7213 & issue2320
+warnings.warn(
+'The close_fds parameter was not specified.  Its default'
+' will change from False to True in a future Python'
+' version.  Most users should set it to True.  Please'
+' update your code explicitly set close_fds.',
+DeprecationWarning)

Dec 13 2010, bpo-7213: close_fds default value was changed to True on 
non-Windows platforms, and False on Windows (commit 
f5604853889bfbbf84b48311c63c0e775dff38cc). The implementation was adjusted in 
bpo-6559 (commit 8edd99d0852c45f70b6abc851e6b326d4250cd33) to use a new 
_PLATFORM_DEFAULT_CLOSE_FDS singleton object.

See issues:

* bpo-2320: Race condition in subprocess using stdin
* bpo-6559: add pass_fds paramter to subprocess.Popen()
* bpo-7213: subprocess leaks open file descriptors between Popen instances 
causing hangs

--

On Windows, there is also the question of handles (HANDLE type). Python 3.7 
added the support for the PROC_THREAD_ATTRIBUTE_HANDLE_LIST in 
subprocess.STARTUPINFO: lpAttributeList['handle_list'] parameter. Hopefully, 
Windows has a way better default than Unix: all handles are created as 
non-inheritable by default, so these is no need to explicitly close them.

--
components: Library (Lib)
messages: 383739
nosy: gregory.p.smith, vstinner
priority: normal
severity: normal
status: open
title: subprocess: don't close all file descriptors by default (close_fds=False)
versions: Python 3.10

___
Python tracker 

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



[issue42685] Improve placing of simple query windows.

2020-12-25 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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



[issue42731] Enhancement request for proxying PyString

2020-12-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

There is no longer PyString in Python, only PyUnicode.

There are plans to get rid of PyUnicode_READY(). After removing support of 
"legacy" Unicode objects (which will happen in few years), PyUnicode_READY() 
will be no longer needed, so all calls of it could be removed. Currently there 
is a last chance to redesign it for other purposes. I suggest to discuss this 
on one of mailing lists (Python-ideas or even Python-Dev) with wider auditory, 
as it can have large impact on the future of C API.

Although I am not sure that PyUnicode_READY() is called in all needed cases. It 
just happen that the code is not tested intensively with "legacy" Unicode 
objects because in normal case you get already ready objects. Actually, 
functions like _PyUnicode_EqualToASCIIString do not call it intentionally and 
read the Py_UNICODE content of non-ready Unicode objects directly.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue42734] Outdated CodeType call in "bogus_code_obj.py"

2020-12-25 Thread Xinmeng Xia

Xinmeng Xia  added the comment:

Yes,you are right. I thought it was fixed,but it wasn't. Thanks.

--
type: enhancement -> behavior

___
Python tracker 

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



[issue42735] "trace_at_recursion_limit.py" should be removed from "Python/Lib/test/crashers"

2020-12-25 Thread Xinmeng Xia


Change by Xinmeng Xia :


--
type: enhancement -> behavior

___
Python tracker 

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



[issue42734] Outdated CodeType call in "bogus_code_obj.py"

2020-12-25 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +22789
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/23939

___
Python tracker 

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



[issue42734] Outdated CodeType call in "bogus_code_obj.py"

2020-12-25 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
title: "bogus_code_obj.py" should be removed from "cPython/Lib/test/crashers" 
-> Outdated CodeType call in "bogus_code_obj.py"

___
Python tracker 

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



[issue38435] Start the deprecation cycle for subprocess preexec_fn

2020-12-25 Thread STINNER Victor


STINNER Victor  added the comment:

> Using an intermediate shell script wrapper that changes the rlimit and exec's 
> the actual process is also an alternative.

IMO using Python is more portable than relying on a shell.

I dislike relying on a shell since shells are not really portable (behave 
differently), unless you restrict yourself to a strict POSIX subset of the 
shell programming language. While '/bin/sh' is available on most Unix, Android 
uses '/system/bin/sh', and Windows and VxWorks have no shell (Windows provides 
cmd.exe which uses Batch programming language, and there are other scripting 
languages like VBS or PowerShell: so you need a complete different 
implementation for Windows).

For the oslo.concurrency project, I wrote the Python script prlimit.py: a 
wrapper calling resource.setrlimit() and then execute a new program. It's 
similar to the Unix prlimit program, but written in Python to be portable (the 
"prlimit" program is not available on all platforms).

https://github.com/openstack/oslo.concurrency/blob/master/oslo_concurrency/prlimit.py

I suggest to not provide a builtin wrapper to replace preexec_fn, but suggest 
replacements in the subprocess and What's New in Python 3.11 documentation 
(explain how to port existing code).

More generally, the whole preeexc_fn feature could be reimplemented a 
third-party project by spawning a *new* Python process, run the Python code, 
and *then* execute the final process. The main feature of preexec_fn is to give 
the ability to run a function of the current process, whereas what I'm 
discussing would be code written as a string.

--

preexec_fn can be used for non-trivial issues like only sharing some Windows 
HANDLE, see:
https://www.python.org/dev/peps/pep-0446/#only-inherit-some-handles-on-windows

Note: This specific problem has been solved the proper way in Python by adding 
support for PROC_THREAD_ATTRIBUTE_HANDLE_LIST in subprocess.STARTUPINFO: 
lpAttributeList['handle_list'] parameter.

--

___
Python tracker 

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



[issue42734] "bogus_code_obj.py" should be removed from "cPython/Lib/test/crashers"

2020-12-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

No, it was not fixed. The code object creation was broken, because the code 
constructor signature was changed.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue42730] TypeError/hang inside of Time.Sleep() when _thread.interrupt_main()

2020-12-25 Thread AR Kareem


AR Kareem  added the comment:

Shouldn't the behaviour for _thread.interrupt_main() be always to interrupt the 
main thread. 

I would expect that if a child thread uses _thread.interrupt_main() that the 
main thread be interrupted regardless of how the python script was invoked.

Wouldn't it be more reasonable to make _thread.interrupt_main() always raise a 
SIGINT? I'm not sure if this is technically considered a bug or not, but it 
seems that it's not functioning as intended even in Python 3.7

--

___
Python tracker 

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



[issue29076] Mac installer shell updater script silently fails if default shell is fish

2020-12-25 Thread miss-islington


miss-islington  added the comment:


New changeset 7f162e867c674f57c308a87fffcdcca3540c8933 by Erlend Egeberg 
Aasland in branch 'master':
bpo-29076: Add fish support to macOS installer (GH-23302)
https://github.com/python/cpython/commit/7f162e867c674f57c308a87fffcdcca3540c8933


--

___
Python tracker 

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



[issue29076] Mac installer shell updater script silently fails if default shell is fish

2020-12-25 Thread miss-islington


Change by miss-islington :


--
pull_requests: +22788
pull_request: https://github.com/python/cpython/pull/23938

___
Python tracker 

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



[issue29076] Mac installer shell updater script silently fails if default shell is fish

2020-12-25 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 4.0 -> 5.0
pull_requests: +22787
pull_request: https://github.com/python/cpython/pull/23937

___
Python tracker 

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



[issue36675] Doctest directives and comments missing from code samples

2020-12-25 Thread Julien Palard


Julien Palard  added the comment:

Happy Christmas, everybody involved in this issue! I'm happy to announce this 
issue is resolved since a few days \o/

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



[issue42730] TypeError/hang inside of Time.Sleep() when _thread.interrupt_main()

2020-12-25 Thread AR Kareem


AR Kareem  added the comment:

My apologies, I meant to flag it as 3.6 instead of 3.7.

I see what's happening now, and thanks for providing the correct way to raise a 
KeyboardInterrupt.

Correctly flagged as 3.6 and closed.

Thanks.

--
resolution:  -> duplicate
versions: +Python 3.6 -Python 3.7

___
Python tracker 

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



[issue42725] PEP 563: Should the behavior change for yield/yield from's

2020-12-25 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

I have a patch ready to go, but I'd prefer to block this issue until issue 
42737 is resolved/decided.

--

___
Python tracker 

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



[issue42737] PEP 563: drop annotations for complex assign targets

2020-12-25 Thread Batuhan Taskaya


New submission from Batuhan Taskaya :

PEP 526 classifies everything but simple, unparenthesized names (a.b, (a), 
a[b]) as complex targets. The way the we handle annotations for them right now 
is, doing literally nothing but evaluating every part of it (just pushing the 
name to the stack, and popping, without even doing the attribute access);

$ cat t.py
foo[bar]: int
$ python -m dis t.py
  1   0 SETUP_ANNOTATIONS
  2 LOAD_NAME0 (foo)
  4 POP_TOP
  6 LOAD_NAME1 (bar)
  8 POP_TOP
 10 LOAD_NAME2 (int)
 12 POP_TOP
 14 LOAD_CONST   0 (None)
 16 RETURN_VALUE


$ cat t.py
a.b: int
$ python -m dis t.py
  1   0 SETUP_ANNOTATIONS
  2 LOAD_NAME0 (a)
  4 POP_TOP
  6 LOAD_NAME1 (int)
  8 POP_TOP
 10 LOAD_CONST   0 (None)
 12 RETURN_VALUE

I noticed this while creating a patch for issue 42725, since I had to create an 
extra check for non-simple annassign targets (because compiler tries to find 
their scope, `int` in this case is not compiled to string). 

Since they have no real side effect but just accessing a name, I'd propose we 
drop this from 3.10 so that both I can simply the patch for issue 42725, and 
also we have consistency with what we do when the target is simple (instead of 
storing this time, we'll just drop the bytecode).

$ cat t.py
a.b: int = 5
$ python -m dis t.py
  1   0 SETUP_ANNOTATIONS
  2 LOAD_CONST   0 (5)
  4 LOAD_NAME0 (a)
  6 STORE_ATTR   1 (b)
  8 LOAD_NAME2 (int)
 10 POP_TOP
 12 LOAD_CONST   1 (None)
 14 RETURN_VALUE

8/10 will be gone in this case.

If agreed upon, I can propose a patch.

--
components: Interpreter Core
messages: 383729
nosy: BTaskaya, gvanrossum, lys.nikolaou, pablogsal, serhiy.storchaka
priority: normal
severity: normal
status: open
title: PEP 563: drop annotations for complex assign targets
versions: Python 3.10

___
Python tracker 

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



  1   2   >