[issue42272] Warning filter message/module documentation is misleading

2021-08-28 Thread Ananya Datta


Ananya Datta  added the comment:

No comments

--
nosy: +ananyadatta88
Added file: https://bugs.python.org/file50238/D365 Finance cert learning 
path.pdf

___
Python tracker 

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



[issue45024] Cannot extend collections ABCs with protocol

2021-08-28 Thread Ken Jin


Ken Jin  added the comment:

Thanks for the bug report Anup. I'm mildly confused by what you meant, so 
please help me here:

I interpreted your request as wanting any type that implements `method` and 
`__iter__` to be considered a subtype of `IterableWithMethod`. But this already 
works at runtime and with mypy.

Are you perhaps saying that you want issubclass(Foo, IterableWithMethod) to 
work?

--
components:  -Parser
nosy: +Jelle Zijlstra, gvanrossum, kj -lys.nikolaou, pablogsal
status: open -> pending

___
Python tracker 

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



[issue36521] Consider removing docstrings from co_consts in code objects

2021-08-28 Thread Irit Katriel


Irit Katriel  added the comment:

> I'd like to remove docstring from code object at all.
> func.__doc__ can be set by MAKE_FUNCTION or STORE_ATTR.


I think that would require a change in the signature of PyFunction_New.

--

___
Python tracker 

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



[issue20658] os.environ.clear() fails with empty keys (posix.unsetenv)

2021-08-28 Thread Irit Katriel


Irit Katriel  added the comment:

They keys are checked now, so I think this is resolved.  (Tested on windows and 
Mac).

>>> os.environ[''] = 'X'
Traceback (most recent call last):
  File "", line 1, in 
  File "/Users/iritkatriel/src/cpython/Lib/os.py", line 684, in __setitem__
putenv(key, value)
^^
OSError: [Errno 22] Invalid argument

>>> os.environ['a=b'] = 'c'
Traceback (most recent call last):
  File "", line 1, in 
  File "/Users/iritkatriel/src/cpython/Lib/os.py", line 684, in __setitem__
putenv(key, value)
^^
ValueError: illegal environment variable name

--
nosy: +iritkatriel
resolution:  -> out of date
status: open -> pending

___
Python tracker 

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



[issue19027] undefined symbol: _PyParser_Grammar

2021-08-28 Thread Irit Katriel


Irit Katriel  added the comment:

We no longer have GRAMMAR_H or _PyParser_Grammar in the code.

--
nosy: +iritkatriel
resolution:  -> out of date
stage: needs patch -> 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



[issue45020] Freeze all modules imported during startup.

2021-08-28 Thread Marc-Andre Lemburg


Marc-Andre Lemburg  added the comment:

On 28.08.2021 06:06, Guido van Rossum wrote:
> 
>> With that in place, it'd be great to pre-cache all the .py files 
>> automatically read in at startup.
> 
> *All* the .py files? I think the binary bloat cause by deep-freezing the 
> entire stdlib would be excessive. In fact, Eric's approach freezes everything 
> in the encodings package, which turns out to be a lot of files and a lot of 
> code (lots of simple data tables expressed in code), and I found that for 
> basic startup time, it's best not to deep-freeze the encodings module except 
> for __init__.py, aliases.py and utf_8.py.

Eric's approach, as I understand it, is pretty much what PyRun does.
It freezes almost the entire stdlib. The main aim was to save space
and create a Python runtime with very few files for easy installation and
shipment of products written in Python.

For Python 3.8 (I haven't ported it to more recent Python versions yet),
the uncompressed stripped binary is 15MB. UPX compressed, it's only 5MB:

-rwxr-xr-x 1 lemburg lemburg  15M May 19 15:26 pyrun3.8
-rwxr-xr-x 1 lemburg lemburg  32M Aug 26  2020 pyrun3.8-debug
-rwxr-xr-x 1 lemburg lemburg 5.0M May 19 15:26 pyrun3.8-upx

There's no bloat, since you don't need the .py/.pyc files for the stdlib
anymore. In fact, you save quite a bit of disk space compared to a
full Python installation and additionally benefit from the memory
mapping the OS does for sharing access to the marshal'ed byte code
between processes.

That said, some things don't work with such an approach, e.g.
a few packages include additional data files which they expect to
find on disk. Since those are not available anymore, they fail.

For PyRun I have patched some of those packages to include the
data in form of Python modules instead, so that it gets frozen
as well, e.g. the Python grammar files.

Whether this is a good approach for Python in general is a different
question, though. PyRun is created on top of the existing released
Python distribution, so it doesn't optimize for being able to
work with the frozen code. In fact, early versions did not
even have a REPL, since the main point was to run a
single released app.

--

___
Python tracker 

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



[issue45036] turtle.onrelease() event doesn't get triggered sometimes

2021-08-28 Thread Techn010 Je11y


New submission from Techn010 Je11y :

(pls read with reference to attached code)

I made a Paint-ish program with Turtle. As there isn't ondrag or onrelease for 
Screen, I created a turtle named bg so I could use ondrag and onrelease (see 
file attached ig) and eliminate the need for double-clicking(previously I used 
Screen.onclick to pen.up(), move it to cursor, and pen.down() then use 
turtle.drag() to draw). However, I noticed that it doesn't work(turtle doesn't 
penup when mouse is released sometimes) and added the print("...", i(or j)) 
bits(pls see code). On at least 1 instance 'start' was printed without a 
corresponding release. I'm a beginner so I apologise if it's just a bug in my 
code. I did not install anything related to python after I installed 
3.9.6(64-bit btw). I do not have any other versions. I did not alter any part 
of what's installed.

