Re: Script profiling details

2022-01-10 Thread Kirill Ratkin
   Hi Joseph,
   **
   Did you try scalene profiler?
   Recently I solved a similar problem and scalene really helped me.
   **
   It creates a well-formed HTML report, and you can optionally
   enable/disable report about
   a code outside your project, for example - standard library.
   **
   Here it is - [1]https://pypi.org/project/scalene/
   **
   10.01.2022, 22:28, "Joseph L. Casale" :

 I am trying to track down a slow script startup time. I have executed
 the
 script using `python -m cProfile -o profile /path/script.py` and read
 through
 the results, but the largest culprit only shows various built-ins.

 I expected this given the implementation, but I was hoping to get some
 finer details so I can track down the specific module or at least the
 specific
 file so I have a place to start reviewing code for optimizations.

 Is there something I can use to analyze the existing profile output or
 to generate
 it with more feedback?

 Thanks,
 jlc

 --
 [2]https://mail.python.org/mailman/listinfo/python-list

References

   Visible links
   1. https://pypi.org/project/scalene/
   2. https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue39298] add BLAKE3 to hashlib

2022-01-10 Thread Jack O'Connor


Jack O'Connor  added the comment:

Update: There is now a C version of the `blake3` Python module available at 
https://github.com/oconnor663/blake3-py/tree/master/c_impl. It's completely 
API-compatible with the Rust version, and it passes the same test suite. 
Multithreading (which is implemented in upstream Rust but not in upstream C) is 
exposed through a "max_threads" argument, as Larry Hastings suggested. The C 
implementation allows this argument but ignores it.

Unlike my previous attempt, this setup.py build handles the full range of 
target platforms and optimized flavors: x86-64 assembly on Windows-MSVC and 
Unix, 32-bit x86 intrinsics on Windows-MSVC and Unix, NEON intrinsics on 
AArch64, and portable C for everyone else. I'm new to distutils/setuptools and 
not particular familiar with the MSVC toolchain either, so there's a good 
chance that others can suggest better/cleaner/more robust approaches than what 
I've got, but it's at least working on my machines and on GitHub CI. (I haven't 
tried to get any cross-compilation working though; is that a thing?)

I haven't published this module to PyPI, partly to avoid confusion with the 
Rust-based implementation, which I think most applications should prefer. But 
if it would make a big difference to anyone who wants to review this code, we 
could certainly put it up as `experimental_blake3_c` or something? Let me know 
what's best.

--

___
Python tracker 

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



[issue46244] typing._TypeVarLike missing __slots__

2022-01-10 Thread Guido van Rossum


Guido van Rossum  added the comment:

Yes.--
--Guido (mobile)

--

___
Python tracker 

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



[issue46340] DeprecationWarning emitted when running asyncio tests

2022-01-10 Thread Kumar Aditya


Change by Kumar Aditya :


--
components: asyncio
nosy: asvetlov, kumaraditya303, yselivanov
priority: normal
pull_requests: 28727
severity: normal
status: open
title: DeprecationWarning emitted when running asyncio tests
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



[issue46333] ForwardRef.__eq__ does not respect module parameter

2022-01-10 Thread Kumar Aditya


Change by Kumar Aditya :


--
nosy: +kumaraditya303

___
Python tracker 

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



[issue46334] Glossary URLs with anchor link no longer jump to definitions

2022-01-10 Thread Ned Deily


Change by Ned Deily :


--
nosy: +mdk

___
Python tracker 

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



[issue46339] PEG parser segfault from ast.literal_eval

2022-01-10 Thread Kumar Aditya


Kumar Aditya  added the comment:

I tested it on 3.10.1 and it didn't segfault on Windows 11 so seems like 3.11 
regression.

--
nosy: +kumaraditya303

___
Python tracker 

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



[issue46244] typing._TypeVarLike missing __slots__

2022-01-10 Thread Kumar Aditya


Kumar Aditya  added the comment:

Can this be closed now ?

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



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

2022-01-10 Thread Kumar Aditya


Change by Kumar Aditya :


--
nosy: +kumaraditya303
nosy_count: 25.0 -> 26.0
pull_requests: +28726
pull_request: https://github.com/python/cpython/pull/30525

___
Python tracker 

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



[issue46205] test.libregrtest: Race condition in runtest_mp leads to hangs (never exits)

2022-01-10 Thread Dong-hee Na


Change by Dong-hee Na :


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



[issue46205] test.libregrtest: Race condition in runtest_mp leads to hangs (never exits)

2022-01-10 Thread Dong-hee Na


Change by Dong-hee Na :


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



[issue46205] test.libregrtest: Race condition in runtest_mp leads to hangs (never exits)

2022-01-10 Thread miss-islington


miss-islington  added the comment:


New changeset 690ed889c537c008a2c5f3e6c4f06c5b0c0afbc6 by Miss Islington (bot) 
in branch '3.9':
bpo-46205: exit if no workers are alive in runtest_mp (GH-30470)
https://github.com/python/cpython/commit/690ed889c537c008a2c5f3e6c4f06c5b0c0afbc6


--

___
Python tracker 

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



[issue46205] test.libregrtest: Race condition in runtest_mp leads to hangs (never exits)

2022-01-10 Thread miss-islington


miss-islington  added the comment:


New changeset e0ec08dc49f8e6f94a735bc9946ef7a3fd898a44 by Miss Islington (bot) 
in branch '3.10':
bpo-46205: exit if no workers are alive in runtest_mp (GH-30470)
https://github.com/python/cpython/commit/e0ec08dc49f8e6f94a735bc9946ef7a3fd898a44


--

___
Python tracker 

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



[issue46205] test.libregrtest: Race condition in runtest_mp leads to hangs (never exits)

2022-01-10 Thread Dong-hee Na


Dong-hee Na  added the comment:


New changeset e13cdca0f5224ec4e23bdd04bb3120506964bc8b by Sam Gross in branch 
'main':
bpo-46205: exit if no workers are alive in runtest_mp (GH-30470)
https://github.com/python/cpython/commit/e13cdca0f5224ec4e23bdd04bb3120506964bc8b


--

___
Python tracker 

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



[issue46205] test.libregrtest: Race condition in runtest_mp leads to hangs (never exits)

2022-01-10 Thread miss-islington


Change by miss-islington :


--
pull_requests: +28725
pull_request: https://github.com/python/cpython/pull/30524

___
Python tracker 

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



[issue46205] test.libregrtest: Race condition in runtest_mp leads to hangs (never exits)

2022-01-10 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 3.0 -> 4.0
pull_requests: +28724
pull_request: https://github.com/python/cpython/pull/30523

___
Python tracker 

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



[issue46339] PEG parser segfault from ast.literal_eval

2022-01-10 Thread Gregory P. Smith


New submission from Gregory P. Smith :

