[issue46200] Discourage logging f-strings due to security considerations

2021-12-29 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +vinay.sajip

___
Python tracker 

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



[issue45853] Misspelled _IGNORED_ERROS in Lib/pathlib.py

2021-12-29 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue45853] Misspelled _IGNORED_ERROS in Lib/pathlib.py

2021-12-29 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 8d7644fa64213207b8dc6f555cb8a02bfabeced2 by andrei kulakov in 
branch 'main':
bpo-45853: Fix misspelling and unused import in pathlib (GH-30292)
https://github.com/python/cpython/commit/8d7644fa64213207b8dc6f555cb8a02bfabeced2


--

___
Python tracker 

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



[issue46200] Discourage logging f-strings due to security considerations

2021-12-29 Thread Arie Bovenberg


New submission from Arie Bovenberg :

(I've already submitted this issue to secur...@python.org, who directed me to 
propose a documentation change here)

Logging f-strings is quite popular, because the `%` style of logging is often 
considered ugly.
However, logging preformatted strings comes with security risks which should 
explicitly be mentioned in the logging documentation.

The following example illustrates the problem:

logger.info('look: %s', untrusted_string)# OK
logger.info('look: %(foo)s', {'foo', untrusted_string})  # OK
logger.info(f'look: {untrusted_string}') # OK 
(security-wise)
logger.info(f'look: {untrusted_string}', some_dict)  # DANGER!

The problem is that `untrusted_string` will be interpreted as a string template 
by the logger. 
If `untrusted_string` has the value `%(foo)9s` (where foo is present in 
`some_dict`), 
logging gets stuck trying to add over a gigabyte of whitespace to a string. 
In other words: a Denial-of-Service attack.

Of course, this combination of f-string and logger arguments is unlikely. But 
it is plausible that:
- After a refactoring to f-string, removing the dict argument is forgotten;
- A developer adding a variable to a message prefers using f-strings and thus 
creates a template mixing the two styles (e.g. `{foo} and %(bar)s`);
- The string is passed through a logging Filter or other function which adds a 
dict argument.

Open questions:
1. Do we want to simply highlight the risks, or actively discourage logging 
f-strings?

   My thoughts:
   I feel it's important enough to actively discourage logging preformatted 
strings (i.e. also .format and manual %-formatting).
   A strong recommendation will allow security linters to flag this.
   Additionally, there are other advantages to the formatting built into 
`logging` (e.g. performance).

2. Should we type annotate logger `msg` as `Literal[str]` following PEP675?

   My thoughts:
   Annotating `msg` as a literal string will greatly help enforce this best 
practice.
   The adoption of typecheckers exceeds that of security linters.

3. Where should this risk be documented?
  a. In the `logger.debug` function docs
  b. In the `logging` docs introduction (like xml.etree.elementtree)
  c. In a new "security" section of the `logging` docs
  d. An informational PEP on logging security considerations (similar to PEP672)

  My thoughts:
  I fear option (a) would not get the attention of most readers.
  Option (c) or (d) may be useful to also highlight general risks 
  of logging (i.e. log injection)

As soon as there is agreement on these questions, I would be happy to submit a 
PR.

--
assignee: docs@python
components: Documentation
messages: 409352
nosy: ariebovenberg, docs@python
priority: normal
severity: normal
status: open
title: Discourage logging f-strings due to security considerations
type: security
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



[issue46191] Conflict between using annotations in singledispatch() and MyPy

2021-12-29 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Okay. As a workaround we can explicitly specify the dispatching type:

@f.register(list)
def _(a: list[int]) -> None:
pass

--
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue46199] Calculation influenced by print

2021-12-29 Thread Eric V. Smith


Eric V. Smith  added the comment:

This is likely not a bug in python. You might have better luck asking on a 
numpy support list.

That said, what results do you get, and what do you expect to get? We don't 
know what error you're seeing.

You might replace:
print("LB: ", LB)

with:
str(LB)

and see what happens. That's the only operation that's called on LB when you're 
printing.

--
nosy: +eric.smith

___
Python tracker 

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



[issue46085] OrderedDict iterator allocates di_result unnecessarily

2021-12-29 Thread Dong-hee Na


Dong-hee Na  added the comment:

Thanks for reporting Kevin!

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



[issue46085] OrderedDict iterator allocates di_result unnecessarily

2021-12-29 Thread miss-islington


miss-islington  added the comment:


New changeset 2d4049da1f61df5cb4314d7e10b54fa556880b0e by Miss Islington (bot) 
in branch '3.9':
bpo-46085: Fix iterator cache mechanism of OrderedDict. (GH-30290)
https://github.com/python/cpython/commit/2d4049da1f61df5cb4314d7e10b54fa556880b0e


--

___
Python tracker 

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



[issue46085] OrderedDict iterator allocates di_result unnecessarily

2021-12-29 Thread miss-islington


miss-islington  added the comment:


New changeset 1b37268ef10bd20c30d349b8401c88215c8a6be8 by Miss Islington (bot) 
in branch '3.10':
bpo-46085: Fix iterator cache mechanism of OrderedDict. (GH-30290)
https://github.com/python/cpython/commit/1b37268ef10bd20c30d349b8401c88215c8a6be8


--

___
Python tracker 

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



[issue37295] Possible optimizations for math.comb()

2021-12-29 Thread Tim Peters


Tim Peters  added the comment:

[Tim]
> That's [Mark's code] cheaper than almost every case handled by
> perm_comb_small()'s current ... "iscomb" loop.