System info:
Windows 10 Pro Education
Version 10.0.19043(or 21H1), Build 19043.1165
Windows Feature Experience Pack 120.2212.3530.0
Lenovo L13 Gen 2, x64 based PC
11th Gen Intel Core i5-1135G7 @ 2.4GHz, 4 Cores, 8 logical processors
8GB ram

Attached is my code(I'm sorry if it hurts your eyes)

--
assignee: terry.reedy
components: IDLE, Tkinter
files: pain2exp.py
messages: 400470
nosy: techn010je11y, terry.reedy
priority: normal
severity: normal
status: open
title: turtle.onrelease() event doesn't get triggered sometimes
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file50239/pain2exp.py

___
Python tracker 

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



[issue45037] theme-change.py for tkinter lib

2021-08-28 Thread Ayush Parikh


Change by Ayush Parikh :


--
components: Tkinter
nosy: Ayushparikh-code
priority: normal
pull_requests: 26455
severity: normal
status: open
title: theme-change.py for tkinter lib

___
Python tracker 

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



[issue45021] Race condition in thread.py

2021-08-28 Thread nullptr


nullptr  added the comment:

Simplifying the reproducing example a bit more:


from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor
from time import sleep

def submit(pool):
pool.submit(submit, pool)


if __name__ == '__main__':
pool = ThreadPoolExecutor(1)
pool.submit(submit, pool)

while True:
with ProcessPoolExecutor() as workers:
print('WORK')
workers.submit(sleep, 0.01).result()
print('DONE')
print('OK')

--

___
Python tracker 

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



[issue45037] theme-change.py for tkinter lib

2021-08-28 Thread E. Paine


New submission from E. Paine :

I'm slightly confused about the purpose of this PR. Is the intention to create 
a demo, or this designed to be used as an API?

--
nosy: +epaine, serhiy.storchaka, terry.reedy

___
Python tracker 

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



[issue36521] Consider removing docstrings from co_consts in code objects

2021-08-28 Thread Guido van Rossum


Guido van Rossum  added the comment:

> I'd like to remove docstring from code object at all.
> func.__doc__ can be set by MAKE_FUNCTION or STORE_ATTR.

You'd just be moving the problem though -- the docstring would have be included 
in the co_consts array of the surrounding code object instead of the function 
object.

This would actually make it harder to strip docstrings e.g. during 
unmarshalling, since you don't know which constants refer to docstrings.

--

___
Python tracker 

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



[issue45037] theme-change.py for tkinter lib

2021-08-28 Thread Ayush Parikh


Ayush Parikh  added the comment:

yes PR purpose is to show demo for themes change of tkinter window

On Sat, Aug 28, 2021 at 8:03 PM E. Paine  wrote:

>
> New submission from E. Paine :
>
> I'm slightly confused about the purpose of this PR. Is the intention to
> create a demo, or this designed to be used as an API?
>
> --
> nosy: +epaine, serhiy.storchaka, terry.reedy
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue45037] theme-change.py for tkinter lib

2021-08-28 Thread Jonathan Isaac


Jonathan Isaac  added the comment:

Get the code!

--
nosy: +bonesisaac1982

___
Python tracker 

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



[issue45037] theme-change.py for tkinter lib

2021-08-28 Thread Jonathan Isaac


Jonathan Isaac  added the comment:

Bugs

--
components: +Parser
nosy: +lys.nikolaou, pablogsal
type:  -> crash
versions: +Python 3.11, Python 3.6

___
Python tracker 

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



[issue45037] theme-change.py for tkinter lib

2021-08-28 Thread E. Paine


Change by E. Paine :


--
components:  -Parser
nosy:  -bonesisaac1982, lys.nikolaou, pablogsal
type: crash -> enhancement
versions:  -Python 3.6

___
Python tracker 

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



[issue45037] theme-change.py for tkinter lib

2021-08-28 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I do not think this should be included in the Tkinter library.

As for demos, there were Tkinter demos in 2.7 (Demo/tkinter), but they were 
removed.

--