cpython/b$ ./python 
Python 3.11.0a3+ (heads/main-dirty:081a214008, Jan 11 2022, 02:48:22) [GCC 
11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ast
>>> ast.literal_eval('''F"""
... 
... 
... {6
... 0="""''')
Segmentation fault

this was discovered by oss-fuzz.

This may be a recent regression?  It didn't happen on my build from a few weeks 
ago.  worth testing on older versions.

--
assignee: pablogsal
components: Parser
messages: 410270
nosy: gregory.p.smith, lys.nikolaou, pablogsal
priority: normal
severity: normal
stage: needs patch
status: open
title: PEG parser segfault from ast.literal_eval
type: crash
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



[issue41987] singledispatchmethod raises an error when relying on a forward declaration

2022-01-10 Thread Guido van Rossum


Guido van Rossum  added the comment:

Thanks for the bisection. It's not surprising that that's the culprit, and in 
other situations that's the right thing to do. I'm not sure how to address this 
without breaking other stuff -- maybe leave the ForwardRef if evaluating it 
doesn't work? But that's likely to have other subtle side effects -- we still 
want simple typos (or other reasons why a reference is legitimately broken) to 
go unchecked. Maybe singledispatch can catch the error and fall back on looking 
at bare __annotations__?

--

___
Python tracker 

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



[issue46162] Make `builtins.property` generic

2022-01-10 Thread Guido van Rossum


Guido van Rossum  added the comment:

Since the conclusion is that we can't do this without breaking backwards 
compatibility, should we just close this? Or is there still a compromise 
possible?

--

___
Python tracker 

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



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

2022-01-10 Thread Yu Zhao


Change by Yu Zhao :


--
nosy: +CharlieZhao
nosy_count: 24.0 -> 25.0
pull_requests: +28723
pull_request: https://github.com/python/cpython/pull/30522

___
Python tracker 

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



Re: Why operations between dict views return a set and not a frozenset?

2022-01-10 Thread Chris Angelico
On Tue, Jan 11, 2022 at 10:26 AM Marco Sulla
 wrote:
>
> On Wed, 5 Jan 2022 at 23:02, Chris Angelico  wrote:
> >
> > On Thu, Jan 6, 2022 at 8:01 AM Marco Sulla  
> > wrote:
> > >
> > > On Wed, 5 Jan 2022 at 14:16, Chris Angelico  wrote:
> > > > That's an entirely invisible optimization, but it's more than just
> > > > "frozenset is faster than set". It's that a frozenset or tuple can be
> > > > stored as a function's constants, which is a massive difference.
> > >
> > > Can you explain this?
> >
> > Play around with dis.dis and timeit.
>
> ? I don't understand. You're talking about function constants. What
> are they? I can't dig deep into something if I can't know what it is.
> Maybe are you talking about function default values for parameters?

No, I'm talking about constants. Every function has them.

> Of course. You can use a proxy and slow down almost everything much
> more. Or you can simply create a version of the mutable object with
> fewer methods, as more or less frozenset is. I checked the
> implementation, no fast iteration is implemented. I do not understand
> why in `for x in {1, 2, 3}` the set is substituted by a frozenset.

Constants. Like I said, play around with dis.dis, and explore what's
already happening. A set can't be a constant, a frozenset can be.
Constants are way faster than building from scratch.

Explore. Play around. I'm not going to try to explain everything in detail.

If you're delving into the details of the C implementation of the
dictionary, I would have expected you'd already be familiar with the
way that functions behave.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46244] typing._TypeVarLike missing __slots__

2022-01-10 Thread Ken Jin


Ken Jin  added the comment:


New changeset 081a2140083680ffc309e53699aea29e71760d70 by Arie Bovenberg in 
branch 'main':
bpo-46244: Remove __slots__ from typing.TypeVar, .ParamSpec (#30444)
https://github.com/python/cpython/commit/081a2140083680ffc309e53699aea29e71760d70


--

___
Python tracker 

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



[issue45331] Can create enum of ranges, cannot create range enum. Range should be subclassable... or EnumMeta.__new__ should be smarter.

2022-01-10 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 6223cbf86ad7d5e6d12f9747e5a9cf1d8c72bdc8 by Nikita Sobolev in 
branch 'main':
bpo-45331: [Enum] add rule to docs that mixin type must be subclassable 
(GH-30521)
https://github.com/python/cpython/commit/6223cbf86ad7d5e6d12f9747e5a9cf1d8c72bdc8


--

___
Python tracker 

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



[issue7238] frame.f_lineno doesn't get updated after local trace function assigned to it

2022-01-10 Thread Irit Katriel


Irit Katriel  added the comment:

I am unable to reproduce this on 3.11, I get this:

iritkatriel@Irits-MBP cpython % ./python.exe tracer_testcase.py 
14
15
16

14
15
16


I am also unable to reproduce the problem in the related issue 16482.

--
nosy: +iritkatriel
status: open -> pending

___
Python tracker 

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



[issue16482] pdb.set_trace() clobbering traceback on error

2022-01-10 Thread Irit Katriel


Irit Katriel  added the comment:

iritkatriel@Irits-MBP cpython % cat pdb_traceback.py

import pdb

x = 0

while True:
pdb.set_trace()
y = "line of code not triggering an error"
x += 1
assert x != 3
iritkatriel@Irits-MBP cpython % cat pdb_traceback.py

import pdb

x = 0

while True:
pdb.set_trace()
y = "line of code not triggering an error"
x += 1
assert x != 3
iritkatriel@Irits-MBP cpython % ./python.exe pdb_traceback.py
> /Users/iritkatriel/src/cpython/pdb_traceback.py(8)()
-> y = "line of code not triggering an error"
(Pdb) c
> /Users/iritkatriel/src/cpython/pdb_traceback.py(8)()
-> y = "line of code not triggering an error"
(Pdb) c
> /Users/iritkatriel/src/cpython/pdb_traceback.py(8)()
-> y = "line of code not triggering an error"
(Pdb) c
Traceback (most recent call last):
  File "/Users/iritkatriel/src/cpython/pdb_traceback.py", line 10, in 
assert x != 3
^
AssertionError

--
nosy: +iritkatriel
status: open -> pending

___
Python tracker 

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



[issue45331] Can create enum of ranges, cannot create range enum. Range should be subclassable... or EnumMeta.__new__ should be smarter.

2022-01-10 Thread Nikita Sobolev


Change by Nikita Sobolev :


--
keywords: +patch
nosy: +sobolevn
nosy_count: 2.0 -> 3.0
pull_requests: +28722
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30521

___
Python tracker 

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



Re: Why operations between dict views return a set and not a frozenset?

2022-01-10 Thread Marco Sulla
On Wed, 5 Jan 2022 at 23:02, Chris Angelico  wrote:
>
> On Thu, Jan 6, 2022 at 8:01 AM Marco Sulla  
> wrote:
> >
> > On Wed, 5 Jan 2022 at 14:16, Chris Angelico  wrote:
> > > That's an entirely invisible optimization, but it's more than just
> > > "frozenset is faster than set". It's that a frozenset or tuple can be
> > > stored as a function's constants, which is a massive difference.
> >
> > Can you explain this?
>
> Play around with dis.dis and timeit.

? I don't understand. You're talking about function constants. What
are they? I can't dig deep into something if I can't know what it is.
Maybe are you talking about function default values for parameters?

> > > Function positional arguments aren't interchangeable, so it makes
> > > sense to have them as a tuple.
> >
> > You are wrong, since kwarg is a dict. Indeed I proposed to use
> > frozendict for kwargs, and Guido said that it's a pity that this will
> > break a lot of existing Python code :D, since the fact that args is
> > _immutable_ and kwargs not always bothered him.
>
> Excuse me? I mentioned kwargs in the part that you removed from the
> quote, and the part you're quoting explicitly says "positional
> arguments".

Ok, I quote also the other part:

> (Function *keyword* arguments, on the other hand, are different; as
> long as the mapping from keys to values is maintained, you can remove
> some of them and pass the rest on, without fundamentally changing
> their meaning.)

First of all, I repeat, Guido said (more or less) that in a perfect
world, kwargs are immutable. Or maybe I did not understand what he
said, maybe he said that in a perfect world also args are mutable. But
I suppose it's more probable the first hypothesis :D

Secondly, you can also get the args from a function, transform it in a
list, change something and pass it unpacked to another function. You
will not change the meaning of the tuple, since, well, you copied it
in another mutable object. The original object is untouched.

I perfectly agree that, in the majority of cases, returning an
immutable vs a mutable are a matter of... sense? Meaning? Ok, I
perfectly agree. But IMHO there are many cases in which immutable
objects are used for a matter of speed, and I bet that args is one of
them.

> > Anyway, I'm starting to think that neither set nor frozenset are good
> > for dict items:
> >
> > (venv_3_10) marco@buzz:~$ python
> > Python 3.10.0 (heads/3.10-dirty:f6e8b80d20, Nov 18 2021, 19:16:18)
> > [GCC 10.1.1 20200718] on linux
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> a = {1: 2}
> > >>> b = {3: []}
> > >>> a | b
> > {1: 2, 3: []}
> > >>> a.items() | b.items()
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > TypeError: unhashable type: 'list'
> > >>>
>
> Well yes. Only dict keys can be considered to be set-like.

This is not true. It's at least from Python 3.6, and I think also
before, that almost the full Set API was added to both keys and items
view.
Items indeed are a sort of set, in a mathematical sense, since any
pair (key, value) is unique, even if value is mutable.

> I don't
> know WHAT you think you're trying to do here, but if you ever thought
> of set operations on dict values, you may want to completely rethink
> what you're doing.

set ops on values? Never said that :) I said that currently you can
operate on item views with set operators. This is a fact.