Although I should clarify they're aimed at different things, and don't overlap 
all that much. Mark's code, & even more so Raymond's extension, picks on small 
"n" and then looks for the largest "k" such that comb(n, k) can be done with 
supernatural speed.

But the existing perm_comb_small() picks on small "k" and then looks for the 
largest "n" such that "the traditional" one-at-a-time loop can complete without 
ever overflowing a C uint64 along the way.

The latter is doubtless more valuable for perm_comb_small(), since its 
recursive calls cut k roughly in half, and the first such call doesn't reduce n 
at all.

But where they do overlap (e.g., comb(50, 15)), Mark's approach is much faster, 
so that should be checked first.

--

___
Python tracker 

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



[issue46085] OrderedDict iterator allocates di_result unnecessarily

2021-12-29 Thread Dong-hee Na


Dong-hee Na  added the comment:


New changeset fb44d0589615590b1e7895ba78a038e96b15a219 by Dong-hee Na in branch 
'main':
bpo-46085: Fix iterator cache mechanism of OrderedDict. (GH-30290)
https://github.com/python/cpython/commit/fb44d0589615590b1e7895ba78a038e96b15a219


--

___
Python tracker 

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



[issue46085] OrderedDict iterator allocates di_result unnecessarily

2021-12-29 Thread miss-islington


Change by miss-islington :


--
pull_requests: +28512
pull_request: https://github.com/python/cpython/pull/30300

___
Python tracker 

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



[issue46085] OrderedDict iterator allocates di_result unnecessarily

2021-12-29 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue43424] Document the `controller.name` field in `webbrowser` module

2021-12-29 Thread Ilya Grigoriev


Ilya Grigoriev  added the comment:

Thank you very much, Nikita! Your patch would certainly solve my issue.

As is, I checked the code I wrote, and it seems that only a lucky
ordering of if-statements caused it to work on Macs.

Ilya.

On Wed, Dec 29, 2021 at 5:30 PM Dong-hee Na  wrote:
>
>
> Dong-hee Na  added the comment:
>
>
> New changeset d12bec69931503be78cd555cf7bc22ad6f4f2bd5 by Nikita Sobolev in 
> branch 'main':
> bpo-43424: Deprecate `webbrowser.MacOSXOSAScript._name` attribute (GH-30241)
> https://github.com/python/cpython/commit/d12bec69931503be78cd555cf7bc22ad6f4f2bd5
>
>
> --
> nosy: +corona10
>
> ___
> Python tracker 
> 
> ___

--

___
Python tracker 

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



[issue46199] Calculation influenced by print

2021-12-29 Thread wby78826


New submission from wby78826 :

(Could be a numpy bug)
##Just run the script, then uncomment Line 14 and run again
The result of "supertrend" is different, depending on whether I print "LB" 
first or not.
If I don't print it first, the result is wrong.

It also does'nt matter if I print it to stdout or stderr, it only works this 
way.

(sry if I did something wrong)

--
components: Windows
files: supertrend.py
messages: 409343
nosy: paul.moore, steve.dower, tim.golden, wby78826, zach.ware
priority: normal
severity: normal
status: open
title: Calculation influenced by print
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file50527/supertrend.py

___
Python tracker 

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



[issue43424] Document the `controller.name` field in `webbrowser` module

2021-12-29 Thread Dong-hee Na


Dong-hee Na  added the comment:


New changeset d12bec69931503be78cd555cf7bc22ad6f4f2bd5 by Nikita Sobolev in 
branch 'main':
bpo-43424: Deprecate `webbrowser.MacOSXOSAScript._name` attribute (GH-30241)
https://github.com/python/cpython/commit/d12bec69931503be78cd555cf7bc22ad6f4f2bd5


--
nosy: +corona10

___
Python tracker 

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



[issue41569] json.JSONEncoder.default should be called for dict keys as well

2021-12-29 Thread Andrei Kulakov


Change by Andrei Kulakov :


--
nosy: +kj
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> json.dump() ignores its 'default' option when serializing 
dictionary keys

___
Python tracker 

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



[issue46195] Annotated and Optional get_type_hints buggy interaction

2021-12-29 Thread Nikita Sobolev


Nikita Sobolev  added the comment:

And on 3.9 as well.

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



[issue46195] Annotated and Optional get_type_hints buggy interaction

2021-12-29 Thread Nikita Sobolev


Change by Nikita Sobolev :


--
versions: +Python 3.10, 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



[issue46195] Annotated and Optional get_type_hints buggy interaction

2021-12-29 Thread Nikita Sobolev


Nikita Sobolev  added the comment:

I can verify that this happens on `3.10` and `main` branches:

```
from typing import Annotated, Optional, get_type_hints

class Foo:
def __init__(self, x: Annotated[Optional[str], "d"] = None): ...

class Foo2:
x: Annotated[Optional[str], "d"] = None

print(get_type_hints(Foo.__init__, include_extras=False))  # ok
# {'x': typing.Optional[str]}
print(get_type_hints(Foo2, include_extras=False))  # ok
# {'x': typing.Optional[str]}

print(get_type_hints(Foo.__init__, include_extras=True))  # not ok?
# {'x': typing.Optional[typing.Annotated[typing.Optional[str], 'd']]}
print(get_type_hints(Foo2, include_extras=True))  # ok
# {'x': typing.Annotated[typing.Optional[str], 'd']}
```

Notice that 3rd case does not look correct: `{'x': 
typing.Optional[typing.Annotated[typing.Optional[str], 'd']]}`