___
Python tracker 

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



[issue45036] turtle.onrelease() event doesn't get triggered sometimes

2021-08-28 Thread E. Paine


E. Paine  added the comment:

The issue is that the "release" function appears to be called before the "drag" 
function for the last coordinate. The fix is probably only lowering the pen 
when the mouse button is first clicked, as this is guaranteed to be called 
before "release". I ended up with something like the following (after removing 
the pen lower logic from the "release" function):

def down(a, b):
print("down")
p.goto(a, b)
p.down()
bg.onclick(down)

--
nosy: +epaine

___
Python tracker 

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



[issue45038] Bugs

2021-08-28 Thread Jonathan Isaac


New submission from Jonathan Isaac :

Jonathan Isaac

Sent with Aqua Mail for Android
https://www.mobisystems.com/aqua-mail

--
messages: 400479
nosy: bonesisaac1982
priority: normal
severity: normal
status: open
title: Bugs

___
Python tracker 

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



[issue45038] Bugs

2021-08-28 Thread Zachary Ware


Zachary Ware  added the comment:

If you don't describe them, we can't fix them ;)

This looks rather like an accidental submission, so I'm going to go ahead and 
close it; if you do have a report you would like to submit, please edit the 
title and add a new comment and I'll be happy to reopen it.

--
nosy: +zach.ware
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



[issue45037] theme-change.py for tkinter lib

2021-08-28 Thread E. Paine


E. Paine  added the comment:

> there were Tkinter demos in 2.7 (Demo/tkinter), but they were removed

Why is this? Because people didn't want to change them all for the tkinter 
module names, or because they were deemed unnecessary?

--

___
Python tracker 

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



[issue45037] theme-change.py for tkinter lib

2021-08-28 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I do not know. There are no issue numbers in changesets which removed them.

--

___
Python tracker 

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



[issue44962] asyncio.create_task weakrefset race condition

2021-08-28 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 206b21ed9f64fedff67bfea7cf73e423e3e32393 by Thomas Grainger in 
branch 'main':
bpo-44962: Fix a race in WeakKeyDict, WeakValueDict and WeakSet when two 
threads attempt to commit the last pending removal (GH-27921)
https://github.com/python/cpython/commit/206b21ed9f64fedff67bfea7cf73e423e3e32393


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue44962] asyncio.create_task weakrefset race condition

2021-08-28 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 5.0 -> 6.0
pull_requests: +26456
pull_request: https://github.com/python/cpython/pull/28013

___
Python tracker 

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



[issue44962] asyncio.create_task weakrefset race condition

2021-08-28 Thread miss-islington


Change by miss-islington :


--
pull_requests: +26457
pull_request: https://github.com/python/cpython/pull/28014

___
Python tracker 

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



[issue45037] theme-change.py for tkinter lib

2021-08-28 Thread Ayush Parikh


Ayush Parikh  added the comment:

so can u review pr and make changes for me if required or guide me so that
it can be merged !

On Sat, Aug 28, 2021 at 10:33 PM Serhiy Storchaka 
wrote:

>
> Serhiy Storchaka  added the comment:
>
> I do not know. There are no issue numbers in changesets which removed them.
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue45039] use ADDOP_LOAD_CONST consistently

2021-08-28 Thread Irit Katriel


New submission from Irit Katriel :

The compiler generally uses ADDOP_LOAD_CONST to emit a LOAD_CONST, but there 
are two places that use ADDOP_O(c, LOAD_CONST, Py_None, consts);

This is currently equivalent to ADDOP_LOAD_CONST(c, Py_None);

It should be replaced because we may soon change ADDOP_LOAD_CONST.

--
components: Interpreter Core
messages: 400485
nosy: iritkatriel
priority: normal
severity: normal
status: open
title: use ADDOP_LOAD_CONST consistently
versions: Python 3.11

___
Python tracker 

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



[issue45029] tkinter doc, hello world example - quit button clobbers method

2021-08-28 Thread miss-islington


Change by miss-islington :


--
keywords: +patch
nosy: +miss-islington
nosy_count: 4.0 -> 5.0
pull_requests: +26458
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/27911

___
Python tracker 

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



[issue45039] use ADDOP_LOAD_CONST consistently

2021-08-28 Thread Irit Katriel


Change by Irit Katriel :


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

___
Python tracker 

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



[issue39817] CRITICAL: TypeError: cannot pickle 'generator'

2021-08-28 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

This issue has been resolved and closed in Pelican tracker; so it can be closed 
here as well, as not a bug.

--
nosy: +andrei.avk

___
Python tracker 

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



[issue45029] tkinter doc, hello world example - quit button clobbers method

2021-08-28 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

For whatever reason, the 3.9 backport, PR-27911, was closed.  In any case, we 
will not edit the code we have replaced.

Lyndon, when responding by email, please delete the old text as it is redundant 
and noisy when your email is added to the web page.