I also said that, since py sets accept only hashable objects, maybe
another ad-hoc object should be used for the result of the items
operations.
But maybe the change isn't worth the additional trouble. Indeed I
didn't know about the new set methods and operations on dict views
until I explored dictobject.c

> Performance is not an automatic result of immutability. That simply
> isn't how it works.

Of course. You can use a proxy and slow down almost everything much
more. Or you can simply create a version of the mutable object with
fewer methods, as more or less frozenset is. I checked the
implementation, no fast iteration is implemented. I do not understand
why in `for x in {1, 2, 3}` the set is substituted by a frozenset.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue43681] doctest forgets previous imports

2022-01-10 Thread Nikita Sobolev


Nikita Sobolev  added the comment:

Ethan, I've tried to reproduce this, but it seems that example you attached is 
not valid.

`Flag` is never imported at all. The same with `auto`.

Should it be:

```
>>> from enum import auto, Flag, STRICT
```

the first time?

As you said, it only happens in rare envs. For me the sample above works 
completely fine.

I also can't find any historical logs from the CI failures :(

Related: 
- https://github.com/python/cpython/pull/25118
- https://bugs.python.org/issue40066

--
nosy: +sobolevn

___
Python tracker 

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



[issue6942] email.generator.Generator memory consumption

2022-01-10 Thread Irit Katriel


Change by Irit Katriel :


--
stage:  -> resolved
status: pending -> closed

___
Python tracker 

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



[issue27257] get_addresses results in traceback with an addrspec with an empty local part.

2022-01-10 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> works for me
stage: patch review -> resolved
status: pending -> closed

___
Python tracker 

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



[issue23902] let exception react to being raised or the setting of magic properties (like __cause__) within Python

2022-01-10 Thread Irit Katriel


Change by Irit Katriel :


--
stage:  -> resolved
status: pending -> closed

___
Python tracker 

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



Re: Script profiling details

2022-01-10 Thread Barry
S

> On 10 Jan 2022, at 19:29, Joseph L. Casale  wrote:
> 
> I am trying to track down a slow script startup time. I have executed the
> script using `python -m cProfile -o profile /path/script.py` and read through
> the results, but the largest culprit only shows various built-ins.
> 
> I expected this given the implementation, but I was hoping to get some
> finer details so I can track down the specific module or at least the specific
> file so I have a place to start reviewing code for optimizations.
> 
> Is there something I can use to analyze the existing profile output or to 
> generate
> it with more feedback?

Read the profile analyses docs/code and report using options that show you 
which callers are using the builtins.

If you need details reply and I will look at the scripts I use that produce a 
number of report types,

Barry
> 
> Thanks,
> jlc
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46336] Sixth element of tuple from __reduce__(), inconsistency between pickle and copy

2022-01-10 Thread Irit Katriel


Irit Katriel  added the comment:

I added Serhiy as the author of the deepcopy optimization. Although it was the 
first to use the 6th item, it is not documented so I wonder if it's the easier 
of the two to change.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue46336] Sixth element of tuple from __reduce__(), inconsistency between pickle and copy

2022-01-10 Thread Irit Katriel


Change by Irit Katriel :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue46336] Sixth element of tuple from __reduce__(), inconsistency between pickle and copy

2022-01-10 Thread Éric Araujo

Change by Éric Araujo :


--
nosy: +pitrou, rhettinger
versions: +Python 3.10, Python 3.11, Python 3.9

___
Python tracker 

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



[issue46328] add sys.exception()

2022-01-10 Thread Alex Waygood


Change by Alex Waygood :


--
nosy: +AlexWaygood

___
Python tracker 

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



[issue46330] Simplify the signature of __exit__

2022-01-10 Thread Alex Waygood


Change by Alex Waygood :


--
nosy: +AlexWaygood

___
Python tracker 

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



[issue46333] ForwardRef.__eq__ does not respect module parameter

2022-01-10 Thread Alex Waygood


Change by Alex Waygood :


--
nosy: +AlexWaygood

___
Python tracker 

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



[issue46338] libc_ver() runtime error when sys.executable is empty

2022-01-10 Thread Allie Hammond


New submission from Allie Hammond :

libc_ver() in platform.py (called from platform()) causes a runtime error if 
sys.executable returns null. In my case, FreeRADIUS offers a module rlm_python3 
which allows you to run python code from the C based FreeRADIUS server - since 
this module doesn't use a python binary to execute sys.executable returns null 
trigering this error.

--
messages: 410261
nosy: allie.hammond, lemburg
priority: normal
severity: normal
status: open
title: libc_ver() runtime error when sys.executable is empty
type: crash
versions: Python 3.9

___
Python tracker 

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



[issue46328] add sys.exception()

2022-01-10 Thread Irit Katriel


Irit Katriel  added the comment:

Cool. I just removed the do-not-merge label from the PR and I guess it's ready 
to be reviewed.

--

___
Python tracker 

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



[issue46337] urllib.parse: Allow more flexibility in schemes and URL resolution behavior

2022-01-10 Thread Lincoln Auster


Change by Lincoln Auster :


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

___
Python tracker 

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



[issue46337] urllib.parse: Allow more flexibility in schemes and URL resolution behavior

2022-01-10 Thread Lincoln Auster


New submission from Lincoln Auster :

It looks like this was discussed in 2013-2015 here: 
https://bugs.python.org/issue18828

Basically, with all the URL schemes that exist in the world (and the 
possibility of a custom scheme), the current strategy of enumerating what do 
what in a hard-coded variable is a bit ... weird. Among the proposed solutions 
in 18828, some were:

+ Have a global registry of what schemes do what (criticized for being 
overkill, and I can't say I disagree)
+ Get rid of the scheme lists altogether, and assume every scheme supports 
everything (isn't backwards compatible; might break with intended behavior, 
too).
+ Switch the use_relative whitelist to a blacklist: (maybe fine in practice, 
maybe not; either way it doesn't really fix the underlying issue)
+ Work around it with global state (modify the uses_* lists; this is what I'm 
doing in my code, and I can't say I like it much).

An alternative implemented I've implemented in my fork 
(https://github.com/lincolnauster/cpython/tree/urllib-custom-schemes) is to 
have an Enum with all the weird scheme-based behaviors that may occur 
(urllib.parse.SchemeClass in my fork) and allow passing a set of those Enums to 
functions relying on scheme-specific behavior, and adding all the elements of 
that set to what's been determined by the scheme. (See the test case for a 
concrete example; this explanation is not great).

Some things I like about this:
+ Backwards compatibility.
+ It makes the functions using it as a general strategy a bit more pure.
+ It makes client code deal with edge cases.

Some things that could be changed:
+ There's no way to remove behaviors you *don't* want.
+ It makes client code deal with edge cases.

As a side thought: if the above could be adopted, the uses_* lists could be 
enforced as immutable, which, while breaking compatibility, could make client 
code a bit cleaner.

--
components: Library (Lib)
messages: 410259
nosy: lincolnauster
priority: normal
severity: normal
status: open
title: urllib.parse: Allow more flexibility in schemes and URL resolution 
behavior
type: behavior

___
Python tracker 

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



[issue46328] add sys.exception()

2022-01-10 Thread Barry A. Warsaw


Barry A. Warsaw  added the comment:

sys.exception() seems like a decent enough trade-off.  I've always disliked the 
abbreviations in "exc_info".  It doesn't feel big enough for a PEP to me.

--

___
Python tracker 

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



[issue46329] Split up the CALL_NO_KW and CALL_KW instructions.

2022-01-10 Thread Brandt Bucher


Change by Brandt Bucher :


--
nosy: +brandtbucher

___
Python tracker 

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



[issue46333] ForwardRef.__eq__ does not respect module parameter

2022-01-10 Thread Andreas H.


Andreas H.  added the comment:

I will give it a try.

--

___
Python tracker 

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



[issue46336] Sixth element of tuple from __reduce__(), inconsistency between pickle and copy

2022-01-10 Thread Lev Bishop

New submission from Lev Bishop :

As discussed in discord thread 
https://discuss.python.org/t/sixth-element-of-tuple-from-reduce-inconsistency-between-pickle-and-copy/12902
 where guido suggested to open this issue.

Both the pickle and copy modules of the standard library make use of a class’s 
__reduce__() method for customizing their pickle/copy process. They seem to 
have a consistent view of the first 5 elements of the returned tuple:
(func, args, state, listiter, dictiter) but the 6th element seems different. 
For pickle it’s state_setter , a callable with signature state_setter(obj, 
state)->None , but for copy it’s deepcopy with signature deepcopy(arg: T, memo) 
-> T .

This seems to be unintentional, since the pickle documentation states:

> As we shall see, pickle does not use directly the methods described
> above. In fact, these methods are part of the copy protocol which 
> implements the __reduce__() special method. The copy protocol provides
> a unified interface for retrieving the data necessary for pickling 
> and copying objects

It seems like in order to make a class definition for __reduce__() returning 
all 6 elements, then the __reduce__() would have to do something very awkward 
like examining its call stack in order to determine if it is being called in 
pickle or copy context in order to return an appropriate callable? (Naively 
providing the same callable in both contexts would cause errors for one or the 
other).

I attach a test file which defines two classes making use of a __reduce__() 
returning a 6 element tuple. One class Pickleable can be duplicated via 
pickling, but not deepcopied. The converse is true for the Copyable class.

Other than the 6th element of the tuple returned from __reduce__() the classes 
are identical.

Guido dug into the history and found that: 
> it looks like these are independent developments:

> the 6th arg for deepcopy was added 6 years ago via Issue 26167: Improve 
> copy.copy speed for built-in types (list/set/dict) - Python tracker
> the 6th arg for pickle was adde 3 years ago via Issue 35900: Add pickler hook 
> for the user to customize the serialization of user defined functions and 
> types. - Python tracker

> I’m guessing the folks doing the latter weren’t aware that deepcopy already 
> uses the 6th arg. Sorting this out will be painful.

--
components: Library (Lib)
files: reduce.py
messages: 410256
nosy: lev.bishop
priority: normal
severity: normal
status: open
title: Sixth element of tuple from __reduce__(), inconsistency between pickle 
and copy
type: behavior
Added file: https://bugs.python.org/file50554/reduce.py

___
Python tracker 

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



[issue46328] add sys.exception()

2022-01-10 Thread Irit Katriel


Irit Katriel  added the comment:

I thought of something like sys.active_exception() but it seems like a lot to 
type. sys.exception() was suggested in pep3134.


Does this change need a pep?

--

___
Python tracker 

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



[issue46320] runtime/interp/thread state refactoring leads to segmentation fault

2022-01-10 Thread Quentin Pradet


Quentin Pradet  added the comment:

We haven't opened an issue for this, but discussed it in Discord, sorry. It 
also does not always crash on GitHub Actions. Here's an example of a crash: 
https://github.com/urllib3/urllib3/runs/4740730329?check_suite_focus=true

If nox can't find your Python version and `nox --no-venv -Rs test-3.11` does 
not run your version of Python 3.11, you can always execute those commands 
directly:

pip install -r dev-requirements.txt
pip install ".[socks,secure,brotli]"
pytest

If that does not crash on your system, I'd appreciate if you could tell me how 
I could help get this fixed besides simplifying the reproducer. Thanks.

--

___
Python tracker 

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



[issue46320] runtime/interp/thread state refactoring leads to segmentation fault

2022-01-10 Thread Eric Snow


Eric Snow  added the comment:

It looks like the urllib3 CI is passing for 3.11.0a3: 
https://github.com/urllib3/urllib3/runs/4762856431 (Ubuntu 3.11-dev test-3.11).

Is there a urllib3 issue number you could point me at?

--

___
Python tracker 

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



[issue46334] Glossary URLs with anchor link no longer jump to definitions

2022-01-10 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
nosy: +rhettinger

___
Python tracker 

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



[issue46320] runtime/interp/thread state refactoring leads to segmentation fault

2022-01-10 Thread Eric Snow


Eric Snow  added the comment:

I must be missing something.  Here is what I did:

```
$ cd cpython
$ git checkout main
$ make -j8
$ ./python -v venv ../venv-urllib3
$ cd ..
$ git clone https://github.com/urllib3/urllib3
$ cd urllib3
$ ../venv-urllib3/bin/python3 -m pip install nox
$ ../venv-urllib3/bin/nox -Rs test-3.11
nox > Running session test-3.11
nox > Session test-3.11 skipped: Python interpreter 3.11 not found.
```

I am not familiar with nox so I'm not sure how to trouble-shoot this.

--

___
Python tracker 

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



[issue46226] User specific paths added to System PATH environment variable

2022-01-10 Thread Steve Dower


Steve Dower  added the comment:

Without logs or the ability to reproduce it, there's not much we can do. I ran 
the install and it put the variables in the right place, so it's not happening 
all the time.

The install logs are usually detailed enough to see why decisions like this are 
made, but it'll almost certainly be because of something specific to your 
machine. If running the install again produces the same result, those logs will 
be helpful as well. I don't see us being able to make any product changes for 
this though.

--

___
Python tracker 

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



[issue46330] Simplify the signature of __exit__

2022-01-10 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Implementation and transition issues aside, I like this idea.  People can 
mostly just use isinstance() checks to match one or more exception types.  
Also, the single argument form would work well with structural pattern matching:

def __exit__(self, exc):
match exc:
case IOError():
...

That said, there will be some cases that are worse off.  If the code actually 
needs "exctype", perhaps for logging or for an exact match, then the new single 
argument form will just shift complexity away from the signature and into the 
main body of the code.  This may be the common case.  During code reviews, I 
see the "exctype" argument used more frequently than "excinst".

--
nosy: +rhettinger

___
Python tracker 

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



[issue46226] User specific paths added to System PATH environment variable

2022-01-10 Thread Aleksandr Krymskiy


Aleksandr Krymskiy  added the comment:

I installed 3.10, and then removed 3.9 that I had installed previously. Python 
is installed in "C:\Program Files\Python310". The only thing that exists under 
%LocalAppData% is an empty directory 
"C:\Users\avk\AppData\Local\Programs\Python\Python310\Scripts" - I always 
install "for all users" so there isn't anything else under the 
"C:\Users\avk\AppData\Local\Programs\Python" other than the empty directory I 
mentioned.

--

___
Python tracker 

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



[issue46327] `test_enum` contains tests for older versions of python

2022-01-10 Thread Nikita Sobolev


Change by Nikita Sobolev :


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



[issue46057] argparse: embedded groups may prevent options from being in help output

2022-01-10 Thread paul j3


paul j3  added the comment:

"I tried to create a group hierarchy in a way that I can pass the 
responsibility of argument validation to the argument parser." 

I looked at your example in:

https://bugs.python.org/issue46058

The many levels of nesting groups was confusing, but now I realize that by 
nesting argument_groups in a mutually_exlusive_group you were try to implement 
some sort of any/all group within the xor group.  

This cannot be done within argparse.  Mutually_exclusive only implements a flat 
xor.  Argument_groups are used for help display, but play no role in parsing.

Some years ago I explored the use of nest parsing groups:

https://bugs.python.org/issue11588
Add "necessarily inclusive" groups to argparse

I was trying to allow for nested groups that implemented all logical options - 
xor, or, and, not.  Defining such groups wasn't hard.  And I think I got the 
testing logic working right.  But usage display required too big of a change to 
the formatter, and left too many loose ends.  So I have let that languish.

Now I recommend focusing on doing the testing after parsing.  Use meaningful 
defaults where possible, and use `is None` to test whether a users has provided 
a value or not.

--

___
Python tracker 

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



[issue46334] Glossary URLs with anchor link no longer jump to definitions

2022-01-10 Thread Trey Hunner


Trey Hunner  added the comment:

I just realized those only affects some terms.

parameter works: https://docs.python.org/3/glossary.html#term-parameter

And LBYL does work but only if LBYL was used: 
https://docs.python.org/3/glossary.html#term-LBYL

The EAFP term does link to #term-LBYL instead of the old #term-lbyl.

It looks like the capitalization changed. The search doesn't seem to know that 
though (the LBYL glossary link at the top is broken): 
https://docs.python.org/3/search.html?q=lbyl

I would vote for changing the link back to lowercase rather than changing the 
search to link to the new URL. Otherwise links to specific glossary terms 
scattered around the internet will all link to the top of the glossary page 
instead.

--

___
Python tracker 

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



Script profiling details

2022-01-10 Thread Joseph L. Casale
I am trying to track down a slow script startup time. I have executed the
script using `python -m cProfile -o profile /path/script.py` and read through
the results, but the largest culprit only shows various built-ins.

I expected this given the implementation, but I was hoping to get some
finer details so I can track down the specific module or at least the specific
file so I have a place to start reviewing code for optimizations.

Is there something I can use to analyze the existing profile output or to 
generate
it with more feedback?

Thanks,
jlc
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What to write or search on github to get the code for what is written below:

2022-01-10 Thread MRAB

On 2022-01-10 16:39, NArshad wrote:


Using openpyxl is pretty straightforward:


from openpyxl import load_workbook
wb = load_workbook(spreadsheet_path)
sheet = wb.active

# Reading the values in cells:
print('Cell A1 contains', sheet['A1'].value)
print('Cell A2 contains', sheet['A2'].value)
print('Cell B1 contains', sheet['B1'].value)

# Alternatively:
print('Cell A1 contains', sheet.cell(1, 1).value)
print('Cell A2 contains', sheet.cell(1, 2).value)
print('Cell B1 contains', sheet.cell(2, 1).value)

"""
The cell numbers (A1 or A2 or A3 or A4……… ) are not fixed they can be any. I 
don't know what the cell number is going to be that's what the problem is.

The user is going to enter the book name in an HTML form present on a website 
then it will be checked whether the book user has entered is present or not in 
the Excel file. If the book is present in the book bank and the user requires 
that book then one will be issued to the user and the total number of books 
will be reduced by 1 (one) and the user or borrower’s name will be entered in 
the Excel’s table row in which the book name is present separated by a comma by 
other borrower names. The borrower's name can be more than one because more 
than one copies of the book are there as these are the books that are taught in 
schools.
"""
  

[snip]
How are the relevant cells identified in the spreadsheet?

It's often the case that the cells on the first row contain text as 
column labels. If that's what you have in your spreadsheet, then read 
the cells on the first row for the column labels and put them in a dict 
to map from column label to column number.

--
https://mail.python.org/mailman/listinfo/python-list


symlinks with python3 http.server.CGIHTTPRequestHandler

2022-01-10 Thread Nat Taylor
Is it possible to get http.server.CGIHTTPRequestHandler to run a symlink-ed
script?

In the example below, GET /cgi-bin/test.py results in a 404 because it is a
symlink.

% mkdir -p test/cgi-bin
% cd test
% vi test.py
% chmod +x test.py
% ln -s test.py cgi-bin
% cp test.py cgi-bin/test2.py
% chmod +x cgi-bin/test2.py
% python3 -m http.server --cgi 8090
Serving HTTP on :: port 8090 (http://[::]:8090/) ...
::1 - - [06/Jan/2022 09:21:48] code 404, message No such CGI script
('/cgi-bin/test.py')
::1 - - [06/Jan/2022 09:21:48] "GET /cgi-bin/test.py HTTP/1.1" 404 -
::1 - - [06/Jan/2022 09:21:59] "GET /cgi-bin/test2.py HTTP/1.1" 200 -
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Inkscape

2022-01-10 Thread Michael Torrie
On 1/10/22 8:27 AM, Mandy and Michael Wilson via Python-list wrote:
> I wonder if you can help me out please.  I have recently added an 
> extension into Inkscape called Axidraw which should enable me to 
> hatchfill text, unforunately I am unable to use this facility as when I 
> open a canvas in Inkscape and go to the axidraw extension I receive a 
> message saying that I require Python 3.6 or greater.  I have downloaded 
> and installed Python 3.10.1 but I am still receiving the same message. 
> Can you please tell me what I am doing wrong ?  I look forward to 
> hearing from you.

Most likely you'll need to ask the folks on the Inkscape forums or
mailing list.  Very few of us have any working understanding of how
Python is used within Inkscape.

What operating system are you using?  If you're running Windows, then
installing Python 3.10 will have no effect on Inkscape because inkscape
does not know about any other installed versions of Python.  It's built
with and ships with a specific version of Python inside of Inkscape.  So
it seems to me like you need to install the latest version of Inkscape,
which should come with the latest supported version of Python inside of it.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46327] `test_enum` contains tests for older versions of python

2022-01-10 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 13e4659276c2af2fa5b0f2b3a31dcd69064868ef by Nikita Sobolev in 
branch 'main':
bpo-46327: [Enum] remove skipped tests (GH-30512)
https://github.com/python/cpython/commit/13e4659276c2af2fa5b0f2b3a31dcd69064868ef


--

___
Python tracker 

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



[issue46301] Enum tests: One branch is not covered in `Enum._convert_`

2022-01-10 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 582286d71c7ee61f5376a846a83c7be4a5727636 by Nikita Sobolev in 
branch 'main':
bpo-46301: [Enum] fix refleak tests (GH30510)
https://github.com/python/cpython/commit/582286d71c7ee61f5376a846a83c7be4a5727636


--

___
Python tracker 

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



[issue32679] concurrent.futures should store full sys.exc_info()

2022-01-10 Thread Irit Katriel


Irit Katriel  added the comment:

Following the changes in issue45711, exc_info[2] is exactly the same as 
exc_info[1].__traceback__, so there is no point in making this change now.

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



[issue46332] Use raise..from in logging/config instead of assigning __cause__

2022-01-10 Thread Irit Katriel


Change by Irit Katriel :


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



[issue46332] Use raise..from in logging/config instead of assigning __cause__

2022-01-10 Thread Irit Katriel


Irit Katriel  added the comment:


New changeset 0d639678d33a0f085851a07259b8fe2782943118 by Irit Katriel in 
branch 'main':
bpo-46332: use raise..from instead of assigning __cause__ and raising (GH-30517)
https://github.com/python/cpython/commit/0d639678d33a0f085851a07259b8fe2782943118


--

___
Python tracker 

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



[issue46335] asyncio.create_subprocess_exec throws RuntimeError yet still executes subprogram

2022-01-10 Thread Clint Olsen


New submission from Clint Olsen :

When stress testing my code in a process-limited environment I found that 
despite throwing an exception, it appears the process still executes. 
Attempting to catch/retry results in a duplicate.

Attached is a script that I was able to repro the problem on Linux. I cannot 
get it to behave similarly on MacOS.

The exception looks like:

/bin/sh: fork: retry: Resource temporarily unavailable
Traceback (most recent call last):
  File "/home/colsen/async/./example", line 16, in run
proc = await asyncio.create_subprocess_exec('/bin/sh','-c', f'/bin/echo 
{_id} > {_uuid}.out')
  File 
"/home/utils/Python/3.9/3.9.7-20211101/lib/python3.9/asyncio/subprocess.py", 
line 236, in create_subprocess_exec
transport, protocol = await loop.subprocess_exec(
  File 
"/home/utils/Python/3.9/3.9.7-20211101/lib/python3.9/asyncio/base_events.py", 
line 1661, in subprocess_exec
transport = await self._make_subprocess_transport(
  File 
"/home/utils/Python/3.9/3.9.7-20211101/lib/python3.9/asyncio/unix_events.py", 
line 202, in _make_subprocess_transport
watcher.add_child_handler(transp.get_pid(),
  File 
"/home/utils/Python/3.9/3.9.7-20211101/lib/python3.9/asyncio/unix_events.py", 
line 1381, in add_child_handler
thread.start()
  File "/home/utils/Python/3.9/3.9.7-20211101/lib/python3.9/threading.py", line 
892, in start
_start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread

So, this script ended up producing 21 output files (duplicate on iteration 18).

I need a way to catch these errors, pause, and retry when they are recoverable.

--
components: asyncio
files: example
messages: 410242
nosy: Clint Olsen, asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: asyncio.create_subprocess_exec throws RuntimeError yet still executes 
subprogram
versions: Python 3.9
Added file: https://bugs.python.org/file50553/example

___
Python tracker 

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



[issue46101] argparse: using parents & subcommands, options can be ignored

2022-01-10 Thread paul j3


paul j3  added the comment:

This patch should be rejected.

By using `common_opts_parser` as parent to both the main and subparsers, you 
have defined the same argument in both.

By a long standing patch, the value assigned in the subparser has precedence 
(whether it's the default or user supplied).

https://bugs.python.org/issue9351
argparse set_defaults on subcommands should override top level set_defaults

Partial retraction of this override has been explored, but any changes are 
still up for debate

https://bugs.python.org/issue45235
argparse does not preserve namespace with subparser defaults

The bottom line is that we should not try to define the same argument (or more 
specifically the same `dest`) in both main and subparsers.  Duplicate flags are 
ok.  

But resolving the conflicting values should be done after parsing.  Some users 
will want to give priority to the main parser's values, others to the 
subparser's.  Or their own defaults.  argparse cannot handle all cases cleanly.

--

___
Python tracker 

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



[issue12756] datetime.datetime.utcnow should return a UTC timestamp

2022-01-10 Thread Paul Ganssle

Paul Ganssle  added the comment:

> from practical experience, it is a whole lot better to not deal with 
> timezones in data processing code at all, but instead only use naive UTC 
> datetime values everywhere, expect when you have to prepare reports or output 
> which has a requirement to show datetime value in local time or some specific 
> timezone.

This is not good advice. It is out of date, and has some significant pitfalls. 
See my blog post on the subject: 
https://blog.ganssle.io/articles/2019/11/utcnow.html

If you are working with `datetime` objects that represent time in a specific 
time zone other than the system local zone, you should probably have them carry 
around a tzinfo object.

> Note also that datetime.now() gives you a naive datetime.  From an API 
> consistency standpoint I think it makes sense that datetime.utcnow() gives a 
> naive datetime.

This... is not accurate. `.now()` gives you the local time; to the extent that 
they represent a date in a time zone at all, naïve time zones represent times 
in the *system local time*, which is why it makes sense for `.now()` to default 
to returning naïve time zones. For example, `datetime.now().timestamp()` will 
give accurate information, whereas `datetime.utcnow().timestamp()` will *not* 
(unless your local zone happens to be UTC or equivalent).

> It would actually be confusing (IMO) for it to return an aware datetime.  I 
> can see why you might disagree, but backward compatibility wins in this case 
> regardless.

As evidenced by this thread, the fact that we have some APIs that return naïve 
datetimes generated by a process that treats them as localized datetimes in 
something other than system local times is actually the source of confusion 

That said, from a backwards compatibility point of view, we simply cannot 
change this. It has been proposed many times and it would be a major breaking 
change for almost no reason. The best we can do is to deprecate the offending 
methods and remove them.

There is more information about the challenge that doing this would present in 
this datetime-SIG thread: 
https://mail.python.org/archives/list/datetime-...@python.org/thread/PT4JWJLYBE5R2QASVBPZLHH37ULJQR43/

I am sympathetic to the idea of removing it, but we would probably want to put 
some optimizations in place for `UTC` first, to make the transition more 
seamless in the few places where there are legitimate uses for `utcnow` and 
`utcfromtimestamp`.

> I would argue that PEP20 should win over backward compatibility, in addition 
> to the points I hinted at above, practicality beats purity

PEP 20 contains a bunch of contradictory advice, and it's not really a binding 
document anyway, so it definitely doesn't "win" over anything, but in this case 
you have it backwards. "Purity" would be making a breaking change for the 
purposes of making the function do what a lot of people think it does, but 
doing so would actually be impractical, because it would cause a lot of work 
for people, and create a lot of ambiguity in what people meant when they wrote 
a given line of code. The practical things to do here would be to either do 
nothing (not break anything that works and try and guide people away from using 
`utcnow` — maybe get a linting rule added to `pylint` to warn against it), or 
to deprecate and remove the function.

--

___
Python tracker 

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



[issue46328] add sys.exception()

2022-01-10 Thread Barry A. Warsaw


Change by Barry A. Warsaw :


--
nosy: +barry

___
Python tracker 

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



[issue46142] python --help output is too long

2022-01-10 Thread Éric Araujo

Éric Araujo  added the comment:

BTW on the PR I am asking for help with string formatting, to print an invalid 
X option (a wchar_t string) using the PyStatus API (needs char).  Help from a 
proper C programmer would be appreciated :)

--

___
Python tracker 

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



[issue46142] python --help output is too long

2022-01-10 Thread Éric Araujo

Éric Araujo  added the comment:

> For me, the best CLI is "git help", "git help init", etc.

I don’t think that prior art applies here, as python does not have subcommands. 
 `--help` and `--help-env` are straightforward, `-X help` is a bit unusual but 
at least it’s part of the optional `-X` options, `--help-full` or `-all` would 
be way to preserve the behaviour of printing full usage with one option.

--

___
Python tracker 

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



[issue46333] ForwardRef.__eq__ does not respect module parameter

2022-01-10 Thread Guido van Rossum


Guido van Rossum  added the comment:

Good catch. Do you want to submit a PR? I agree that the repr() could also be 
better (but please only show other values if they differ from the default).

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



Re: Gunicorn - HTTP and HTTPS in the same instance?

2022-01-10 Thread Lars Liedtke

server {
   listen [::]:80;
   listen 80;


   server_name api.familie-liedtke.net;

   location / {
   return 301 https://$host$request_uri;
   }

   include /usr/local/etc/nginx/include/letsencrypt.conf;
}

server {
   listen 443 ssl http2;
   listen [::]:443 ssl http2;

   server_name api.familie-liedtke.net;

   ssl_certificate 
/usr/local/etc/ssl/certs/api.familie-liedtke.net/fullchain.pem;
   ssl_certificate_key 
/usr/local/etc/ssl/certs/api.familie-liedtke.net/privkey.pem;


   root /var/www/api;

   location /weather/{
   access_log /var/log/nginx/weather-access.log;
   include uwsgi_params;
   rewrite ^/weather(/.*)$ $1 break;
   uwsgi_pass unix:///tmp/uwsgi.sock;
   }

   include /usr/local/etc/nginx/include/ssl.conf;
}

This is my config for a flask app on uwsgi. granted it is a bit more 
than the 10 lines I said. But there is not much sophistication to it.


Am 08.01.22 um 17:25 schrieb Skip Montanaro:

Thanks all. I was hoping to get away without something more
sophisticated like NGINX. This is just a piddly little archive of an
old mailing list running on a single-core Ubuntu VM somewhere on the
East Coast. Speed is not a real requirement. Load balancing seemed
like overkill to me. Still, I guess if it has to be, then it has to
be.

Skip


--
punkt.de GmbH
Lars Liedtke
.infrastructure

Kaiserallee 13a 
76133 Karlsruhe

Tel. +49 721 9109 500
https://infrastructure.punkt.de
i...@punkt.de

AG Mannheim 108285
Geschäftsführer: Jürgen Egeling, Daniel Lienert, Fabian Stein
--
https://mail.python.org/mailman/listinfo/python-list


[issue46333] ForwardRef.__eq__ does not respect module parameter

2022-01-10 Thread Guido van Rossum


Change by Guido van Rossum :


--
stage:  -> needs patch

___
Python tracker 

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



Re: What to write or search on github to get the code for what is written below:

2022-01-10 Thread NArshad

Using openpyxl is pretty straightforward:


from openpyxl import load_workbook
wb = load_workbook(spreadsheet_path)
sheet = wb.active

# Reading the values in cells:
print('Cell A1 contains', sheet['A1'].value)
print('Cell A2 contains', sheet['A2'].value)
print('Cell B1 contains', sheet['B1'].value)

# Alternatively:
print('Cell A1 contains', sheet.cell(1, 1).value)
print('Cell A2 contains', sheet.cell(1, 2).value)
print('Cell B1 contains', sheet.cell(2, 1).value)

"""
The cell numbers (A1 or A2 or A3 or A4……… ) are not fixed they can be any. I 
don't know what the cell number is going to be that's what the problem is.

The user is going to enter the book name in an HTML form present on a website 
then it will be checked whether the book user has entered is present or not in 
the Excel file. If the book is present in the book bank and the user requires 
that book then one will be issued to the user and the total number of books 
will be reduced by 1 (one) and the user or borrower’s name will be entered in 
the Excel’s table row in which the book name is present separated by a comma by 
other borrower names. The borrower's name can be more than one because more 
than one copies of the book are there as these are the books that are taught in 
schools. 
"""
 
# Changing the value in a cell:
sheet.cell(1, 20).value = 'TEST'

# A value of None means that the cell is empty.

wb.save(spreadsheet_path)
wb.close()
-- 
https://mail.python.org/mailman/listinfo/python-list


Inkscape

2022-01-10 Thread Mandy and Michael Wilson via Python-list




hello Python


I wonder if you can help me out please.  I have recently added an 
extension into Inkscape called Axidraw which should enable me to 
hatchfill text, unforunately I am unable to use this facility as when I 
open a canvas in Inkscape and go to the axidraw extension I receive a 
message saying that I require Python 3.6 or greater.  I have downloaded 
and installed Python 3.10.1 but I am still receiving the same message. 
Can you please tell me what I am doing wrong ?  I look forward to 
hearing from you.




regards


Mandy Wilson

m. 07739 263 234







--
https://mail.python.org/mailman/listinfo/python-list


[issue41534] argparse : allow_abbrev behavior between 3.7 and 3.8

2022-01-10 Thread Steve Fox


Steve Fox  added the comment:

Fundamentally the use of allow_abbrev=False is now broken (it is allowing 
abbreviations when already explicitly told not to)

The use of a single - for all options is much older than -- and exists in my 
unix utilities and many programs have been written to follow this convention, 
these are now broken in 3.8+

"Changed in version 3.8: In previous versions, allow_abbrev also disabled 
grouping of short flags such as -vv to mean -v -v"

Does not accurately describe the behavior change, it is more broadly injecting 
abbreviations when already told not to.

--
nosy: +Fox214

___
Python tracker 

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



[issue46334] Glossary URLs with anchor link no longer jump to definitions

2022-01-10 Thread Alex Waygood


Alex Waygood  added the comment:

Reproduced on safari on my iPad, as well.

--
nosy: +AlexWaygood

___
Python tracker 

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



[issue46334] Glossary URLs with anchor link no longer jump to definitions

2022-01-10 Thread Trey Hunner


New submission from Trey Hunner :

The glossary page allows for anchor links to jump to specific definitions.

For example: https://docs.python.org/3.9/glossary.html#term-lbyl will open the 
glossary page with the web browser showing the LBYL at the top of the page.

This no longer works in Python 3.10 and Python 3.11 documentation.

https://docs.python.org/3.10/glossary.html#term-lbyl

https://docs.python.org/3.11/glossary.html#term-lbyl

Opening either of those links in Chrome or Firefox on my machine results in the 
glossary page being opened without any scrolling (the top of the glossary page 
is shown rather than the LBYL definition).

--
assignee: docs@python
components: Documentation
messages: 410234
nosy: docs@python, trey
priority: normal
severity: normal
status: open
title: Glossary URLs with anchor link no longer jump to definitions
type: behavior
versions: Python 3.10, Python 3.11

___
Python tracker 

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



[issue12756] datetime.datetime.utcnow should return a UTC timestamp

2022-01-10 Thread Tony Rice


Tony Rice  added the comment:

I would argue that PEP20 should win over backward compatibility, in addition to 
the points I hinted at above, 

practicality beats purity

--

___
Python tracker 

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



[issue12756] datetime.datetime.utcnow should return a UTC timestamp

2022-01-10 Thread R. David Murray


R. David Murray  added the comment:

Note also that datetime.now() gives you a naive datetime.  From an API 
consistency standpoint I think it makes sense that datetime.utcnow() gives a 
naive datetime.  It would actually be confusing (IMO) for it to return an aware 
datetime.  I can see why you might disagree, but backward compatibility wins in 
this case regardless.

--

___
Python tracker 

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



[issue46320] runtime/interp/thread state refactoring leads to segmentation fault

2022-01-10 Thread Quentin Pradet


Quentin Pradet  added the comment:

Yes, exactly. `pip install nox && nox -Rs test-3.11`. My reproducer is still 
too big to be useful, and I failed to reproduce this on Docker. If you can't 
reproduce, I'll work on the reproducer more. Thanks!

--

___
Python tracker 

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



[issue46326] 'virtualenv --clear' should prompt user before nuking entire directory

2022-01-10 Thread Eryk Sun

Eryk Sun  added the comment:

The implementation of `--clear` in virtualenv apparently was changed to align 
with venv. On the linked virtualenv issue, Bernát Gábor suggested creating a 
bpo issue for venv to determine how the issue should be resolved for virtualenv.

--
nosy: +vinay.sajip

___
Python tracker 

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



[issue46326] 'virtualenv --clear' should prompt user before nuking entire directory

2022-01-10 Thread Ned Deily


Ned Deily  added the comment:

> Ned, the CLI of venv has a `--clear` option, which invokes EnvBuilder [1] 
> with clear=True.

Thanks, I saw that. However, the issue as written does not mention venv at all, 
only virtualenv. I wanted the OP to verify that it does apply to venv and, if 
the problem exists both places, to update this issue and to open an issue 
against virtualenv.

--

___
Python tracker 

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



[issue46326] 'virtualenv --clear' should prompt user before nuking entire directory

2022-01-10 Thread Eryk Sun


Eryk Sun  added the comment:

Ned, the CLI of venv has a `--clear` option, which invokes EnvBuilder [1] with 
clear=True. It's implemented by EnvBuilder.clear_directory(). Ali wants this 
method to prompt for confirmation before deleting the directory contents and 
also proposes the addition of a new `--force` option to skip the prompt.

---
[1] https://docs.python.org/3/library/venv.html#api

--
nosy: +eryksun
status: pending -> open

___
Python tracker 

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



[issue46320] runtime/interp/thread state refactoring leads to segmentation fault

2022-01-10 Thread Eric Snow


Eric Snow  added the comment:

I'll look into this today.  To reproduce, I should run the urllib3 test suite?

--
assignee:  -> eric.snow
stage:  -> needs patch

___
Python tracker 

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



[issue46331] 3.11: tracing revisits class line after class docstring

2022-01-10 Thread Mark Shannon


Change by Mark Shannon :


--
assignee:  -> Mark.Shannon

___
Python tracker 

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



[issue46331] 3.11: tracing revisits class line after class docstring

2022-01-10 Thread Mark Shannon


Change by Mark Shannon :


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

___
Python tracker 

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



[issue12756] datetime.datetime.utcnow should return a UTC timestamp

2022-01-10 Thread Marc-Andre Lemburg


Marc-Andre Lemburg  added the comment:

Hi Tony,

from practical experience, it is a whole lot better to not deal with
timezones in data processing code at all, but instead only use
naive UTC datetime values everywhere, expect when you have to
prepare reports or output which has a requirement to show datetime
value in local time or some specific timezone.

You convert all datetime values into UTC upon input, possibly
store the timezone somewhere, if that is relevant for later reporting,
and then forget about timezones.

Your code will run faster, become a lot easier to understand
and you avoid many pitfalls that TZs have, esp. when TZs are
silently dropped interfacing to e.g. numeric code, databases or
other external code.

There's a reason why cloud code (and a lot of other code, such
as data science code) has standardized on UTC :-)

Cheers,
-- 
Marc-Andre Lemburg
eGenix.com

--
nosy: +lemburg

___
Python tracker 

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



[issue46328] add sys.exception()

2022-01-10 Thread Eric Snow


Eric Snow  added the comment:

FWIW, here's an alternative we should *not* pursue:  return just the exception 
from sys.exc_info().  For compatibility, we would implement `__iter__` and 
`__getitem__` on BaseException, to duplicate the behavior of the current tuple. 
 There are a number of good reasons why this is *not* what we should do.

--

___
Python tracker 

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



[issue46328] add sys.exception()

2022-01-10 Thread Eric Snow


Eric Snow  added the comment:

So sys.exception() will be equivalent to sys.exc_info()[1] (or rather, 
sys.exc_info() will be (type(sys.exception()), sys.exception(), 
sys.exception().__traceback__))?

That seems good to me.

--
nosy: +eric.snow

___
Python tracker 

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



[issue46326] 'virtualenv --clear' should prompt user before nuking entire directory

2022-01-10 Thread Ned Deily


Ned Deily  added the comment:

It appears you are describing behavior in the third-party virtualenv project; 
if so, you should report the problem to that project 
(https://pypi.org/project/virtualenv/). If similar behavior is also an issue 
with the Python standard library venv module (which is a derivative of 
virtualenv), please update this issue accordingly. Thanks!

https://docs.python.org/3/library/venv.html

--
nosy: +ned.deily
status: open -> pending

___
Python tracker 

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



[issue46328] add sys.exception()

2022-01-10 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

Would there be any value in spelling this as sys.active_exception() or 
sys.current_exception() or sys.get_exception() or sys.exception_in_flight() or 
similar?

My only worry is confusion between sys.exception() versus builtins.Exception.

--
nosy: +Dennis Sweeney

___
Python tracker 

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



[issue46333] ForwardRef.__eq__ does not respect module parameter

2022-01-10 Thread Andreas H.


New submission from Andreas H. :

The __eq__ method of ForwardRef does not take into account the module 
parameter. 

However, ForwardRefs with dissimilar module parameters are referring to 
different types even if they have different name. Thus also the ForwardRef's 
with same name but different module, should not be considered equal.


Consider the following code


from typing import *

ZZ = Optional['YY'] 
YY = int

YY = Tuple[Optional[ForwardRef("YY", module=__name__)], int]
print( YY.__args__[0].__args__[0].__forward_module__ )
# this prints None, but should print __main__ (or whatever __name__ contains)


When the first ForwardRef is not created, the program behaves correctly

#ZZ = Optional['YY'] 
YY = int

YY = Tuple[Optional[ForwardRef("YY", module=__name__)], int]
print( YY.__args__[0].__args__[0].__forward_module__ )
# this prints __main__ (or whatever __name__ contains)



The issue is that the line `ZZ = Optional['YY']` creates a cache entry, which 
is re-used instead of the second definition `Optional[ForwardRef("YY", 
module=__name__)]` and thus shadows the different argument of ForwardRef.


This problem could be fixed if the __eq__ method of FowardRef also checks for 
module equality.

i.e. in ForwardRef.__eq__ in typing.py replace 

   return self.__forward_arg__ == other.__forward_arg__

with 

   return self.__forward_arg__ == other.__forward_arg__  and  
self.__forward__module__ == other.__forward__module__ 


Ideally, (and for consistency reasons) the `__repr__` method of `ForwardRef` 
would also include the module arg if it present:

Change:

def __repr__(self):
return f'ForwardRef({self.__forward_arg__!r})'

to 

def __repr__(self):
if self.__forward_module__ is None:
return f'ForwardRef({self.__forward_arg__!r})'
else:
return f'ForwardRef({self.__forward_arg__!r}, 
module={self.__forward__module!r})'

--
components: Library (Lib)
messages: 410221
nosy: andreash, gvanrossum, kj
priority: normal
severity: normal
status: open
title: ForwardRef.__eq__ does not respect module parameter
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



[issue46332] Use raise..from in logging/config instead of assigning __cause__

2022-01-10 Thread Irit Katriel


Change by Irit Katriel :


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

___
Python tracker 

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



[issue46332] Use raise..from in logging/config instead of assigning __cause__

2022-01-10 Thread Irit Katriel


Irit Katriel  added the comment:

Lib/logging/config.py has this, which looks like it's partly remnants of old 
exception handling APIs: 

except ImportError:
e, tb = sys.exc_info()[1:]
v = ValueError('Cannot resolve %r: %s' % (s, e))
v.__cause__, v.__traceback__ = e, tb
raise v

It is clearer if written as:

except ImportError as e:
v = ValueError('Cannot resolve %r: %s' % (s, e))
raise v from e


(note that this doesn't copy the traceback from e to v, but this is redundant 
information anyway because e is chained to v as the cause).

--

___
Python tracker 

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



[issue12756] datetime.datetime.utcnow should return a UTC timestamp

2022-01-10 Thread Tony Rice


Tony Rice  added the comment:

This enhancement request should be reconsidered.  

Yes it is the documented behavior but that doesn't mean it's the right 
behavior. Functions should work as expected not just in the context of the 
module they are implemented in but the context of the problem they are solving.

The suggested workaround of essentially nesting the specified UTC time via 
datetime.now(timezone.utc) is ugly rather than beautiful, complex rather than 
simple, and nested instead of flat.

The suggestion that now is preferred over isnow loses sight that UTC is not 
like other timezones.

A lot has changed since Python 2.7 was released in 2010. It is the default 
timezone of cloud infrastructure.

--
nosy: +rtphokie

___
Python tracker 

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



[issue46332] Use raise..from in logging/config instead of assigning __cause__

2022-01-10 Thread Irit Katriel


Change by Irit Katriel :


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

___
Python tracker 

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



[issue46332] Use raise..from in logging/config instead of assigning __cause__

2022-01-10 Thread Irit Katriel


Change by Irit Katriel :


--
nosy: +vinay.sajip

___
Python tracker 

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



  1   2   >