In my opinion it should be `{'x': typing.Annotated[typing.Optional[str], 'd']}`

I will look into it! :)

--
nosy: +sobolevn

___
Python tracker 

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



[issue46198] Duplicated test name `test_get_unstructured_invalid_ew` in `test__header_value_parser.py`

2021-12-29 Thread Nikita Sobolev


Change by Nikita Sobolev :


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

___
Python tracker 

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



[issue46191] Conflict between using annotations in singledispatch() and MyPy

2021-12-29 Thread Alex Waygood


Alex Waygood  added the comment:

Yeah, I think I agree with Guido. Mypy only has partial support for 
singledispatch anyway, and only achieves that through a plugin, so 
special-casing by type-checkers is inevitable.

--

___
Python tracker 

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



[issue46198] Duplicated test name `test_get_unstructured_invalid_ew` in `test__header_value_parser.py`

2021-12-29 Thread Nikita Sobolev


New submission from Nikita Sobolev :

There are two tests with the same name in a same test class in 
`Lib/test/test_email/test__header_value_parser.py`: 
`test_get_unstructured_invalid_ew`

1. 
https://github.com/python/cpython/blob/8e11237c5d24e649b26cc928b52bc37f2fde9c7a/Lib/test/test_email/test__header_value_parser.py#L304
2. 
https://github.com/python/cpython/blob/8e11237c5d24e649b26cc928b52bc37f2fde9c7a/Lib/test/test_email/test__header_value_parser.py#L398

So, because of this bad naming - the first test is always shadowed by the 
second one and is silently skipped. With my patch: 1660 tests, without: 1659 
tests.

PR to rename the second test is on its way.

--
components: Tests
messages: 409338
nosy: sobolevn
priority: normal
severity: normal
status: open
title: Duplicated test name `test_get_unstructured_invalid_ew` in 
`test__header_value_parser.py`
type: behavior
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



[issue13672] Add co_qualname attribute in code objects

2021-12-29 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> duplicate
stage: patch review -> resolved
status: open -> closed
superseder:  -> Propagate qualname from the compiler unit to code objects for 
finer grained profiling data

___
Python tracker 

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



[issue12535] Chained tracebacks are confusing because the first traceback is minimal

2021-12-29 Thread Irit Katriel


Irit Katriel  added the comment:

This was created about 10 years ago, I wonder if people still feel there is a 
need to change something here, or did we all get used to the status quo by now?

In particular, the suggestion is to indicate that the traceback of chained 
exceptions is truncated.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue46191] Conflict between using annotations in singledispatch() and MyPy

2021-12-29 Thread Guido van Rossum


Guido van Rossum  added the comment:

If we allow registering list[int] but give it the same meaning as registering 
plain list (at runtime), that would violate user expectations pretty strongly 
-- for the same reason why we don't allow isinstance(x, list[int]).

If you want stronger checking inside the function you should probably do 
something like

@foo.register
def _(_a: list) -> ...:
a: list[int] = _a
...

That said I don't care enough about singledispatch to argue strongly.

--

___
Python tracker 

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



[issue45108] frame.f_lasti points at DICT_MERGE instead of CALL_FUNCTION_EX in Windows only

2021-12-29 Thread Irit Katriel


Irit Katriel  added the comment:

I've reproduced this on 3.10 but in 3.11 the result on windows is correct, 
f_lasti is of the CALL_FUNCTION_EX opcode.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue46197] ensurepip bootstrap breaks out of isolated environment

2021-12-29 Thread kcdodd


New submission from kcdodd :

A change in behavior was made to the `ensurepip` module in Python 3.8.7 that 
causes bootstrapping to break out of an isolated environment. This is relevant 
to the assumption made in the `venv` module, which ran ensurepip as a 
sub-process with the `-I` flag environment isolation to force installation in 
the virtual environment directory.

In Python <= 3.8.6, ensurepip ran the bootstrap within the current interpreter, 
so the environment remained isolated. But in Python >= 3.8.7 it creates a 
second subprocess without the `-I` flag, and the un-isolated environment 
appears to be restored for pip. This would then allow a search of any 
additional paths, and prevent installation of pip and setuptools from being 
installed in the venv environment directory if they are found somewhere else.

--
messages: 409334
nosy: kcdodd
priority: normal
severity: normal
status: open
title: ensurepip bootstrap breaks out of isolated environment
type: behavior
versions: Python 3.10, Python 3.11, 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



[issue38522] Py_USING_MEMORY_DEBUGGER is referenced in docs but not present in code

2021-12-29 Thread Benjamin Peterson


Benjamin Peterson  added the comment:


New changeset 9f0e40fae5191c3e3ed6109bd2e2f97aa0ac8d64 by Miss Islington (bot) 
in branch '3.10':
closes bpo-38522 docs: remove references to Py_USING_MEMORY_DEBUGGER (GH-30284) 
(GH-30295)
https://github.com/python/cpython/commit/9f0e40fae5191c3e3ed6109bd2e2f97aa0ac8d64


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



[issue9350] add remove_argument_group to argparse

2021-12-29 Thread Irit Katriel


Change by Irit Katriel :


--
stage: needs patch -> 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



[issue46196] documentation for cmd library should include columnize() function

2021-12-29 Thread sharewell


New submission from sharewell :

Cmd.columnize is an extremely useful function in Python, that can be used in 
many situations. It is part of the Cmd library. Unfortunately, the Cmd 
documentation does not mention it. It should. I only found out about it via 
https://stackoverflow.com/a/59627245