--
nosy: +terry.reedy
resolution:  -> out of date
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue45039] use ADDOP_LOAD_CONST consistently

2021-08-28 Thread Irit Katriel


Change by Irit Katriel :


--
nosy: +Mark.Shannon, gvanrossum

___
Python tracker 

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



[issue44524] __name__ attribute in typing module

2021-08-28 Thread miss-islington


miss-islington  added the comment:


New changeset 81fa08c5ea2cf15254b951034b9d6c7358f96d79 by Miss Islington (bot) 
in branch '3.10':
bpo-44524: Fix cryptic TypeError message when trying to subclass special forms 
in `typing` (GH-27710)
https://github.com/python/cpython/commit/81fa08c5ea2cf15254b951034b9d6c7358f96d79


--

___
Python tracker 

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



[issue45018] Pickling a range iterator with an index of over sizeof(int) stores an invalid index

2021-08-28 Thread miss-islington


miss-islington  added the comment:


New changeset cd986e903176d28ed795f65ba14e6fcbf2a65e3d by Miss Islington (bot) 
in branch '3.10':
bpo-45018: Fix rangeiter_reduce in rangeobject.c (GH-27938)
https://github.com/python/cpython/commit/cd986e903176d28ed795f65ba14e6fcbf2a65e3d


--

___
Python tracker 

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



[issue44962] asyncio.create_task weakrefset race condition

2021-08-28 Thread miss-islington


miss-islington  added the comment:


New changeset 8aa64cc45bff516a6db1f3a3c037cbcce9417fea by Miss Islington (bot) 
in branch '3.10':
bpo-44962: Fix a race in WeakKeyDict, WeakValueDict and WeakSet when two 
threads attempt to commit the last pending removal (GH-27921)
https://github.com/python/cpython/commit/8aa64cc45bff516a6db1f3a3c037cbcce9417fea


--

___
Python tracker 

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



[issue27334] [sqlite3] context manager leaves db locked if commit fails in __exit__

2021-08-28 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 2a80893e5c023a73ccd32cc319f4f0404f548c00 by Erlend Egeberg 
Aasland in branch '3.10':
[3.10] bpo-27334: roll back transaction if sqlite3 context manager fails to 
commit (GH-26202) (GH-27943)
https://github.com/python/cpython/commit/2a80893e5c023a73ccd32cc319f4f0404f548c00


--

___
Python tracker 

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



[issue25130] Make tests more PyPy compatible

2021-08-28 Thread Carl Friedrich Bolz-Tereick


Change by Carl Friedrich Bolz-Tereick :


--
nosy: +Carl.Friedrich.Bolz
nosy_count: 6.0 -> 7.0
pull_requests: +26460
pull_request: https://github.com/python/cpython/pull/28002

___
Python tracker 

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



[issue25130] Make tests more PyPy compatible

2021-08-28 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset eb263f9a356f5c5f21b8d5ce20bac92f31c40cad by Carl Friedrich 
Bolz-Tereick in branch 'main':
bpo-25130: Make unit-test about restricting the maximum number of nested blocks 
cpython-only (GH-28002)
https://github.com/python/cpython/commit/eb263f9a356f5c5f21b8d5ce20bac92f31c40cad


--

___
Python tracker 

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



[issue25130] Make tests more PyPy compatible

2021-08-28 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 7.0 -> 8.0
pull_requests: +26461
pull_request: https://github.com/python/cpython/pull/28016

___
Python tracker 

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



[issue25130] Make tests more PyPy compatible

2021-08-28 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +26462
pull_request: https://github.com/python/cpython/pull/28017

___
Python tracker 

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



[issue27334] [sqlite3] context manager leaves db locked if commit fails in __exit__

2021-08-28 Thread Erlend E. Aasland

Erlend E. Aasland  added the comment:

Thanks Luca, for the report, reproducer, and initial patch, Berker for helpful 
suggestion, and Łukasz, Pablo, & Victor for reviewing and merging.

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



[issue44962] asyncio.create_task weakrefset race condition

2021-08-28 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 166ad706066a2aad84d0ae5b1594c88904fbb939 by Miss Islington (bot) 
in branch '3.9':
bpo-44962: Fix a race in WeakKeyDict, WeakValueDict and WeakSet when two 
threads attempt to commit the last pending removal (GH-27921) (GH-28014)
https://github.com/python/cpython/commit/166ad706066a2aad84d0ae5b1594c88904fbb939


--

___
Python tracker 

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



[issue44962] asyncio.create_task weakrefset race condition

2021-08-28 Thread Łukasz Langa

Łukasz Langa  added the comment:

Thanks, Thomas! ✨ 🍰 ✨

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

___
Python tracker 

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



[issue45018] Pickling a range iterator with an index of over sizeof(int) stores an invalid index

