[issue45382] platform() is not able to detect windows 11

2022-03-28 Thread Tim Golden


Tim Golden  added the comment:

> I don't see why the wmi module ( https://pypi.org/project/WMI/ ) can't be 
> used instead to get the information

Well I can speak here as the author of that module and as an (occasional) core 
developer. The wmi module stands on the shoulderes of the pywin32 
win32com.client code -- which is an _enormous_ dependency to bring into Python. 
(And which no-one would realistically agree to...)

--

___
Python tracker 

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



[issue47128] Enhance Argument Clinic's NoneType return converter to give `void`

2022-03-28 Thread Oleg Iarygin


Oleg Iarygin  added the comment:

Actually, you're right. For now, PyErr_Occurred is a GIL lock plus a memory 
access. While the access is cheap because of a L1 cache hit, the GIL takes its 
toll in a hot path.

So I'm closing the PR until GIL removal is done so no performance penalty will 
be imposed.

I could use _PyErr_Occurred because "Currently Argument Clinic is considered 
internal-only for CPython", but it requires extra modifications of the clinic 
that is undesirable.

--

___
Python tracker 

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



[issue45618] Documentation builds fail with Sphinx 3.2.1

2022-03-28 Thread Maciej Olko


Maciej Olko  added the comment:

> This really should be handled in a new issue since the original fixes for all 
> affected releases are already in the field.

Sorry, I got suggested too much with expected fix which is common for both of 
those issues. Shall I create a new issue?

> Moreover, we should be a bit careful about bumping the required Sphinx 
> version for older releases as this has caused problems for downstream 
> distributors of Python in the past. Can't we just pin the Jinja2 version for 
> current releases?

Didn't know about the problems for distributors. Definitely just pinning Jinja2 
is enough.

--

___
Python tracker 

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



[issue47138] Bump Sphinx to fix docs build

2022-03-28 Thread Hugo van Kemenade


New submission from Hugo van Kemenade :

The docs build on GitHub Actions is passing on `main` but has started failing 
for the `3.7` - `3.10` branches:

```
Missing the required blurb or sphinx-build tools.
Please run 'make venv' to install local copies.

make[1]: *** [Makefile:50: build] Error 1
```

https://github.com/python/cpython/actions/workflows/doc.yml
https://github.com/python/cpython/runs/5714593700?check_suite_focus=true

This is because the `PATH=./venv/bin:$PATH sphinx-build --version` check is 
failing:

```
/home/runner/work/cpython/cpython/Doc/venv/lib/python3.10/site-packages/sphinx/util/docutils.py:45:
 DeprecationWarning: distutils Version classes are deprecated. Use 
packaging.version instead.
  __version_info__ = tuple(LooseVersion(docutils.__version__).version)
Traceback (most recent call last):
  File "/home/runner/work/cpython/cpython/Doc/./venv/bin/sphinx-build", line 5, 
in 
from sphinx.cmd.build import main
  File 
"/home/runner/work/cpython/cpython/Doc/venv/lib/python3.10/site-packages/sphinx/cmd/build.py",
 line 25, in 
from sphinx.application import Sphinx
  File 
"/home/runner/work/cpython/cpython/Doc/venv/lib/python3.10/site-packages/sphinx/application.py",
 line 42, in 
from sphinx.registry import SphinxComponentRegistry
  File 
"/home/runner/work/cpython/cpython/Doc/venv/lib/python3.10/site-packages/sphinx/registry.py",
 line 24, in 
from sphinx.builders import Builder
  File 
"/home/runner/work/cpython/cpython/Doc/venv/lib/python3.10/site-packages/sphinx/builders/__init__.py",
 line 26, in 
from sphinx.util import import_object, logging, rst, progress_message, 
status_iterator
  File 
"/home/runner/work/cpython/cpython/Doc/venv/lib/python3.10/site-packages/sphinx/util/rst.py",
 line 22, in 
from jinja2 import environmentfilter
ImportError: cannot import name 'environmentfilter' from 'jinja2' 
(/home/runner/work/cpython/cpython/Doc/venv/lib/python3.10/site-packages/jinja2/__init__.py)
```

This is because `3.10` and `3.9` are still using old versions of Sphinx (3.2.1 
and 2.4.4 respectively) which is incompatible with the newest Jinja2:

https://github.com/pallets/jinja/issues/1630

`main` is using a newer Sphinx (4.2.0), so it passes.

Bumping to Sphinx 4.5.0 will fix both `3.9` and `3.10`. `3.7` and `3.8` are 
affected too. We can bump `main` to use `4.5.0` as well.

--
assignee: docs@python
components: Documentation
messages: 416149
nosy: docs@python, hugovk
priority: normal
severity: normal
status: open
title: Bump Sphinx to fix docs build
versions: Python 3.10, Python 3.11, 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



[issue45618] Documentation builds fail with Sphinx 3.2.1

2022-03-28 Thread Hugo van Kemenade


Hugo van Kemenade  added the comment:

> > This really should be handled in a new issue since the original fixes for 
> > all affected releases are already in the field.

> Sorry, I got suggested too much with expected fix which is common for both of 
> those issues. Shall I create a new issue?

I created https://bugs.python.org/issue47138, let's continue there.

--
nosy: +hugovk

___
Python tracker 

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



[issue47138] Bump Sphinx or pin Jinja2 to fix docs build

2022-03-28 Thread Hugo van Kemenade


Hugo van Kemenade  added the comment:

re: https://bugs.python.org/issue45618#msg416017

Maciej Olko, please could you update these PRs to keep the Sphinx version the 
same and only pin Jinja2 to match?

3.7: https://github.com/python/cpython/pull/32109
3.8: https://github.com/python/cpython/pull/32111

I guess update them to use this bpo too. Thanks!

--
title: Bump Sphinx to fix docs build -> Bump Sphinx or pin Jinja2 to fix docs 
build

___
Python tracker 

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



[issue47070] Improve performance of array_inplace_repeat

2022-03-28 Thread Dennis Sweeney


Dennis Sweeney  added the comment:


New changeset 850687df47b03e98c1433e6e70e71a8921eb4454 by Pieter Eendebak in 
branch 'main':
bpo-47070: Add _PyBytes_Repeat() (GH-31999)
https://github.com/python/cpython/commit/850687df47b03e98c1433e6e70e71a8921eb4454


--

___
Python tracker 

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



[issue37430] [doc] range is not a built-in function

2022-03-28 Thread Stanley


Stanley  added the comment:

Terry, how do you think the example/paragraph should be improved? I notice that 
the previous paragraphs talk about continue/break/else, so were you looking for 
some new example with all those? And I think the indexing's been fixed by now, 
but a clickable link to the range() documentation 
(https://docs.python.org/3/library/stdtypes.html#range) might still be a good 
idea just for convenience.

--
nosy: +slateny

___
Python tracker 

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



[issue46712] Share global string identifiers in deepfreeze

2022-03-28 Thread Kumar Aditya


Change by Kumar Aditya :


--
pull_requests: +30230
pull_request: https://github.com/python/cpython/pull/32152

___
Python tracker 

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



[issue47139] pthread_sigmask needs SIG_BLOCK behaviour explaination

2022-03-28 Thread Richard Purdie


New submission from Richard Purdie :

I've been struggling to get signal.pthread_sigmask to do what I expected it to 
do from the documentation. Having looked at the core python code handling 
signals I now (think?!) I understand what is happening. It might be possible 
for python to improve the behaviour, or it might just be something to document, 
I'm not sure but I though I'd mention it.

I'd added pthread_sigmask(SIG_BLOCK, (SIGTERM,)) and 
pthread_sigmask(SIG_UNBLOCK, (SIGTERM,)) calls around a critical section I 
wanted to protect from the SIGTERM signal. I was still seeing SIGTERM inside 
that section. Using SIGMASK to restore the mask instead of SIG_UNBLOCK behaves 
the same.

What I hadn't realised is that firstly python defers signals to a convenient 
point and secondly that signals are processed in the main thread regardless of 
the thread they arrived in. This means that I can see SIGTERM arrive in my 
critical section as one of my other threads created in the background by the 
core python libs helpfully handles it.  This makes SIG_BLOCK rather ineffective 
in any threaded code.

To work around it, I can add my own handlers and have them track whether a 
signal arrived, then handle any signals after my critical section by re-raising 
them. It is possible python itself could defer processing signals masked with 
SIG_BLOCK until they're unblocked. Alternatively, a note in the documentation 
warning of the pitfalls here might be helpful to save someone else from 
wondering what is going on!

--
components: Interpreter Core
messages: 416154
nosy: rpurdie
priority: normal
severity: normal
status: open
title: pthread_sigmask needs SIG_BLOCK behaviour explaination
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



[issue26120] pydoc: move __future__ imports out of the DATA block

2022-03-28 Thread Irit Katriel


Irit Katriel  added the comment:

That's a good point. I see that the __future__ imports appear in the dir() of 
the module, and indeed they are imported with 'from m import *'. 

But I wonder if that is actually a bug. If you try this:


% cat x.py

from __future__ import annotations

% cat y.py
from x import *

print(dir())

class D:
def f(self, a: D):
return 42

% ./python.exe y.py
['__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', 
'__loader__', '__name__', '__package__', '__spec__', 'annotations']
Traceback (most recent call last):
  File "/Users/iritkatriel/src/cpython-654/y.py", line 5, in 
class D:

  File "/Users/iritkatriel/src/cpython-654/y.py", line 6, in D
def f(self, a: D):
   ^
NameError: name 'D' is not defined
--


but if you add "from __future__ import annotations" at the top of y.py, then it 
does run.

So perhaps the future imports should be excluded by "from m import *"?

--

___
Python tracker 

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



[issue47140] configure --enable-optimizations with clang *12* fails to detect llvm-profdata

2022-03-28 Thread Ofek Shilon


New submission from Ofek Shilon :

Working on 3/228/2022 github trunk in Ubuntu20. If I use the shipped clang10 :
$ ./configure --enable-optimizations
succeeds. If however I -
$ export CC=clang-12
`configure` starts to fail with symptoms identical to 
https://bugs.python.org/issue36002:

checking for --enable-optimizations... yes
checking for --with-lto... no
checking for -llvm-profdata... no
configure: error: llvm-profdata is required for a --enable-optimizations build 
but could not be found.

Manually setting LLVM_PROFDATA is still a valid workaround.

--
components: Build
messages: 416156
nosy: ofekshilon
priority: normal
severity: normal
status: open
title: configure --enable-optimizations with clang *12* fails to detect 
llvm-profdata
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



[issue47138] Bump Sphinx or pin Jinja2 to fix docs build

2022-03-28 Thread Maciej Olko


Change by Maciej Olko :


--
keywords: +patch
nosy: +Maciej Olko
nosy_count: 2.0 -> 3.0
pull_requests: +30231
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/32111

___
Python tracker 

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



[issue47138] Bump Sphinx or pin Jinja2 to fix docs build

2022-03-28 Thread Maciej Olko


Change by Maciej Olko :


--
pull_requests: +30232
pull_request: https://github.com/python/cpython/pull/32109

___
Python tracker 

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



[issue47115] Documentation inconsistency with the stable ABI

2022-03-28 Thread Petr Viktorin


Petr Viktorin  added the comment:

Thanks for the report! You're right that this is misleading. I'll clarify the 
docs for this and other structs.

- struct PyTypeObject is part if the limited API.
- its fields and size are not part of the API or stable ABI.

--

___
Python tracker 

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



[issue47138] Bump Sphinx or pin Jinja2 to fix docs build

2022-03-28 Thread Maciej Olko


Maciej Olko  added the comment:

I've update both PRs to contain the pin only.

--

___
Python tracker 

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



[issue45953] Statically allocate interpreter states as much as possible.

2022-03-28 Thread Julien Palard


Julien Palard  added the comment:

Since 
https://github.com/python/cpython/commit/121f1f893a39d0b58d3d2b5597505c154ecaac2a,
 `sys.getrefcount(1)` is surprising:

>>> __import__("sys").getrefcount(1)
100210

Should sys.getrefcount try to "fix" the value like by returning 
`PyREFCNT(object) % 9`? (But using a define to avoid the "magic, 
copy/pasted value").

--
nosy: +mdk

___
Python tracker 

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



[issue26120] pydoc: move __future__ imports out of the DATA block

2022-03-28 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I once proposed to exclude modules from the star import by default, but this 
proposition was rejected. You can try, maybe your proposition will be more 
acceptable.

--

___
Python tracker 

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



[issue45953] Statically allocate interpreter states as much as possible.

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

> Should sys.getrefcount try to "fix" the value (...)

https://peps.python.org/pep-0683/ would make it possible. Right now, I don't 
think that it's possible.

Right now, a refcount of 100210 can be a real value, or it can be an 
immortal object.

--

___
Python tracker 

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



[issue47137] MemoryError

2022-03-28 Thread Eric V. Smith


Eric V. Smith  added the comment:

A simpler reproducer is:
codeop.compile_command('[' * 100)

Verified I get MemoryError on cygwin PYthon 3.8.12. A length of 99 does not 
show a problem.

On Windows 3.11.0a5+, I get:

>>> codeop.compile_command('[' * 201)
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\home\eric\local\python\cpython\Lib\codeop.py", line 107, in 
compile_command
return _maybe_compile(_compile, source, filename, symbol)
   ^^
  File "C:\home\eric\local\python\cpython\Lib\codeop.py", line 70, in 
_maybe_compile
compiler(source + "\n", filename, symbol)
^
  File "C:\home\eric\local\python\cpython\Lib\codeop.py", line 86, in _compile
return compile(source, filename, symbol, PyCF_DONT_IMPLY_DEDENT | 
PyCF_ALLOW_INCOMPLETE_INPUT)
   
^^^
  File "", line 1


[

^
SyntaxError: too many nested parentheses

A length of 200 seems to work correctly.

So it looks like this was fixed somewhere along the line, I'm guessing with the 
PEG parser. I suspect backporting the fix to older versions won't be possible.

--
nosy: +eric.smith

___
Python tracker 

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



[issue47141] EmailMessage may lack Mime-Version

2022-03-28 Thread Vlastimil Zíma

New submission from Vlastimil Zíma :

When an `EmailMessage` is created without setting its content, it may lack the 
`MIME-Version` header. I encountered this behavior when creating a S/MIME 
signed message, but I believe it applies to any `EmailMessage` in general.

Example:


from email.message import EmailMessage

nested_message = EmailMessage()
nested_message.set_content("Gazpacho!")

env = EmailMessage()
env.add_header("Content-Type", "multipart/signed", 
protocol="application/pkcs7-signature", micalg='sha-256')
env.preamble = "This is an S/MIME signed message"
env.attach(nested_message)
print(str(env))


This results in a message with no `MIME-Version` header


Content-Type: multipart/signed; protocol="application/pkcs7-signature";
 micalg="sha-256"; boundary="===4414940364499332856=="

This is an S/MIME signed message
--===4414940364499332856==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0

Gazpacho!

--===4414940364499332856==--


which violates section 4 of RFC 2045, see 
https://datatracker.ietf.org/doc/html/rfc2045#section-4


> Messages composed in accordance with this document MUST include such
   a header field, with the following verbatim text:

 MIME-Version: 1.0


and the section doesn't seem to be obsoleted by newer MIME related RFCs.

It's not clear why the `EmailMessage` shouldn't have the `MIME-Version` header 
defined in all cases, since it should represent the email message. I suggest to 
set the `MIME-version` header on `__init__` the same way `MIMEBase` does.

--
components: email
messages: 416163
nosy: Vlastimil.Zíma, barry, r.david.murray
priority: normal
severity: normal
status: open
title: EmailMessage may lack Mime-Version
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



[issue47142] Document importlib.resources.abc.Traversable

2022-03-28 Thread Petr Viktorin

New submission from Petr Viktorin :

importlib.resources.files is documented [0] as returning 
importlib.resources.abc.Traversable, which is an undocumented class (dead link) 
now. It should be documented.
The [source] has helpful docstrings, but is missing some details. I'd like to 
know these before writing some docs:

- Can the argument to `joinpath` contain path separators?
- Are the methods expected to raise specific exception types (e.g. if a 
resource is missing, or you call iterdir on a “file”)? This seems quite 
important for people who implement the protocol.


[0]: 
https://docs.python.org/dev/library/importlib.resources.html#importlib.resources.files
[source]: 
https://github.com/python/cpython/blob/main/Lib/importlib/resources/abc.py#L49

--
assignee: docs@python
components: Documentation
messages: 416164
nosy: docs@python, jaraco, petr.viktorin
priority: normal
severity: normal
status: open
title: Document importlib.resources.abc.Traversable

___
Python tracker 

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



[issue47124] explore hashlib use of the Apple CryptoKit macOS

2022-03-28 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

SecDigestTransformCreate() is probably a relevant API to look into, this seems 
to be supported from 10.7 until now.

A major disadvantage for us of this API is that it is a CoreFoundation API and 
because of that is problematic in pre-forking scenario's (that is, call in a 
child proces that's the result of fork-without-exec) because most if not all 
CoreFoundation types are not safe to use in these scenario's.

Apple also has an older crypto API, but that has been deprecated for a long 
time and should not be used.

--

___
Python tracker 

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



[issue47142] Document importlib.resources.abc.Traversable

2022-03-28 Thread Jason R. Coombs


Change by Jason R. Coombs :


--
assignee: docs@python -> jaraco

___
Python tracker 

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



[issue47137] MemoryError

2022-03-28 Thread qiu


qiu <1425166...@qq.com> added the comment:

y

--

___
Python tracker 

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



[issue47138] Bump Sphinx or pin Jinja2 to fix docs build

2022-03-28 Thread Ned Deily


Ned Deily  added the comment:

Thank you both for addressing this. The main reason for minimizing changes to 
the docs build chain for brances in bugfix or security-fix-only phases is that 
many distributors of Python also release the Python docs as a package and they 
do not necessarily rely on using our fairly-recent venv step in the Docs 
Makefile. In particular, they want to use the versions of Sphinx et al that 
they release as packages. If we change the required versions for these 
mid-stream, they not only have to update the docs themselves but have to go 
through the process of updating the other packages (like Sphinx) which may have 
other consequences. This can also impact our own on-line doc building process. 
(Version updates for a new Python feature release prior to its entering beta 
phase are not a problem.) So it is best to do the minimal amount of version 
updating for releases in the field, preferably none (as in pinning existing 
versions). In that spirit, we should also just pin the Jinja2 version for 3.10
  and 3.9.

--
nosy: +ned.deily

___
Python tracker 

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



[issue47143] Add functools.copy_class() which updates closures

2022-03-28 Thread STINNER Victor


New submission from STINNER Victor :

Class decorarators of attrs and stdlib dataclasses modules have to copy a class 
to *add* slots:

* old fixed attrs issue: https://github.com/python-attrs/attrs/issues/102
* attrs issue with Python 3.11: https://github.com/python-attrs/attrs/issues/907
* dataclasses issues with slots=True: https://bugs.python.org/issue46404


In the common case, copying a class is trivial:

cls2 = type(cls)(cls.__name__, cls.__bases__, cls.__dict__)

Full dummy example just to change a class name without touching the original 
class (create a copy with a different name):
---
class MyClass:
def hello(self):
print("Hello", self.__class__)

def copy_class(cls, new_name):
cls_dict = cls.__dict__.copy()
# hack the dict to modify the class copy
return type(cls)(new_name, cls.__bases__, cls_dict)

MyClass2 = copy_class(MyClass, "MyClass2")
MyClass2().hello()
---

Output:
---
Hello 
---


The problem is when a class uses a closure ("__class__" here):
---
class MyClass:
def who_am_i(self):
cls = __class__
print(cls)
if cls is not self.__class__:
raise Exception(f"closure lies: __class__={cls} {self.__class__=}")

def copy_class(cls, new_name):
cls_dict = cls.__dict__.copy()
# hack the dict to modify the class copy
return type(cls)(new_name, cls.__bases__, cls_dict)

MyClass().who_am_i()
MyClass2 = copy_class(MyClass, "MyClass2")
MyClass2().who_am_i()
---

Output:
---


Traceback (most recent call last):
  ...
Exception: closure lies: __class__= 
self.__class__=
---


The attrs project uses the following complicated code to workaround this issue 
(to "update closures"):
---

# The following is a fix for
# .  On Python 3,
# if a method mentions `__class__` or uses the no-arg super(), the
# compiler will bake a reference to the class in the method itself
# as `method.__closure__`.  Since we replace the class with a
# clone, we rewrite these references so it keeps working.
for item in cls.__dict__.values():
if isinstance(item, (classmethod, staticmethod)):
# Class- and staticmethods hide their functions inside.
# These might need to be rewritten as well.
closure_cells = getattr(item.__func__, "__closure__", None)
elif isinstance(item, property):
# Workaround for property `super()` shortcut (PY3-only).
# There is no universal way for other descriptors.
closure_cells = getattr(item.fget, "__closure__", None)
else:
closure_cells = getattr(item, "__closure__", None)

if not closure_cells:  # Catch None or the empty list.
continue
for cell in closure_cells:
try:
match = cell.cell_contents is self._cls
except ValueError:  # ValueError: Cell is empty
pass
else:
if match:
set_closure_cell(cell, cls)
---
source: 
https://github.com/python-attrs/attrs/blob/5c040f30e3e4b3c9c0f27c8ac6ff13d604c1818c/src/attr/_make.py#L886

The implementation of the set_closure_cell() function is really complicate 
since cells were mutable before Python 3.10:
https://github.com/python-attrs/attrs/blob/5c040f30e3e4b3c9c0f27c8ac6ff13d604c1818c/src/attr/_compat.py#L203-L305


I propose to add a new functools.copy_class() function which copy a class and 
update the closures: end of the _create_slots_class() function:
---
cls = type(self._cls)(...)
for item in cls.__dict__.values():
... # update closures
return cls
---


The alternative is not to add a function to copy a class, just only to "update 
closures", but IMO such API would be more error prone.


I would like to implement this function, but first I would like to dicuss if it 
makes sense to add such function and check if it's the right abstraction.

--
components: Library (Lib)
messages: 416168
nosy: eric.smith, petr.viktorin, rhettinger, serhiy.storchaka, vstinner
priority: normal
severity: normal
status: open
title: Add functools.copy_class() which updates closures
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



[issue46404] RFE: @dataclasses.dataclass(slots=True) doesn't support methods using closures

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

I changed the issue title to focus this issue on enhance dataclasses to support 
@dataclasses.dataclass(slots=True) on methods using closures: it would be a new 
Python 3.11 feature.


I created https://bugs.python.org/issue47143 "Add functools.copy_class() which 
updates closures".

--
nosy: +vstinner
title: 3.11a4: a small attrs regression -> RFE: 
@dataclasses.dataclass(slots=True) doesn't support methods using closures
type: behavior -> enhancement

___
Python tracker 

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



[issue45618] Documentation builds fail with Sphinx 3.2.1

2022-03-28 Thread Ned Deily


Change by Ned Deily :


--
pull_requests:  -30186

___
Python tracker 

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



[issue45618] Documentation builds fail with Sphinx 3.2.1

2022-03-28 Thread Ned Deily


Change by Ned Deily :


--
pull_requests:  -30194

___
Python tracker 

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



[issue45618] Documentation builds fail with Sphinx 3.2.1

2022-03-28 Thread Ned Deily


Change by Ned Deily :


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



[issue47143] Add functools.copy_class() which updates closures

2022-03-28 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

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



[issue47124] explore hashlib use of the Apple CryptoKit macOS

2022-03-28 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

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



[issue45953] Statically allocate interpreter states as much as possible.

2022-03-28 Thread Guido van Rossum

Guido van Rossum  added the comment:

Please don’t try to “fix” anything. The value is only useful if you
understand the implementation. It should map straightforwardly to what’s in
memory.

On Mon, Mar 28, 2022 at 05:16 STINNER Victor  wrote:

>
> STINNER Victor  added the comment:
>
> > Should sys.getrefcount try to "fix" the value (...)
>
> https://peps.python.org/pep-0683/ would make it possible. Right now, I
> don't think that it's possible.
>
> Right now, a refcount of 100210 can be a real value, or it can be an
> immortal object.
>
> --
>
> ___
> Python tracker 
> 
> ___
>
-- 
--Guido (mobile)

--

___
Python tracker 

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



[issue47138] Bump Sphinx or pin Jinja2 to fix docs build

2022-03-28 Thread Hugo van Kemenade


Change by Hugo van Kemenade :


--
pull_requests: +30235
pull_request: https://github.com/python/cpython/pull/32154

___
Python tracker 

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



[issue47138] Bump Sphinx or pin Jinja2 to fix docs build

2022-03-28 Thread Hugo van Kemenade


Change by Hugo van Kemenade :


--
pull_requests: +30234
pull_request: https://github.com/python/cpython/pull/32153

___
Python tracker 

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



[issue47138] Pin Jinja2 to fix docs build

2022-03-28 Thread Hugo van Kemenade


Hugo van Kemenade  added the comment:

I cherry picked Maciej's 3.8 commit into 3.9 and 3.10 PRs:

3.9: https://github.com/python/cpython/pull/32153
3.10: https://github.com/python/cpython/pull/32154

And marking this issue as not relevant to 3.11; instead I bumped the Sphinx 
version in bpo-47126 / gh-32124 as it's directly relevant there.

Thanks!

--
title: Bump Sphinx or pin Jinja2 to fix docs build -> Pin Jinja2 to fix docs 
build
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



[issue47144] Allow setting __classcell__

2022-03-28 Thread Douglas Raillard


New submission from Douglas Raillard :

The cell object __classcell__ currently cannot be set by code invoked by 
metaclass.__new__. Attempts to do so will be caught by builtin___build_class__ 
in bltimodule.c:

} else {
const char *msg =
"__class__ set to %.200R defining %.200R as %.200R";
PyErr_Format(PyExc_TypeError, msg, cell_cls, name, cls);
}

This is unfortunate as there is a use-case for such trickery: if the method of 
a class A are only used to be grafted onto another class B (monkey patching), 
A.__classcell__ should be set to B so that super() works as expected.

This can be useful in contexts where e.g. A.__new__ returns instances of B. B 
is not necessarily something under direct user control (it can be dynamically 
created by inheriting from a "template"), so A would be a better place for 
users to define custom method.

--
components: Interpreter Core
messages: 416172
nosy: douglas-raillard-arm
priority: normal
severity: normal
status: open
title: Allow setting __classcell__
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



[issue47144] Allow setting __classcell__

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

> This is unfortunate as there is a use-case for such trickery: if the method 
> of a class A are only used to be grafted onto another class B (monkey 
> patching), A.__classcell__ should be set to B so that super() works as 
> expected.

Would you elaborate your use case?

Would bpo-47143 "Add functools.copy_class() which updates closures" solve your 
use case?

--
nosy: +vstinner

___
Python tracker 

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



[issue46404] RFE: @dataclasses.dataclass(slots=True) doesn't support methods using closures

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-45520: "Frozen dataclass deep copy doesn't work with __slots__" 
which is related but a different issue.

--

___
Python tracker 

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



[issue47143] Add functools.copy_class() which updates closures

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

It seems like the copy module doesn't support copying a class. 
copy.deepcopy(cls) doesn't copy a class but returns its argument, the class 
unchanged.

--

___
Python tracker 

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



[issue47143] Add functools.copy_class() which updates closures

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

The pickle module doesn't copy a type but gets it from its module. The Python 
implementation is pickle._Pickler.save_type() which calls 
pickle._Pickler.save_global().

The cloudpickle module doesn't copy types neither: same behavior than pickle.

Example:
---
import pickle
import pickletools

class A:
pass

data = pickle.dumps(A)
pickletools.dis(data)
---

Output:
---
0: \x80 PROTO  4
2: \x95 FRAME  18
   11: \x8c SHORT_BINUNICODE '__main__'
   21: \x94 MEMOIZE(as 0)
   22: \x8c SHORT_BINUNICODE 'A'
   25: \x94 MEMOIZE(as 1)
   26: \x93 STACK_GLOBAL
   27: \x94 MEMOIZE(as 2)
   28: .STOP
highest protocol among opcodes = 4
---

In short, it's implemented as:

getattr(__import__('__main__'), 'A')

--

___
Python tracker 

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



[issue47143] Add functools.copy_class() which updates closures

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

pickle.dump(x) checks if x is a type since commit 
f048a8f6d79173cc1da1bf12c60ae06fea36762c (March 2002) of bpo-494904:

Pickler.save(): Fix for SF bug #494904: Cannot pickle a class with a
metaclass, reported by Dan Parisien.

+if issubclass(t, TypeType):
+self.save_global(object)
+return

Followed by a minor fix: commit 85ee491b3af3e1c124522249a52443b4d8c34c88 of 
bpo-502085:

Don't die when issubclass(t, TypeType) fails.


-if issubclass(t, TypeType):
+try:
+issc = issubclass(t, TypeType)
+except TypeError: # t is not a class
+issc = 0

copy.deepcopy(x) returns x if it's a type since commit 
11ade1ddc053dcec884e2431b55fb1c1727c65d7 (June 2002) of bpo-560794.

SF patch 560794 (Greg Chapman): deepcopy can't handle custom
metaclasses.

 try:
-copier = x.__deepcopy__
-except AttributeError:
+issc = issubclass(type(x), type)
+except TypeError:
+issc = 0
+if issc:
+y = _deepcopy_dispatch[type](x, memo)
+else:
 (...)

--

___
Python tracker 

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



[issue47143] Add functools.copy_class() which updates closures

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

More recent copy.copy() change: commit 5c1c3b4f197c57952760be37d77d73669284a607 
of bpo-11480:

Issue #11480: Fixed copy.copy to work with classes with custom metaclasses.

+try:
+issc = issubclass(cls, type)
+except TypeError: # cls is not a class
+issc = False
+if issc:
+# treat it as a regular class:
+return _copy_immutable(x)

--

___
Python tracker 

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



[issue47143] Add functools.copy_class() which updates closures

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

If I understand correctly, a cell content can be modified since Python 3.7: 
since commit 64505a1f6c0af4574e17e823b27ffe24eca44df5 of bpo-30486:

bpo-30486: Allow setting cell value (#1840)

Antoine Pitrou created bpo-30486 for cloudpickle:

"There are use cases for setting a cell value.  One such use case is for 
(un)pickling recursive closures (see heroic workaround here: 
https://github.com/cloudpipe/cloudpickle/pull/90/files#diff-d2a3618afedd4e124c532151eedbae09R74
 ).  Other use cases may include tinkering around and general education value."

--

___
Python tracker 

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



[issue47143] Add functools.copy_class() which updates closures

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

In the Python C API, PEP 384 added PyType_FromSpec(). There is also 
PyStructSequence_NewType(). PEP 3121 proposed PyType_Copy() but it was never 
implemented: see bpo-3760. But in C, closures are implemented using a module 
state, or previously using a global or static variable: cell objects are not 
used for types implemented in C.

--

___
Python tracker 

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



[issue47125] Explore hashlib use of the Windows Crypto API NG

2022-03-28 Thread Steve Dower


Steve Dower  added the comment:

Did a basic test (with timeit and a work-internal library I already have) and 
the native functionality is *slightly* faster than OpenSSL.

But I think it's worthwhile anyway, to help reduce our dependency on OpenSSL.

--

___
Python tracker 

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



[issue47145] Improve graphlib.TopologicalSort by removing the prepare step

2022-03-28 Thread Larry Hastings


New submission from Larry Hastings :

I've maintained my own topological sort class for a while now.  The API I came 
up with (or was it Tim and I?) was adopted for graphlib.TopologicalSort().  
Some of my method names are slightly different, but the APIs are so similar, I 
can do a little renaming and run Lib/test/test_graphlib using my 
implementation.  (For clarity I'm going to write the rest of this issue using 
the names from graphlib.)

Recently I made an improvement to my version: it no longer has the modal 
behavior where there's a "before prepare" phase where you add nodes and an 
"after prepare" phase where you can call get_ready and done.

Instead, in my new and improved version the graph is always maintained in a 
"ready" state.  You can call add, get_ready, and done in any order, as much as 
you like.  prepare doesn't do anything besides the cycle check--but read on!

This approach required tweaking some semantics behind the scenes.  My graph 
object now maintains an internal "dirty" flag.  It's set to True after any 
edges are added, and only gets cleared after checking for cycles.  prepare runs 
this cycle check, but get_ready *also* runs this cycle check.  (Though in both 
cases, only when the dirty flag is set, of course.)  In theory this means you 
no longer need the prepare call.  However, it's still useful, because you can 
call it to check for a CycleError.

So, on the one hand, this means that get_ready can throw a CycleError, which it 
never did before.  On the other hand, it won't throw for existing users of the 
library, because they never add edges after their prepare call.  So this 
semantic change shouldn't break existing users, assuming they're not misusing 
the existing API.

Another wrinkle: adding a dependency on a node that's already been handed out 
by get_ready (but hasn't been returned by done) is ignored.  Again, not 
something existing users of graphlib can do, so this shouldn't break code.

There's one final semantic change I made worth knowing about: when you return a 
node via done, the graph simply forgets about it.  This means you could add it 
a second time (!) and it could go for a complete ride through the graph again, 
wh!  This also means that when all nodes have been returned by done, the 
graph is essentially returned to its initial pristine state.  This too seems 
completely harmless, because with the existing library it's illegal to add 
nodes to a graph after calling prepare, so nobody's doing it, so it won't break 
any code.

I'm happy to contribute my version.  But I was lazy and didn't worry about 
speed or memory implementation; it's strewn with sets and things.  I figured I 
could always optimize it later.  But "later" could become "now" if we were 
interested in trying to merge this behavior into Python's graphlib.

Interested?

--
assignee: larry
components: Library (Lib)
messages: 416182
nosy: eric.smith, larry, pablogsal, tim.peters
priority: normal
severity: normal
stage: needs patch
status: open
title: Improve graphlib.TopologicalSort by removing the prepare step
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



[issue47143] Add functools.copy_class() which updates closures

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

The same problem exists at the function level: see bpo-39805: "Copying 
functions doesn't actually copy them".

For example, copy.deepcopy(func) returns func unchanged if it's a function.

Example:
---
import copy

def make_closure():
closure = []
def append(value):
closure.append(value)
return append, closure

func, closure = make_closure()
func(1)
func2 = copy.deepcopy(func)
func2(2)
print(func2 is func)
print(closure)
---

Output:
---
True
[1, 2]
---

--

___
Python tracker 

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



[issue47143] Add functools.copy_class() which updates closures

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

> * old fixed attrs issue: https://github.com/python-attrs/attrs/issues/102
> * attrs issue with Python 3.11: 
> https://github.com/python-attrs/attrs/issues/907
> * dataclasses issues with slots=True: https://bugs.python.org/issue46404

Similar bug without attrs nor dataclasses: bpo-29944 "Argumentless super() 
fails in classes constructed with type()".

--

___
Python tracker 

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



[issue29944] Argumentless super() fails in classes constructed with type()

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-47143 "Add functools.copy_class() which updates closures".

--
nosy: +vstinner

___
Python tracker 

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



[issue47143] Add functools.copy_class() which updates closures

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

See also the types.new_class() function:
https://docs.python.org/dev/library/types.html#types.new_class

Oh, I didn't know this function!

--

___
Python tracker 

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



[issue47144] Allow setting __classcell__

2022-03-28 Thread Douglas Raillard


Douglas Raillard  added the comment:

> Would bpo-47143 "Add functools.copy_class() which updates closures" solve 
> your use case?

This looks like a similar issue indeed. If I'm able to copy a class "cleanly" 
(as defined in this other thread), that may solve the problem (hard to tell 
precisely until trying it though, the devil is in the details).

> Would you elaborate your use case?

As you probably expect, it's a relatively tricky metaprogramming bit of code. 
It's implementing something akin to higher kinded types, similar in spirit to 
the following example where you can have e.g. containers that "know" the item 
type they contain:

class ContainerBase:
ITEM = None

@classmethod
def apply(cls, typ):
...


@classmethod
def empty_list(cls):
...
  
class List(ContainerBase):
pass

class ListOfInt(List.apply(int)):
pass

The goal is to allow "ListOfInt" to define custom methods if we want in its 
body.

"ListOfInt" cannot return instances of itself [1] so I'm trying to "cherry 
pick" its method and graft them onto the type that is actually instantiated.

[1] We e.g. want to create an empty list of the right type. "List" already 
provides the method for such factory, but it will not return an actual instance 
of ListOfInt, since it does not even know this class exists. What it will use 
is an internal type that it created using the "ITEM" class attribute in e.g. 
List.__init_subclass__, and that is what will get instantiated. This "internal 
class" could still be customized by ListOfInt to have some custom methods 
though, which is what I'm trying to achieve.

--

___
Python tracker 

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



[issue47144] Allow setting __classcell__

2022-03-28 Thread Douglas Raillard


Douglas Raillard  added the comment:

EDIT: empty_list() is a class method of List, not ContainerBase

--

___
Python tracker 

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



[issue47143] Add functools.copy_class() which updates closures

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

> If I understand correctly, a cell content can be modified since Python 3.7: 
> since commit 64505a1f6c0af4574e17e823b27ffe24eca44df5 of bpo-30486

Moreover, it's possible to create a cell object since Python 3.8, commit 
df8d2cde63c865446468351f8f648e1c7bd45109 of bpo-35911.

--
nosy: +pitrou

___
Python tracker 

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



[issue47143] Add functools.copy_class() which updates closures

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

bpo-32176 "Zero argument super is broken in 3.6 for methods with a hacked 
__class__ cell" added test_code.test_closure_injection() and fixed the 
CO_NOFREE flag in the code object constructor (types.CodeType).

--

___
Python tracker 

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



[issue14369] make function __closure__ writable

2022-03-28 Thread STINNER Victor


Change by STINNER Victor :


--
title: make __closure__ writable -> make function __closure__ writable

___
Python tracker 

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



[issue47143] Add functools.copy_class() which updates closures

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

> The same problem exists at the function level: see bpo-39805: "Copying 
> functions doesn't actually copy them".

See also bpo-14369 "make function __closure__ writable".

--

___
Python tracker 

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



[issue26120] pydoc: move __future__ imports out of the DATA block

2022-03-28 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Module objects are not shown in the help unless they are submodules of the 
specified module, even if they are imported with the star import. With this 
precedence I think it is okay to exclude the __future__ annotations as well.

--

___
Python tracker 

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



[issue47146] PR check "Check if generated files are up to date" failing intermittently

2022-03-28 Thread Eric Snow


New submission from Eric Snow :

The "Check if generated files are up to date" GitHub check for PRs has been 
failing recently.  It may also impact local usage of "make regen-all".

Example: https://github.com/python/cpython/runs/5719012664

This may be related to gh-32061.

--
assignee: eric.snow
components: Build
messages: 416193
nosy: Mark.Shannon, brandtbucher, eric.snow
priority: normal
severity: normal
stage: needs patch
status: open
title: PR check "Check if generated files are up to date" failing intermittently
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



[issue47138] Pin Jinja2 to fix docs build

2022-03-28 Thread Ned Deily


Ned Deily  added the comment:


New changeset 25f00bfb264a3197ac91c41cdec15036fd8401f1 by m-aciek in branch 
'3.7':
bpo-47138: Fix documentation build by pinning Jinja version to 3.0.3 (GH-32111)
https://github.com/python/cpython/commit/25f00bfb264a3197ac91c41cdec15036fd8401f1


--

___
Python tracker 

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



[issue47138] Pin Jinja2 to fix docs build

2022-03-28 Thread Ned Deily


Ned Deily  added the comment:


New changeset 9194a7b8990a0feec1209b1e5694df3bf42906d8 by Hugo van Kemenade in 
branch '3.10':
bpo-47138: Fix documentation build by pinning Jinja version to 3.0.3 (GH-32154)
https://github.com/python/cpython/commit/9194a7b8990a0feec1209b1e5694df3bf42906d8


--

___
Python tracker 

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



[issue47138] Pin Jinja2 to fix docs build

2022-03-28 Thread Ned Deily


Ned Deily  added the comment:


New changeset 25c40bd994aa0da75283c5efdd71ba26c734b67e by Hugo van Kemenade in 
branch '3.9':
bpo-47138: Fix documentation build by pinning Jinja version to 3.0.3 (GH-32153)
https://github.com/python/cpython/commit/25c40bd994aa0da75283c5efdd71ba26c734b67e


--

___
Python tracker 

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



[issue47138] Pin Jinja2 to fix docs build

2022-03-28 Thread Ned Deily


Ned Deily  added the comment:

Thanks, everyone! Merged for 3.10.5, 3.9.13, and 3.7.14. I'll leave the issue 
in pending state until merged for 3.8.14.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> pending

___
Python tracker 

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



[issue47147] Allow `return yield from`

2022-03-28 Thread Patrick Reader


New submission from Patrick Reader :

I would like to be able to use a `yield from` expression in a `return` 
statement without parentheses, as a small quality of life tweak, i.e.:

return yield from gen

instead of

return (yield from gen)

I think this makes sense, since `yield from` can be used on the right-hand-side 
of an assignment, which accepts any expression, and so should `return`.

Here is a medium-sized real-world example of where I'm using this, where it 
would be nice to allow `return yield from`: 
https://gist.github.com/pxeger/48f97484364bf0b43dee974a8f0f4265

--
components: Parser
messages: 416198
nosy: lys.nikolaou, pablogsal, pxeger
priority: normal
severity: normal
status: open
title: Allow `return yield from`
type: enhancement

___
Python tracker 

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



[issue47147] Allow `return yield from`

2022-03-28 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Please, submit an email to python-ideas or python-dev first as this need to be 
discussed in the mailing lists.

--

___
Python tracker 

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



[issue45100] Improve help() by making typing.overload() information accessible at runtime

2022-03-28 Thread Guido van Rossum


Change by Guido van Rossum :


--
nosy: +gvanrossum

___
Python tracker 

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



[issue44493] Missing terminated NUL in the length of sockaddr_un

2022-03-28 Thread miss-islington


Change by miss-islington :


--
pull_requests: +30236
pull_request: https://github.com/python/cpython/pull/32156

___
Python tracker 

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



[issue44493] Missing terminated NUL in the length of sockaddr_un

2022-03-28 Thread miss-islington


miss-islington  added the comment:


New changeset 5944807b09717d43bb017f700e8c451dd07199ed by Miss Islington (bot) 
in branch '3.10':
[3.10] bpo-44493: Add missing terminated NUL in sockaddr_un's length (GH-26866) 
(GH-32140)
https://github.com/python/cpython/commit/5944807b09717d43bb017f700e8c451dd07199ed


--

___
Python tracker 

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



[issue47146] PR check "Check if generated files are up to date" failing intermittently

2022-03-28 Thread Eric Snow


Eric Snow  added the comment:

There's probably something racy with make.

See: 
https://github.com/python/cpython/runs/5712538599?check_suite_focus=true#step:10:1147

--

___
Python tracker 

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



[issue28516] contextlib.ExitStack.__enter__ has trivial but undocumented behavior

2022-03-28 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:


New changeset 1e3132b1c3ebff8d28a6dd353bf217cb97c41e81 by Miss Islington (bot) 
in branch '3.9':
bpo-28516: document contextlib.ExitStack.__enter__ behavior (GH-31636) 
(GH-32145)
https://github.com/python/cpython/commit/1e3132b1c3ebff8d28a6dd353bf217cb97c41e81


--

___
Python tracker 

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



[issue43224] Add support for PEP 646

2022-03-28 Thread Matthew Rahtz


Change by Matthew Rahtz :


--
pull_requests: +30237
pull_request: https://github.com/python/cpython/pull/32159

___
Python tracker 

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



[issue4833] Explicit directories for zipfiles

2022-03-28 Thread Sam Ezeh


Change by Sam Ezeh :


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

___
Python tracker 

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



[issue4833] Explicit directories for zipfiles

2022-03-28 Thread Sam Ezeh


Sam Ezeh  added the comment:

I've submitted the above patch. I created the ZipFile.mkdir function, created 
the necessary tests and wrote the documentation.

I think it is ready for review.

--
Added file: https://bugs.python.org/file50705/sam_ezeh.patch

___
Python tracker 

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



[issue43818] Email does not apply policy to multipart messages with defects

2022-03-28 Thread Martin Dengler


Martin Dengler  added the comment:

Possible related to https://github.com/python/cpython/pull/32137 and 
https://bugs.python.org/issue43323

--

___
Python tracker 

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



[issue47147] Allow `return yield from`

2022-03-28 Thread Patrick Reader


Patrick Reader  added the comment:

Ok, will do, but what is the bar for a feature to need to go to the mailing 
lists first? I thought as this was a relatively minor one it wouldn't need to. 
Is it just because it's an actual syntax change?

--

___
Python tracker 

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



[issue47147] Allow `return yield from`

2022-03-28 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

In general, anything changing the python syntax needs to be discussed in the 
mailing lists and it may likely need a PEP as well, even if is minor. This is 
because this has consequences rippling the whole ecosystem, from IDEs to other 
parsers and this need to be discussed, and communicated in a better forum than 
this.

--

___
Python tracker 

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



[issue4833] Explicit directories for zipfiles

2022-03-28 Thread Ethan Furman


Change by Ethan Furman :


--
nosy: +ethan.furman
versions: +Python 3.11 -Python 3.4

___
Python tracker 

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



[issue44493] Missing terminated NUL in the length of sockaddr_un

2022-03-28 Thread Gregory P. Smith


Gregory P. Smith  added the comment:


New changeset dae09c2b819c2683ad870733451c050b59c3eb93 by Miss Islington (bot) 
in branch '3.9':
[3.9] bpo-44493: Add missing terminated NUL in sockaddr_un's length (GH-26866) 
(GH-32140) (GH-32156)
https://github.com/python/cpython/commit/dae09c2b819c2683ad870733451c050b59c3eb93


--

___
Python tracker 

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



[issue47138] Pin Jinja2 to fix docs build

2022-03-28 Thread Steve Dower


Change by Steve Dower :


--
nosy: +steve.dower
nosy_count: 4.0 -> 5.0
pull_requests: +30239
status: pending -> open
pull_request: https://github.com/python/cpython/pull/32161

___
Python tracker 

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



[issue45953] Statically allocate interpreter states as much as possible.

2022-03-28 Thread Julien Palard


Julien Palard  added the comment:

Hum, and why 9? I am probably missing something obvious but 1 should be 
enough to ensure the value never hits 0. Except for refcount bugs obviously, 
but I don't think this is the right reason?

--

___
Python tracker 

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



[issue47146] PR check "Check if generated files are up to date" failing intermittently

2022-03-28 Thread Eric Snow


Change by Eric Snow :


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

___
Python tracker 

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



[issue47138] Pin Jinja2 to fix docs build

2022-03-28 Thread Steve Dower


Steve Dower  added the comment:


New changeset 295114dcd32b3aad5453e5e15e9e1befa0e5ca01 by Steve Dower in branch 
'main':
bpo-47138: Ensure Windows docs build uses the same pinned version as other 
platforms (GH-32161)
https://github.com/python/cpython/commit/295114dcd32b3aad5453e5e15e9e1befa0e5ca01


--

___
Python tracker 

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



[issue45953] Statically allocate interpreter states as much as possible.

2022-03-28 Thread Guido van Rossum


Guido van Rossum  added the comment:

I used 9 in deepfreeze.py to signify "immortal object". It has been 
copied by others (small integers are essentially immortal too). I wasn't too 
sure that the refcount wouldn't go below zero if the interpreter is repeatedly 
finalized and reinitialized. Once we have official immortal objects (see PEP 
683) we should switch to that.

Since you seem to be challenging the value of 9, my question to you is, 
why do you care what the refcount of 1 is?

--

___
Python tracker 

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



[issue47146] PR check "Check if generated files are up to date" failing intermittently

2022-03-28 Thread Eric Snow


Eric Snow  added the comment:


New changeset 4c116f716bd1c174d6530b9a7a5ed3863927a109 by Eric Snow in branch 
'main':
bpo-47146: Eliminate a race between make regen-deepfreeze and make 
regen-global-objects. (gh-32162)
https://github.com/python/cpython/commit/4c116f716bd1c174d6530b9a7a5ed3863927a109


--

___
Python tracker 

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



[issue47138] Pin Jinja2 to fix docs build

2022-03-28 Thread Steve Dower


Change by Steve Dower :


--
pull_requests: +30241
stage: resolved -> patch review
pull_request: https://github.com/python/cpython/pull/32163

___
Python tracker 

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



[issue26120] pydoc: move __future__ imports out of the DATA block

2022-03-28 Thread Irit Katriel


Irit Katriel  added the comment:


New changeset 15ba8167d78f9e66bd5b07c4e5cbb0463460310a by Irit Katriel in 
branch 'main':
bpo-26120: make pydoc exclude __future__ imports from the data block of the 
module (GH-30888)
https://github.com/python/cpython/commit/15ba8167d78f9e66bd5b07c4e5cbb0463460310a


--

___
Python tracker 

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



[issue26120] pydoc: move __future__ imports out of the DATA block

2022-03-28 Thread Irit Katriel


Irit Katriel  added the comment:

Thank you, Serhiy!

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



[issue47146] PR check "Check if generated files are up to date" failing intermittently

2022-03-28 Thread Eric Snow


Eric Snow  added the comment:

Looks like that fixed it, per https://github.com/python/cpython/pull/32134.

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



[issue47137] MemoryError in codeop.compile_command

2022-03-28 Thread Eric V. Smith


Change by Eric V. Smith :


--
nosy: +pablogsal
title: MemoryError -> MemoryError in codeop.compile_command
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



[issue47129] Improve errors messages in f-string syntax errors

2022-03-28 Thread Eric V. Smith

Eric V. Smith  added the comment:


New changeset 7b44ade018cfe6f54002a3cee43e8aa415d4d635 by Maciej Górski in 
branch 'main':
bpo-47129: Add more informative messages to f-string syntax errors (32127)
https://github.com/python/cpython/commit/7b44ade018cfe6f54002a3cee43e8aa415d4d635


--

___
Python tracker 

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



[issue47129] Improve errors messages in f-string syntax errors

2022-03-28 Thread Eric V. Smith


Eric V. Smith  added the comment:

Thanks, @macgors!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type:  -> behavior

___
Python tracker 

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



[issue47129] Improve errors messages in f-string syntax errors

2022-03-28 Thread Maciej Górski

Maciej Górski  added the comment:

Thanks for helping me with my very first python contribution! @eric.smith 
@lys.nikolaou

--

___
Python tracker 

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



[issue27929] asyncio.AbstractEventLoop.sock_connect broken for AF_BLUETOOTH

2022-03-28 Thread Andrew Svetlov


Andrew Svetlov  added the comment:


New changeset 5c30388f3c586ba2f33e349e22e5949cb92de621 by Vincent Bernat in 
branch 'main':
bpo-27929: resolve names only for AF_INET/AF_INET6 with asyncio (GH-32131)
https://github.com/python/cpython/commit/5c30388f3c586ba2f33e349e22e5949cb92de621


--

___
Python tracker 

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



[issue27929] asyncio.AbstractEventLoop.sock_connect broken for AF_BLUETOOTH

2022-03-28 Thread miss-islington


Change by miss-islington :


--
pull_requests: +30243
pull_request: https://github.com/python/cpython/pull/32165

___
Python tracker 

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



[issue27929] asyncio.AbstractEventLoop.sock_connect broken for AF_BLUETOOTH

2022-03-28 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue47143] Add functools.copy_class() which updates closures

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

Note: Implementing a metaclass in Python is hard, it's easy to mess up with 
closures: see bpo-29270 "ctypes: fail to create a _ctypes._SimpleCData subclass 
using a closure like calling super() without arguments". type.__new__() is 
called twice on the same type dict, and the second call overrides the 
__classcell__ cell value.

--

___
Python tracker 

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



[issue27929] asyncio.AbstractEventLoop.sock_connect broken for AF_BLUETOOTH

2022-03-28 Thread miss-islington


miss-islington  added the comment:


New changeset f84fb55659079bbc99d4cd0441dc13ab07ac3dcf by Miss Islington (bot) 
in branch '3.9':
bpo-27929: resolve names only for AF_INET/AF_INET6 with asyncio (GH-32131)
https://github.com/python/cpython/commit/f84fb55659079bbc99d4cd0441dc13ab07ac3dcf


--

___
Python tracker 

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



[issue29270] ctypes: fail to create a _ctypes._SimpleCData subclass using a closure like calling super() without arguments

2022-03-28 Thread STINNER Victor


STINNER Victor  added the comment:

CreateSwappedType() is an helper function used by the _ctypes.PyCSimpleType 
type. Python script reproducing this ctypes bug:
---
class PyCSimpleType(type):
def __new__(cls, name, bases, dct):
print(f"PyCSimpleType: create {name} class")
cell = dct.get('__classcell__', None)
# type.__new__() sets __classcell__
x = super().__new__(cls, name, bases, dct)
if cell is not None:
print(f"PyCSimpleType: after first type.__new__() call: 
__classcell__={cell.cell_contents}")

name2 = name + "_Swapped"
dct2 = dict(dct, __qualname__=name2)
# Calling type.__new__() again with the same cell object overrides
# __classcell__
x.__ctype_be__ = super().__new__(cls, name2, bases, dct2)
if cell is not None:
print(f"PyCSimpleType: after second type.__new__() call: 
__classcell__={cell.cell_contents}")

return x

class BaseItem:
pass

class Item(BaseItem, metaclass=PyCSimpleType):
def get_class(self):
# get '__class__' to create a closure
return __class__

# Alternative to create a closure:
#def __repr__(self):
#return super().__repr__()
---

Output:
---
PyCSimpleType: create Item class
PyCSimpleType: after first type.__new__() call: __classcell__=
PyCSimpleType: after second type.__new__() call: __classcell__=
Traceback (most recent call last):
  File "meta.py", line 23, in 
class Item(BaseItem, metaclass=PyCSimpleType):
TypeError: __class__ set to  defining 'Item' as 

---

It's not a bug in Python types, but a bug specific to the _ctypes.PyCSimpleType 
type which prevents creating subclasses which use closures ("__class__", 
"super()", etc.).

--
nosy: +vstinner
title: super call in ctypes subclass fails -> ctypes: fail to create a 
_ctypes._SimpleCData subclass using a closure like calling super() without 
arguments
versions: +Python 3.11 -Python 3.8

___
Python tracker 

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



[issue27929] asyncio.AbstractEventLoop.sock_connect broken for AF_BLUETOOTH

2022-03-28 Thread miss-islington


miss-islington  added the comment:


New changeset 2bcbc3113dee6c35631595ec0d5ee3a8dd2a2ddd by Miss Islington (bot) 
in branch '3.10':
bpo-27929: resolve names only for AF_INET/AF_INET6 with asyncio (GH-32131)
https://github.com/python/cpython/commit/2bcbc3113dee6c35631595ec0d5ee3a8dd2a2ddd


--

___
Python tracker 

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



  1   2   >