Please add to the documentation: https://docs.python.org/3/library/cmd.html

--
assignee: docs@python
components: Documentation
messages: 409332
nosy: docs@python, sharewell
priority: normal
severity: normal
status: open
title: documentation for cmd library should include columnize() function
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



[issue17024] cElementTree calls end() on parser taget even if start() fails

2021-12-29 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> works for me
stage: needs patch -> 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



[issue37295] Possible optimizations for math.comb()

2021-12-29 Thread Tim Peters


Tim Peters  added the comment:

A practical caution about this in comb_with_side_limits.py:

Pmax = 25   # 25 41
Fmax = Pmax

It's true then that 25! == F[25] << S[25], but that's so in Python. The result 
has 84 bits, so 64-bit C arithmetic isn't enough.

That's apparently why mathmodule.c's static SmallFactorials[] table ends at 20 
(the largest n such that n! fits in 64 bits).

(Well, actually, it ends at 12 on Windows, where sizeof(long) is 4, even on 
"modern" 64-bit boxes)

I would, of course, use uint64_t for these things - "long" and "long long" are 
nuisances, and not even attractive ones ;-) While support (both software and 
HW) for 64-bit ints progressed steadily in the 32-bit era, the same does not 
appear to be true of 128-bit ints in the 64-bit era. Looks to me like 64-bit 
ints will become as much a universal HW truth as, say, 2's-complement, and byte 
addresses, have become.

--

___
Python tracker 

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



[issue28141] shutil.copystat utime lookup fails on certain Android file systems

2021-12-29 Thread Irit Katriel


Irit Katriel  added the comment:

Please create a new issue if this is still a problem on a currentl version of 
python (>= 3.9).

--
resolution:  -> out of date
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



[issue38522] Py_USING_MEMORY_DEBUGGER is referenced in docs but not present in code

2021-12-29 Thread miss-islington


Change by miss-islington :


--
pull_requests: +28509
pull_request: https://github.com/python/cpython/pull/30296

___
Python tracker 

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



[issue38522] Py_USING_MEMORY_DEBUGGER is referenced in docs but not present in code

2021-12-29 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue46185] Python 3.10.1 installer refers to /Applications/Python 3.9 Install Certificates

2021-12-29 Thread Erlend E. Aasland

Erlend E. Aasland  added the comment:

Thanks for the report, Jaap, and thanks Łukasz for merging :)

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

___
Python tracker 

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



[issue46120] Add note to `typing.Union` that it is recommended to use `|` instead

2021-12-29 Thread Nikita Sobolev

Nikita Sobolev  added the comment:

Thank you for your time, Łukasz!

--

___
Python tracker 

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



[issue38522] Py_USING_MEMORY_DEBUGGER is referenced in docs but not present in code

2021-12-29 Thread Carlos Damazio


Carlos Damazio  added the comment:

Opened a PR for this issue. It'll remove the mentions to the 
`Py_USING_MEMORY_DEBUGGER` since it'd been removed 5 years ago.

--
nosy: +carlosdamazio

___
Python tracker 

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



[issue46194] Wrong base class for transport returned by loop.create_datagram_endpoint()

2021-12-29 Thread Carlos Damazio


Carlos Damazio  added the comment:

I think I have a fix for this, I opened a PR. Let me know if you have any 
questions.

--
nosy: +carlosdamazio

___
Python tracker 

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



[issue23952] cgi: Document the 'maxlen' member of the cgi module

2021-12-29 Thread Yatin Kanetkar


Change by Yatin Kanetkar :


--
nosy: +yatink

___
Python tracker 

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



[issue46195] Annotated and Optional get_type_hints buggy interaction

2021-12-29 Thread Guido van Rossum


Guido van Rossum  added the comment:

Could you try with 3.10 and the stdlib typing.Annotated please? There might
be changes (in the past a default of None automatically caused an Optional
to be added, but we changed our minds.--
--Guido (mobile)

--

___
Python tracker 

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



[issue22859] unittest.TestProgram.usageExit no longer invoked

2021-12-29 Thread Carlos Damazio


Carlos Damazio  added the comment:

Well, to this issue, I'm going to put a PR to remove it and give it a chance 
for it to being reinstated if you folks want to.

--
nosy: +carlosdamazio -dmzz

___
Python tracker 

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



[issue46185] Python 3.10.1 installer refers to /Applications/Python 3.9 Install Certificates

2021-12-29 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset c31fdef1e71ff1598f213b1b4ad1a565e47d7864 by Erlend Egeberg 
Aasland in branch '3.10':
[3.10] bpo-46185: Fix wrong version ref. in macOS installer ReadMe (GH-30280)
https://github.com/python/cpython/commit/c31fdef1e71ff1598f213b1b4ad1a565e47d7864


--

___
Python tracker 

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



[issue46185] Python 3.10.1 installer refers to /Applications/Python 3.9 Install Certificates

2021-12-29 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset bc87ac6d0b13116f525215f8a31b46506bc8d629 by Erlend Egeberg 
Aasland in branch 'main':
bpo-46185: Fix wrong version ref. in macOS installer ReadMe (GH-30278)
https://github.com/python/cpython/commit/bc87ac6d0b13116f525215f8a31b46506bc8d629


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue22859] unittest.TestProgram.usageExit no longer invoked

2021-12-29 Thread Carlos Damázio

Change by Carlos Damázio :


--
keywords: +patch
nosy: +dmzz
nosy_count: 1.0 -> 2.0
pull_requests: +28507
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30293