2021-08-28 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



[issue25130] Make tests more PyPy compatible

2021-08-28 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 779b9aef4fb2750f57ce07f0efbc8ce8406e43ab by Miss Islington (bot) 
in branch '3.10':
bpo-25130: Make unit-test about restricting the maximum number of nested blocks 
cpython-only (GH-28002) (GH-28016)
https://github.com/python/cpython/commit/779b9aef4fb2750f57ce07f0efbc8ce8406e43ab


--

___
Python tracker 

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



[issue25130] Make tests more PyPy compatible

2021-08-28 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 1046cd06b0e2f20b3be93de83d49b684956af98d by Serhiy Storchaka in 
branch '3.9':
[3.9] bpo-25130: Make unit-test about restricting the maximum number of nested 
blocks cpython-only (GH-28002) (GH-28017)
https://github.com/python/cpython/commit/1046cd06b0e2f20b3be93de83d49b684956af98d


--

___
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

2021-08-28 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

A worthwhile general suggestion on a new path forward for the mess of things 
between (v)fork+exec from Victor is over in 
https://bugs.python.org/issue42736#msg383869

TL;DR creating a subprocess.Preexec() recording object with specific interfaces 
for things that can be done, an instance of which gets passed in and the 
recorded actions are done as appropriate.

--
versions: +Python 3.11 -Python 3.10

___
Python tracker 

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



[issue35391] threading.RLock exception handling while waiting

2021-08-28 Thread Irit Katriel


Irit Katriel  added the comment:

Have you reproduced the issue on 3.8?

I am unable to reproduce this on main (on a Mac). Adding Antoine since I think 
he fixed a few issues in this area.

--
nosy: +iritkatriel, pitrou

___
Python tracker 

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



[issue36258] Incorrect docstring of the ssl module

2021-08-28 Thread Irit Katriel


Change by Irit Katriel :


--
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, Python 3.4, Python 
3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue24388] Python readline module crashes in history_get on FreeBSD with libedit

2021-08-28 Thread Diana


Change by Diana :


--
nosy: +DonnaDia
nosy_count: 3.0 -> 4.0
pull_requests: +26463
pull_request: https://github.com/python/cpython/pull/28018

___
Python tracker 

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



[issue24888] FileNotFoundException raised by subprocess.call

2021-08-28 Thread Diana


Change by Diana :


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

___
Python tracker 

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



[issue45036] turtle.onrelease() event doesn't get triggered sometimes

2021-08-28 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

(turtle module has no relation to IDLE other than also using tkinter.  The fact 
that turtledemo can be run from IDLE is incidental.)

3.10.0rc installed on Win 10.  I first clicked randomly and never saw a missing 
'release'.  I noticed that the turtle occasionally jumped to where I clicked, 
with 'start n' being printed.  I realized that I must have moved the mouse at 
least a pixel between click and release, triggering a move event.

I then did multiple click-drag-releases.  I am not sure if I ever saw a missing 
'release', but sometimes saw an extra 'start' as I released, especially when 
releasing while moving the mouse.  EP's comment explains this.  A subsequent 
click and drag prints no 'start' (which really means 'pen down') because the 
pen was already down.

I see two possible issues:

1. https://docs.python.org/3.9/library/turtle.html#using-events talks about 
events 'on this turtle'.  Should that mean clicks anywhere on the screen or 
just literally 'on' the turtle image.  If there were multiple turtles, should 
'anywhere on the screen' be 'on' all' of them?  The meaning of 'on' is 
turtle-specific, so this might be a turtle bug, depending on the intention.

2. The OS sends its graphics screen mouse move events corresponding to the 
physical mouse being moved.  There are available to tk.  ondrag is supposed to 
only notice those after button press (and by implication before button 
release).  In other words, while the button is down.  There should be not be 
drag events after the release event.  This might be a turtle bug, but could be 
in tk or even the OS mouse driver

--
assignee: terry.reedy -> 
components: +Library (Lib) -IDLE, Tkinter
versions: +Python 3.11

___
Python tracker 

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



[issue45040] [sqlite3] optimise transaction control functions

2021-08-28 Thread Erlend E. Aasland


New submission from Erlend E. Aasland :

pysqlite_connection_commit_impl(), pysqlite_connection_rollback_impl(), and 
begin_transaction() can be simplified:

sqlite3_finalize() will pass on any error set by sqlite3_step(). This implies 
that we only need to check the return value of sqlite3_prepare_v2() and 
sqlite3_finalize(), which implies that we can execute sqlite3_prepare_v2(), 
sqlite3_step() and sqlite3_finalize() in a row inside a begin/end threads 
wrapper. As a result, error handling will be greatly simplified.

Fewer lines of code, simpler error paths, increased readability, and increased 
code coverage.

diffstat: 2 files changed, 27 insertions(+), 62 deletions(-)