___
Python tracker 

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



[issue37295] Possible optimizations for math.comb()

2021-12-29 Thread Tim Peters


Tim Peters  added the comment:

{Serhiy]
> It can benefit larger arguments if move the code in
> perm_comb_small().

Seems pretty clear that the newer code really belongs there instead.

> And perhaps loops in perm_comb_small() could be optimized 
> by using precalculated values for some products.

For all n <= 67, the newer code computes comb(n, k), for all k, in a small and 
fixed number of operations, all in platform C arithmetic. Two multiplies, a 
shift, and some fiddling to compute the shift count. No divisions. That's 
cheaper than almost every case handled by perm_comb_small()'s current

k < Py_ARRAY_LENGTH(fast_comb_limits)
   && n <= fast_comb_limits[k])

"iscomb" loop. That loop is constrained by that all intermediate results have 
to fit in a C unsigned long long, but the newer code only needs to know that 
the _final_ result fits (intermediate overflows are both expected and harmless 
- indeed, they're _necessary_ for the modular arithmetic to work as intended).

--

___
Python tracker 

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



[issue46195] Annotated and Optional get_type_hints buggy interaction

2021-12-29 Thread Mehdi2277


Change by Mehdi2277 :


--
type:  -> behavior

___
Python tracker 

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



[issue45853] Misspelled _IGNORED_ERROS in Lib/pathlib.py

2021-12-29 Thread Andrei Kulakov


Change by Andrei Kulakov :


--
pull_requests: +28506
pull_request: https://github.com/python/cpython/pull/30292

___
Python tracker 

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



[issue37295] Possible optimizations for math.comb()

2021-12-29 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> Did you try running that?

Yes.  The table size was extended beyond what we have now. See attached file.

--
Added file: https://bugs.python.org/file50526/comb_with_side_limits.py

___
Python tracker 

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



[issue46195] Annotated and Optional get_type_hints buggy interaction

2021-12-29 Thread Mehdi2277


New submission from Mehdi2277 :

This is two closely related issues with get_type_hints on an optional annotated 
member. I'm testing with Annotated/get_type_hints from typing extensions on 3.8 
and assuming they're backport equivalent to current behavior.

The first issue is get_type_hints has inconsistent behavior depending on 
whether annotation comes from a function with a None default or an attribute 
with a None default.

class Foo:
def __init__(
self,
x: 
Annotated[Optional[str], "doc string"] = None,
):
...

class Foo2:
x: Annotated[Optional[str], "doc string"] = None

get_type_hints(Foo.__init__) 
# {'x': typing.Union[typing_extensions.Annotated[typing.Union[str, NoneType], 
'doc string'], NoneType]}

get_type_hints(Foo2)
# {'x': typing_extensions.Annotated[typing.Union[str, NoneType], 'doc string']}

Attributes with a None default are not wrapped by get_type_hints, but function 
parameters. Which of the two behaviors is correct I don't know, but I'd expect 
the two to be equivalent annotations.

The second issue is for function arguments with a None default the optional 
wrapper happens even if the type inside annotated already has optional. Example,

from typing_extensions import Annotated, get_type_hints

class Foo:
def __init__(
self,
x: 
Annotated[Optional[str], "doc string"] = None,
):
...

get_type_hints(Foo.__init__, include_extras=True)
# {'x': typing.Union[typing_extensions.Annotated[typing.Union[str, NoneType], 
'doc string'], NoneType]}


For Annotated types I would expect any type rules like wrapping to apply only 
to the first argument and not the entire annotation. I mainly ran into this for 
a runtime type introspection library (similar in spirit to pydantic).

As a note include_extras being True or False while it changes type is an issue 
in either case. With include_extras as False the Annotated goes away, but the 
type still gets double wrapped as an Optional.

--
messages: 409319
nosy: gvanrossum, kj, med2277
priority: normal
severity: normal
status: open
title: Annotated and Optional get_type_hints buggy interaction
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



[issue41593] pathlib PermissionError problem

2021-12-29 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

Cannot reproduce on 3.9 and 3.11; the quoted fragment of code is no longer in 
pathlib.

Closing as fixed as it seems that it was fixed in 3.9 or earlier.

Please comment if you think it should be reopened.

--
nosy: +andrei.avk, kj
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue37295] Possible optimizations for math.comb()

2021-12-29 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I think Raymond means extending the tables to TableSize=101. It can benefit 
larger arguments if move the code in perm_comb_small(). And perhaps loops in 
perm_comb_small() could be optimized by using precalculated values for some 
products.

--

___
Python tracker 

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



[issue46120] Add note to `typing.Union` that it is recommended to use `|` instead

2021-12-29 Thread Łukasz Langa

Łukasz Langa  added the comment:

Haha, that backport took more time than I thought :D

Thanks! ✨  ✨

--
nosy: +lukasz.langa

___
Python tracker 

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



[issue37295] Possible optimizations for math.comb()

2021-12-29 Thread Tim Peters


Tim Peters  added the comment:

About:

TableSize = 101
limits = bytearray(TableSize)
for n in range(0, TableSize):
for k in range(0, n+1):
if comb(n, k) != comb_small(n, k):

(and regardless of whether the last line is replaced with the later correction):

Did you try running that? Assuming "comb_small()" refers to the earlier Python 
function of that name you posted, it dies in the obvious way:

Traceback (most recent call last):
  File "C:\MyPy\temp3.py", line 29414, in 
if comb(n, k) != comb_small(n, k) % Modulus:
  File "C:\MyPy\temp3.py", line 29404, in comb_small
return (F[n] * Finv[k] * Finv[n-k] % Modulus) << (S[n] - S[k] - S[n-k])
IndexError: list index out of range

This occurs, as expected, when n first reaches 68 (because Cmax = 67 in the 
code posted for comb_small()).

So it's unclear what you intended to say. Certainly, the current mathmodule.c 
perm_comb_small() (where "small" appears to mean merely that the args fit in C 
"unsigned long long") makes no attempt to exploit the newer n <= 67 code Mark 
checked in.

--

___
Python tracker 

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



[issue46191] Conflict between using annotations in singledispatch() and MyPy

2021-12-29 Thread Alex Waygood


Alex Waygood  added the comment:

I like Serhiy's idea from a type-checking perspective. It would mean we could 
continue to have sophisticated type inference from mypy/pyright/etc. inside 
singledispatch function definitions. It would also mean people could use type 
annotations in singledispatch functions in much the same way as in the rest of 
their code, instead of having to remember that *this specific stdlib function* 
works differently. Lastly, it avoids having to have each type-checker 
separately special-case singledispatch so that they do not raise an error when 
an unparameterised generic is used as a type annotation. 

My concern, however, is that the runtime semantics are slightly unintuitive. 
Registering an implementation to the "type" `list[str]` (and having it succeed 
without an error being raised) might give the false implication that there will 
be runtime checking of whether all the elements in a list are strings.

I also think that GenericAlias objects should probably only be accepted in the 
form of `singledispatch.register()` that parses type annotations. There's no 
use case for allowing GenericAlias objects in the other forms of registering 
implementations.

--

___
Python tracker 

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



[issue46191] Conflict between using annotations in singledispatch() and MyPy

2021-12-29 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I do not think there is a problem in MyPy. What if use __origin__ for 
dispatching? Registering with parametrized generics with the same __origin__ 
will be error.

@sigledispatch
def f(a: int) -> None:
pass

@f.register  # ok
def _(a: list[int]) -> None:
pass

@f.register  # runtime error
def _(a: list[str]) -> None:
pass

@f.register  # runtime error
def _(a: list) -> None:
pass

f(1)  # ok
f([1])  # ok
f([])  # ok
f(['abc'])  # static type checking error

I think that it will have advantage of stronger static type checking.

--

___
Python tracker 

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



[issue46187] Optionally support rounding for math.isqrt()

2021-12-29 Thread Tim Peters


Tim Peters  added the comment:

All cool. Since I doubt these new rounding modes will get much use anyway, it's 
not worth arguing about. If I were to do this for myself, the rounding argument 
would be one of the three values {-1, 0, +1}, which are already more than good 
enough as mnemonics for "go down, get close, go up". Passing strings of any 
kind is already pedantic overkill ;-)

--

___
Python tracker 

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



[issue46194] Wrong base class for transport returned by loop.create_datagram_endpoint()

2021-12-29 Thread Carlos Damázio

Change by Carlos Damázio :


--
keywords: +patch
nosy: +dmzz
nosy_count: 2.0 -> 3.0
pull_requests: +28505
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30291

___
Python tracker 

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



[issue34498] Python 3.7+ break on singledispatch_function.register(pseudo_type), which Python 3.6 accepted

2021-12-29 Thread Guido van Rossum


Guido van Rossum  added the comment:

Let's close this issue as "won't fix" then. The solution "use 
collections.abc.Sequence" makes sense.

--

___
Python tracker 

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



[issue46191] Conflict between using annotations in singledispatch() and MyPy

2021-12-29 Thread Guido van Rossum


Guido van Rossum  added the comment:

That mypy error is only reported with a certain mypy setting (--strict, or 
probably one of the specific settings that that turns on).

We won't be supporting Sequence[Any] at runtime (because we only support actual 
types), but we should support Sequence, since that *is* an actual type (at 
least collections.abc.Sequence is).

So IMO this is either a problem in mypy (though in that case probably in 
typeshed) or a situation for which the user should just silence mypy (it's not 
perfect and never claimed to be).

But I think there's nothing for us to do in Python itself, so this bug should 
be closed.

--

___
Python tracker 

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



[issue46085] OrderedDict iterator allocates di_result unnecessarily

2021-12-29 Thread Dong-hee Na


Change by Dong-hee Na :


--
keywords: +patch
nosy: +corona10
nosy_count: 4.0 -> 5.0
pull_requests: +28504
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30290

___
Python tracker 

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



[issue46194] Wrong base class for transport returned by loop.create_datagram_endpoint()

2021-12-29 Thread Andrew Svetlov


New submission from Andrew Svetlov :

Selector-based event loops returns `_SelectorDatagramTransport` which inherits 
`asyncio.Transport` instead of `asyncio.DatagramTransport`.

isinstance(transp, asyncio.DatagramTransport) fails.
It doesn't affect the actual execution since `transp.sendto()` and 
`transp.error_received()` are correctly implemented.

The bug doesn't affect Windows proactor-based implementation.

The fix is relatively easy, a champion is welcome!

--
components: asyncio
messages: 409309
nosy: asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: Wrong base class for transport returned by 
loop.create_datagram_endpoint()
versions: Python 3.10, Python 3.11, 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



[issue45711] Simplify the interpreter's (type, val, tb) exception representation

2021-12-29 Thread Irit Katriel


Change by Irit Katriel :