--
components: Extension Modules
messages: 400501
nosy: erlendaasland
priority: low
severity: normal
status: open
title: [sqlite3] optimise transaction control functions
type: enhancement
versions: Python 3.11

___
Python tracker 

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



[issue24388] Python readline module crashes in history_get on FreeBSD with libedit

2021-08-28 Thread Ned Deily


Change by Ned Deily :


--
pull_requests:  -26463

___
Python tracker 

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



[issue45040] [sqlite3] optimise transaction control functions

2021-08-28 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


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

___
Python tracker 

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



[issue45024] Cannot extend collections ABCs with protocol

2021-08-28 Thread Anup Parikh


Anup Parikh  added the comment:

Yeah, you got the gist of what I meant, though, I guess that was a confusing 
example since there are apparently protocols for Iterable. But not for many of 
the other collection ABCs such as Sequence, e.g., the following doesn't work:

from typing import Sequence, Protocol

class SequenceWithMethod(Sequence, Protocol):
def method(self) -> None: pass

In which case, anything that implements `method`, `__getitem__`, `__len__`, 
`__contains__`, `__iter__`, `__reversed__`, `index`,  and `count` would be 
considered a subtype of `SequenceWithMethod`

--
status: pending -> open

___
Python tracker 

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



[issue35391] threading.RLock exception handling while waiting

2021-08-28 Thread Antoine Pitrou


Antoine Pitrou  added the comment:

RLock is implemented in C nowadays so this problem doesn't occur anymore:
https://github.com/python/cpython/blob/main/Modules/_threadmodule.c#L436-L459

You can of course, however, import the pure Python RLock under the name 
"_PyRLock", which is still vulnerable to this issue:
https://github.com/python/cpython/blob/main/Lib/threading.py#L204-L206

--
type: crash -> behavior
versions:  -Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue35391] threading.RLock exception handling while waiting

2021-08-28 Thread Antoine Pitrou


Change by Antoine Pitrou :


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



[issue45037] theme-change.py for tkinter lib

2021-08-28 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Ayush, when responding by email, please delete the text you are responding to.  
After posting on the webpage, the quoted copy becomes redundant and noisy.
--

I suspect that whatever tkinter demo existed previously was dropped because no 
one wanted to maintain it and test it on all systems.  Perhaps it was known to 
be buggy, at least on some systems.  Or it was considered unnecessary given the 
available 3rd party resources.  These have expanded since and some are listed 
at the beginning of the tkinter doc.  Plus, there are numerous commented 
solutions on Stackoverflow.  We recently replaced the initial code example in 
the tkinter doc with something simpler.

I expect that there might be an issue on macOS.  Some years ago, I and another 
person fixed up the turtledemo framework and the approximately 20 demo files.  
I few months ago I discovered that macOS currently ignores background color 
settings for buttons.  There is a note about this deep in the tk docs but 
nothing that I know of in any tkinter docs.  If I spend time on tkinter, it 
would be to improve the reference material and have it include such needed 
details.

I ran the file and I don't consider it to be useful in relation to the problems 
people have with tkinter and ttk.  I think this issue and the PR should be 
closed.

--

___
Python tracker 

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



[issue45037] theme-change.py for tkinter lib

2021-08-28 Thread Terry J. Reedy


Change by Terry J. Reedy :


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

___
Python tracker 

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



[issue45037] theme-change.py for tkinter lib

2021-08-28 Thread Terry J. Reedy


Change by Terry J. Reedy :


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

___
Python tracker 

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



[issue45041] [sqlite3] simplify executescript()

2021-08-28 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


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

___
Python tracker 

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



[issue45041] [sqlite3] simplify executescript()

2021-08-28 Thread Erlend E. Aasland


New submission from Erlend E. Aasland :

See also bpo-45040

Since sqlite3_finalize() will pass on any error message set by sqlite3_step(), 
we can greatly simplify SQLite C API usage and error handling in 
sqlite3.Cursor.executescript(), thus reducing the number of times we 
save/restore thread state, and also simplifying error handling greatly.

We can also "inline" the commit before the main loop using the SQLite API 
directly, instead of calling self.commit()

Diffstat for the proposed patch:
1 file changed, 25 insertions(+), 42 deletions(-)

--
components: Extension Modules
messages: 400505
nosy: erlendaasland
priority: low
severity: normal
status: open
title: [sqlite3] simplify executescript()
type: enhancement
versions: Python 3.11

___
Python tracker 

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



[issue39817] CRITICAL: TypeError: cannot pickle 'generator'

2021-08-28 Thread Irit Katriel


Irit Katriel  added the comment:

Thank you Andrei.

--
nosy: +iritkatriel
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



[issue45020] Freeze all modules imported during startup.

2021-08-28 Thread Gregory Szorc


Gregory Szorc  added the comment:

When I investigated freezing the standard library for PyOxidizer, I ran into a 
rash of problems. The frozen importer doesn't behave like PathFinder. It 
doesn't (didn't?) set some common module-level attributes that are documented 
by the importer "specification" to be set and this failed a handful of tests 
and lead to runtime issues or breakage in 3rd party packages (such as random 
packages looking for a __file__ on a common stdlib module).

Also, when I last looked at the CPython source, the frozen importer performed a 
linear scan of its indexed C array performing strcmp() on each entry until it 
found what it was looking for. So adding hundreds of modules could result in 
sufficient overhead and justify using a more efficient lookup algorithm. 
(PyOxidizer uses Rust's HashMap to index modules by name.)

I fully support more aggressive usage of frozen modules in the standard library 
to speed up interpreter startup. However, if you want to ship this as enabled 
by default, from my experience with PyOxidizer, I highly recommend:

* Make sure you run unit tests against the frozen modules. If you don't do 
this, subtle differences in how the different importers behave will lead to 
problems.
* Shoring up the implementation of the frozen importer to make it better 
conform with the importer specification.
* Be prepared for people to complain about the loss of __file__. e.g. 
https://github.com/indygreg/PyOxidizer/issues/69 / 
https://pyoxidizer.readthedocs.io/en/stable/oxidized_importer_behavior_and_compliance.html?highlight=__file__#file-and-cached-module-attributes

--
nosy: +indygreg

___
Python tracker 

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



[issue45020] Freeze all modules imported during startup.

2021-08-28 Thread Gregory Szorc


Gregory Szorc  added the comment:

Oh, PyOxidizer also ran into more general issues with the frozen importer in 
that it broke various importlib APIs. e.g. because the frozen importer only 
supports bytecode, you can't use .__loader__.get_source() to obtain the source 
of a module. This makes tracebacks more opaque and breaks legitimate API 
consumers relying on these importlib interfaces.

The fundamental limitations with the frozen importer are why I implemented my 
own meta path importer (implemented in pure Rust), which is more fully 
featured, like the PathFinder importer that most people rely on today. That 
importer is available on PyPI (https://pypi.org/project/oxidized-importer/) and 
has its own API to facilitate PyOxidizer-like functionality 
(https://pyoxidizer.readthedocs.io/en/stable/oxidized_importer.html) if anyone 
wants to experiment with it.

--

___
Python tracker 

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



[issue45038] Bugs

2021-08-28 Thread Zachary Ware


Change by Zachary Ware :


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

___
Python tracker 

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



[issue45037] theme-change.py for tkinter lib

2021-08-28 Thread Zachary Ware


Zachary Ware  added the comment:

I agree with Serhiy and Terry that this is not the right place for this example 
and am closing the issue.

--
nosy: +zach.ware
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue45020] Freeze all modules imported during startup.

2021-08-28 Thread Guido van Rossum


Guido van Rossum  added the comment:

Gregor, thanks for sharing your experience!

I guess freezing the entire stdlib instead of just a smattering of modules 
(like we do here) exacerbated the problems in your case.

Builtin modules (such as sys or time) don't have a __file__ attribute either, 
and nobody has ever complained about this (that I know of). I wonder how far 
our backwards compatibility guarantee should go -- would this mean we cannot 
turn any stdlib module written in Python into one written in C (or Rust :-)?

It would be more serious if standard tests fail, but I haven't seen any 
evidence -- the tests all seem to pass for Eric's PR.

Now, if there are stdlib modules that reference their own __file__ and we want 
to freeze those, we should switch those to using ResourceReader or 
importlib.resources of course.

I agree that we should shore up the frozen importer -- probably in a separate 
PR though. (@Eric: do you think this is worth its own bpo issue?)

I also noticed the linear scan (and it's being called up to 5 times for modules 
that *aren't* frozen :-). strcmp is *very* fast (isn't it a compiler 
intrinsic?), but perhaps we should time it and if it seems a problem we could 
sort the array and do a form of bisection. (A slight problem is that there's an 
API to mutate the list by changing a pointer, so we may have to detect when the 
pointer has changed and recompute the size by doing a scan for the sentinel, 
once.)

Unfortunately I don't think we're yet in a world where we can accept any 
dependencies on Rust for CPython itself, so we would have to rewrite your 
example implementations in C if we wanted to use them.

--

___
Python tracker 

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



[issue36521] Consider removing docstrings from co_consts in code objects

2021-08-28 Thread Inada Naoki


Inada Naoki  added the comment:

> You'd just be moving the problem though -- the docstring would have be 
> included in the co_consts array of the surrounding code object instead of the 
> function object.

As far as I know, surrounding code objects (e.g. global, class body) will be 
removed right after they are executed.
So removing docstring by `func.__doc__ = None` can release memory for 
docstring, while we can not reduce startup time by this.

--

___
Python tracker 

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



[issue36521] Consider removing docstrings from co_consts in code objects

2021-08-28 Thread Inada Naoki


Inada Naoki  added the comment:

> This would actually make it harder to strip docstrings e.g. during 
> unmarshalling, since you don't know which constants refer to docstrings.

We can not strip class docstring anyway.

One idea to strip docstring during startup: Add new opcode only for storing 
__doc__.
We can use it for both of func and class. The opcode will store None if "remove 
docstring during startup" option is enabled. And surrounding code objects will 
be released after executing global/class body.

--

___
Python tracker 

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



[issue45020] Freeze all modules imported during startup.

2021-08-28 Thread Inada Naoki


Change by Inada Naoki :


--
nosy: +methane

___
Python tracker 

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



[issue34561] Replace list sorting merge_collapse()?

2021-08-28 Thread Tim Peters

Tim Peters  added the comment:

The merge order was mentioned on python-dev today, and a quick web searched 
turned up a revision of Vincent Jugé's "Adaptive Shivers Sort: An Alternative 
Sorting Algorithm" paper I hadn't seen before:

https://arxiv.org/pdf/1809.08411.pdf

Its "length-adaptive ShiversSort" variation sure _sounds_ like it was intended 
to address the issues we discussed here (some "bad" cases when very few runs 
are in play).

The analyses in that paper show that length-adaptive ShiversSort, and 
powersort, have the same asymptotic best and worst-case behaviors. Average 
case? Who knows? Hard to believe it could really be an issue, because even the 
worst cases are pretty darn good.

So length-adaptive ShiversSort is worth looking into. But, if someone has the 
energy to pursue it, I'd be happy, at this point, just to give plain old 
"adaptive ShiversSort" a try. The version of the paper linked to above even 
lists the precise changes needed to CPython's code to implement it (although a 
code review would ask for changes, most obviously that its "int x" is too 
narrow an integer type).

--

___
Python tracker 

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



[issue36521] Consider removing docstrings from co_consts in code objects

2021-08-28 Thread Guido van Rossum


Guido van Rossum  added the comment:

Why all the hating on docstrings? What have docstrings done wrong? I know 
there's the -OO flag that strips docstrings, but it doesn't work well and I 
think it was a mistake.

--

___
Python tracker 

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



[issue36521] Consider removing docstrings from co_consts in code objects

2021-08-28 Thread Inada Naoki


Inada Naoki  added the comment:

> Why all the hating on docstrings? What have docstrings done wrong? 

Oh, I don't hate docstrings. I just want to move it from code object to 
function object.
Remove docstring during unmarshal is your idea, not mine.

My main motivation is reducing code size. See this example.

```
class Foo:
def name(self):
"""Return my name"""
return self._name

def set_name(self, name):
"""Set my name"""
self._name = name

def age(self):
"""Return my age"""
return self._age

def set_age(self, age):
"""Set my age"""
self._age = age

>>> Foo.name.__code__.co_consts
('Return my name',)
>>> Foo.set_name.__code__.co_consts
('Set my name', None)
>>> Foo.age.__code__.co_consts
('Return my age',)
>>> Foo.set_age.__code__.co_consts
('Set my age', None)
```

If docstring is not in co_consts, all co_consts are empty tuple. The empty 
tuple is nearly zero-cost because its a singleton.

When comparing adding code.co_doc vs func.__doc__, "we can release old 
docstring" is a (small) pros. But it is no my main motivation.

Classes and modules don't use co_consts[0] anyway. So setting `func.__doc__` is 
better for consistency too.


> I know there's the -OO flag that strips docstrings, but it doesn't work well 
> and I think it was a mistake.

Some libraries (e.g. SQLAlchemy) have very huge docstrings. `-OO` can save 10% 
RAM.

I like an idea adding per-file flag for "don't remove docstring in -OO mode", 
because docstrings can be used runtime in some cases (e.g. docopt).
But it is out of scope of this issue.

--

___
Python tracker 

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



[issue36521] Consider removing docstrings from co_consts in code objects

2021-08-28 Thread Inada Naoki


Inada Naoki  added the comment:

> If docstring is not in co_consts, all co_consts are empty tuple. The empty 
> tuple is nearly zero-cost because its a singleton.

My wrong. Two setters will have `(None,)` tuple. But such tuple can be merged 
at compile time for now. And "common const" [1] approach will make them empty 
tuple.

[1] https://github.com/iritkatriel/cpython/pull/27

--

___
Python tracker 

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



[issue36521] Consider removing docstrings from co_consts in code objects

2021-08-28 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

If we are going to move docstring out of co_consts, I would make it a code 
object attribute rather than argument of MAKE_FUNCTION. It saves time on 
function creation.

Most functions do not change docstring after creation. It is the same as code 
docstring, so it consumes zero memory.

--

___
Python tracker 

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