--
pull_requests: +28503
pull_request: https://github.com/python/cpython/pull/30289

___
Python tracker 

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



[issue46193] Using a dictionary for open files.

2021-12-29 Thread Keepun


Keepun  added the comment:

I didn't think about calculating the argument before passing it to the 
function...

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



[issue46176] mmap module add MAP_STACK constant mostly for OpenBSD

2021-12-29 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy:  -corona10
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



[issue46176] mmap module add MAP_STACK constant mostly for OpenBSD

2021-12-29 Thread Dong-hee Na


New submission from Dong-hee Na :


New changeset 66c47b63a0df3143fe48d6efc1183eecda2a363d by David CARLIER in 
branch 'main':
bpo-46176: mmap module adding MAP_STACK constant. (GH-30252)
https://github.com/python/cpython/commit/66c47b63a0df3143fe48d6efc1183eecda2a363d


--
nosy: +corona10

___
Python tracker 

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



[issue26552] Failing ensure_future still creates a Task

2021-12-29 Thread Kumar Aditya


Change by Kumar Aditya :


--
nosy: +kumaraditya303
nosy_count: 5.0 -> 6.0
pull_requests: +28502
pull_request: https://github.com/python/cpython/pull/30288

___
Python tracker 

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



[issue38397] __init_subclass__ causes TypeError when used with more standard library metaclasses (such as EnumMeta)

2021-12-29 Thread Alex Waygood


Alex Waygood  added the comment:

I am closing this, as I believe it was fixed by the addition of **kwds to 
EnumMeta. Feel free to reopen this if you disagree, @retnikt.

--
nosy: +AlexWaygood
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue46193] Using a dictionary for open files.

2021-12-29 Thread Eryk Sun


Eryk Sun  added the comment:

Every time open(r"test.txt", "w") is called, the existing "test.txt" file gets 
overwritten in the filesystem as an empty file. For each iteration, 
setdefault() returns a reference to the first file object, which advances its 
file pointer with each fh.write("\nHello\n") call. For the last write, the file 
pointer is at offset 693 (i.e. 7 * 99), and the OS first writes null bytes up 
to the file pointer. This is normal behavior, not a bug.

--
nosy: +eryksun

___
Python tracker 

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



[issue26552] Failing ensure_future still creates a Task

2021-12-29 Thread Carlos Damázio

Change by Carlos Damázio :


--
keywords: +patch
nosy: +dmzz
nosy_count: 4.0 -> 5.0
pull_requests: +28501
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30287

___
Python tracker 

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



[issue38401] Make dataclass attribute docstrings accessible

2021-12-29 Thread Erik Gebeshuber


Erik Gebeshuber  added the comment:

There is some confusion in the answers that I want to clear up:

"Attribute docstrings" were suggested in PEP 224 in August 2000 and rejected 
March 2001: https://www.python.org/dev/peps/pep-0224/

taleinat mentioned already PEP 258 from May 2001, which also contained 
"attribute docstrings" and was as well rejected.

At the same time - May 2001 - the well-known PEP 257 about docstring 
conventions came up and was accepted. It also mentions "attribute docstrings", 
but in a kind of restricted way (highlighting *** by me):

> String literals occurring elsewhere in Python code ***may also act as 
> documentation***. They are ***not recognized*** by the Python bytecode 
> compiler and are ***not accessible*** as runtime object attributes (i.e. not 
> assigned to __doc__), ...
> Please see PEP 258, "Docutils Design Specification" [2], for a detailed 
> description of attribute and additional docstrings.

The reference to the rejected PEP 258 does in my opinion not make the concept 
of "attribute docstrings" invalid, but indeed the restrictive wording 
(highlighted *** in the quote) defines their status, and it helps to explain 
the situation:

* Attribute docstrings are not supported by Python itself (no __doc__ etc.) -> 
that's why it is hard to add support for dataclass documentation in `help` as 
John Parejko suggested.

* It is totally fine to use attribute docstrings, since PEP 257 explicitly 
mentions them. Various tools support them.

* There is - as far as I can see it - no clear notion to differentiate between 
"official" docstrings and "inofficial" ones (attribute docstrings, additional 
docstrings). All of them are docstrings in the broader sense, though most times 
only the "official" ones are meant, and many don't even know about the 
"inofficial" ones.

--
nosy: +egebes

___
Python tracker 

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



[issue46193] Using a dictionary for open files.

2021-12-29 Thread Keepun


New submission from Keepun :

"""
Using a dictionary for open files.

The file is filled with NULL. Only the last entry is normal.

Result:
00 00 00 00 ... 00 0A 48 65 6C 6C 6F 0A

Ubuntu - 3.8.10
Windows - 3.9.8
"""
fhandles = {}
for f in range(100):
fh = fhandles.setdefault("suffix", open(r"test.txt", "w"))
fh.write("\nHello\n")
fh.flush()
for f in fhandles.values():
f.close()

import sys
print(sys.version_info)

--
components: IO
messages: 409303
nosy: Keepun
priority: normal
severity: normal
status: open
title: Using a dictionary for open files.
type: behavior
versions: 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



[issue30420] [doc] subprocess module: Clarify kwarg handing for convenience APIs

2021-12-29 Thread Alex Waygood


Change by Alex Waygood :


--
title: Clarify kwarg handing for subprocess convenience APIs -> [doc] 
subprocess module: Clarify kwarg handing for convenience APIs

___
Python tracker 

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



[issue46120] Add note to `typing.Union` that it is recommended to use `|` instead

2021-12-29 Thread Alex Waygood


Change by Alex Waygood :


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



[issue46120] Add note to `typing.Union` that it is recommended to use `|` instead

2021-12-29 Thread miss-islington


miss-islington  added the comment:


New changeset ed1671ced7c9b951dfc16a0cf32a2b4eab914cf1 by Miss Islington (bot) 
in branch '3.10':
[3.10] bpo-46120: State that `|` is preferred over `Union` (GH-30222) (GH-30250)
https://github.com/python/cpython/commit/ed1671ced7c9b951dfc16a0cf32a2b4eab914cf1


--

___
Python tracker 

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



[issue45853] Misspelled _IGNORED_ERROS in Lib/pathlib.py

2021-12-29 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It was assigned to a variable initially because it was used in multiple places. 
Now it is only used in one place, but I agree with keeping the variable for 
readability.

But it should be named _IGNORED_ERRNOS.

--

___
Python tracker 

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



[issue46190] Omit k in random.sample()

2021-12-29 Thread Tilman Krummeck


Tilman Krummeck  added the comment:

Hmm, ok, that sounds obvious. Thanks for the clarification.

--

___
Python tracker 

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



[issue46191] Conflict between using annotations in singledispatch() and MyPy

2021-12-29 Thread Alex Waygood


Change by Alex Waygood :


--
nosy: +AlexWaygood, lukasz.langa

___
Python tracker 

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



[issue46192] Optimize builtin functions min() and max()

2021-12-29 Thread colorfulappl


Change by colorfulappl :


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

___
Python tracker 

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



[issue46192] Optimize builtin functions min() and max()

2021-12-29 Thread colorfulappl


Change by colorfulappl :


--
type:  -> performance

___
Python tracker 

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



[issue46192] Optimize builtin functions min() and max()

2021-12-29 Thread colorfulappl


New submission from colorfulappl :

https://github.com/faster-cpython/ideas/discussions/199

--
components: Interpreter Core
messages: 409299
nosy: colorfulappl
priority: normal
severity: normal
status: open
title: Optimize builtin functions min() and max()
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



[issue37295] Possible optimizations for math.comb()

2021-12-29 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

- if comb(n, k) != comb_small(n, k):
+ if comb(n, k) != comb_small(n, k) % Modulus:

--

___
Python tracker 

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



[issue43639] Do not raise AttributeError on instance attribute update/deletion if data descriptor with missing __set__/__delete__ method found on its type

2021-12-29 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
assignee:  -> rhettinger

___
Python tracker 

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



[issue43639] Do not raise AttributeError on instance attribute update/deletion if data descriptor with missing __set__/__delete__ method found on its type

2021-12-29 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

I'm going to decline this one.  

* It is arguable whether or not this behavior should have been designed in 
originally.  However, changing it now is risky (as noted by Brett and Ethan).

* Personally, I disagree with the notion of allowing a partial pass through.  
That seems hazardous and error-prone to me.  It is easier to reason about data 
descriptors being all or nothing.  I like that AttributeError is raised while 
still allowing me to add the missing methods if I want to explicitly define 
some other behavior. 

* This has been open for 9 months and no one else stepped forward to champion 
it.

* For two decades, no one has complained that the current behavior got in the 
way of what they were trying to do.  That provides some evidence that there 
isn't a real world problem to be solved.

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



[issue34498] Python 3.7+ break on singledispatch_function.register(pseudo_type), which Python 3.6 accepted

2021-12-29 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

The original issue is about dispatching on non-parametrized generics like 
typing.Sequence. isinstance([], typing.Sequence) works, so it could be possible 
to support dispatching on typing.Sequence. But I have doubts that it is worth 
to revive such feature, because it needs some effort, and you can use 
collections.abc.Sequence instead.

But there is a conflict between using annotations in singledispatch() and MyPy 
(issue46191).

--

___
Python tracker 

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



[issue46191] Conflict between using annotations in singledispatch() and MyPy

2021-12-29 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

You can dispatch on collections.abc.Sequence.

@functools.singledispatch
def f(a: collections.abc.Sequence) -> None:
pass

But MyPy complains about this:

error: Missing type parameters for generic type "Sequence"

MyPy requires parametrized generic (like collections.abc.Sequence[int]), but 
singledispatch() does not work with it.

--
components: Library (Lib)
messages: 409295
nosy: gvanrossum, kj, rhettinger, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Conflict between using annotations in singledispatch() and MyPy
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



[issue46187] Optionally support rounding for math.isqrt()

2021-12-29 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> So use decimal's ROUND_CEILING, ROUND_FLOOR, and ROUND_HALF_EVEN

It think is would suck to have to type those out.  Sorry, I think you're headed 
down the path of foolish consistency with an unrelated module and a more 
complicated topic.  What's wrong with keeping consistent the name of the 
existing functions: round, floor, and ceil which are self-explanatory and much 
better known than the decimal module constants.  Also, the intent for these to 
be substitutable for existing code which uses round(sqrt(x)), floor(sqrt(x)), 
and ceil(sqrt(x)).  If those are the starting point, then round, floor, and 
ceil are a logical progression from the existing code.  It is also consistent 
with how the numeric tower approaches various ways of rounding.

--

___
Python tracker 

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



[issue46190] Omit k in random.sample()

2021-12-29 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

The use case isn't bizarre.  But having an API where that is the default 
behavior would be.  From the point of view of most users, such an API would be 
unusual and surprising (I don't know of any other random package that has such 
a default).

--

___
Python tracker 

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