[issue44123] make function parameter sentinel value true singletons

2021-05-13 Thread Tal Einat


New submission from Tal Einat :

I recently noticed that some functions use sentinel values to differentiate 
between not having been passed any value vs. None. One example of this is 
traceback.print_exception(), hence I'm adding Irit to the nosy list.

However, using e.g. `sentinel = object()` or a single instance of a dedicated 
class/type can break when combined with pickling (see examples below).

Since these sentinel are usually compared using the `is` operator, having more 
than a single instance will break things, sometimes in very confusing ways.

I suggest ensuring that a single instance is always used, probably by using a 
class with a __new__() method making sure to always return a single instance.


>>> sentinel = object()
>>> sentinel2 = pickle.loads(pickle.dumps(sentinel))
>>> sentinel is sentinel2
False
>>> sentinel

>>> sentinel2



>>> class A:
... pass
... 
>>> a = A()
>>> a2 = pickle.loads(pickle.dumps(a))
>>> a is a2
False
>>> a
<__main__.A object at 0x7fd00a9972f0>
>>> a2
<__main__.A object at 0x7fd009599450>

--
components: Library (Lib)
messages: 393580
nosy: iritkatriel, taleinat
priority: normal
severity: normal
status: open
title: make function parameter sentinel value true singletons
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



[issue39906] pathlib.Path: add `follow_symlinks` argument to `stat()` and `chmod()`

2021-05-13 Thread miss-islington


miss-islington  added the comment:


New changeset 2d972b8e7cb5347ddf83dfcee461f550b59f0736 by Miss Islington (bot) 
in branch '3.10':
bpo-39906: Document new follow_symlinks argument to pathlib.Path.stat() and 
chmod() in 3.10 whatsnew. (GH-26089)
https://github.com/python/cpython/commit/2d972b8e7cb5347ddf83dfcee461f550b59f0736


--

___
Python tracker 

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



[issue44123] make function parameter sentinel value true singletons

2021-05-13 Thread Zachary Ware


Zachary Ware  added the comment:

FWIW, at work we've been using `...` as a handy not-None singleton.

--
nosy: +zach.ware

___
Python tracker 

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



[issue40938] urllib.parse.urlunsplit makes relative path to absolute (http:g -> http:///g)

2021-05-13 Thread Open Close


Open Close  added the comment:

I tried hard (even read RFC1630),
but I think no.

--

___
Python tracker 

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



[issue44104] http.cookies.CookieError: Illegal key

2021-05-13 Thread ra1nb0w


ra1nb0w  added the comment:

Just another question: jaswdr, can you provide an example on how to filter out 
http.cookies.CookieError? thanks

--

___
Python tracker 

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



[issue43933] Regression in python3.10 with traceback frame having lineno of -1

2021-05-13 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 0acdf255a51b836c0b44f3676797620322974af3 by Mark Shannon in 
branch '3.10':
[3.10] bpo-43933: Force RETURN_VALUE bytecodes to have line numbers (GH-26061)
https://github.com/python/cpython/commit/0acdf255a51b836c0b44f3676797620322974af3


--

___
Python tracker 

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



[issue40938] urllib.parse.urlunsplit makes relative path to absolute (http:g -> http:///g)

2021-05-13 Thread Open Close


Open Close  added the comment:

hello, @jaswdr, but I can't understand what's wrong with my point.
What is 'the expected behaviour'?

--

___
Python tracker 

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



[issue43757] pathlib: move 'resolve()' logic out of path flavour

2021-05-13 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue40938] urllib.parse.urlunsplit makes relative path to absolute (http:g -> http:///g)

2021-05-13 Thread Open Close


Open Close  added the comment:

'http:///g' has absolute path '/g',
and as urljoin shows:

>>> urljoin('http://a/b/c/d', 'http:///g')
'http://a/g'  # 'a' is netloc

So you are proposing third interpretation.

  "http:g"=  "http:g" ; for strict parsers
  /  "http://a/b/c/g; ; for backward compatibility
  /  "http://a/g; ; (yours)

--

___
Python tracker 

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



[issue37658] In some cases asyncio.wait_for can lead to socket leak.

2021-05-13 Thread Denis S. Otkidach

Denis S. Otkidach  added the comment:

The original problem can be fixed by wrapping await into try-except block:

```
async def create_connection(ssl_obj):
loop = asyncio.get_event_loop()
connector = loop.create_connection(MyEchoClientProtocol, '127.0.0.1', 5000, 
ssl=ssl_obj)
connector = asyncio.ensure_future(connector)
try:
tr, pr = await connector
except asyncio.CancelledError:
if connector.done():
tr, pr = connector.result()
# Uncommenting the following line fixes the problem:
# tr.close()
raise
return tr, pr
```

I've updated my example to reproduce this: 
https://github.com/ods/bpo-37658/commit/eca3d81d60cbe129ce687674e6451836d567f6b9

I believe it's general problem with maintaining atomicity in async code, and 
not a bug in `wait_for`. Probably having an interface like `async with 
loop.create_connection(…) as transport, protocol` might simplify correct usage 
for this particular case.

--

___
Python tracker 

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



[issue44124] Unhelpful error messages with mis-ordering of f-string specifiers

2021-05-13 Thread Angus L'Herrou


Change by Angus L'Herrou :


--
title: Unhelpful SyntaxError message with mis-ordering of f-string specifiers 
-> Unhelpful error messages with mis-ordering of f-string specifiers

___
Python tracker 

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



[issue44123] make function parameter sentinel value true singletons

2021-05-13 Thread Tal Einat


Tal Einat  added the comment:

Additional examples of such sentinel values in the stdlib are those in the 
dataclasses module, e.g. dataclasses.MISSING.

--

___
Python tracker 

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



[issue44123] make function parameter sentinel value true singletons

2021-05-13 Thread Eric V. Smith


Change by Eric V. Smith :


--
nosy: +eric.smith

___
Python tracker 

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



[issue39906] pathlib.Path: add `follow_symlinks` argument to `stat()` and `chmod()`

2021-05-13 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue43795] Implement PEP 652 -- Maintaining the Stable ABI

2021-05-13 Thread Petr Viktorin


Change by Petr Viktorin :


--
pull_requests: +24742
pull_request: https://github.com/python/cpython/pull/26101

___
Python tracker 

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



[issue44124] Unhelpful SyntaxError message with mis-ordering of f-string specifiers

2021-05-13 Thread Angus L'Herrou


New submission from Angus L'Herrou :

The f-string grammar clearly specifies the correct order of f-string =, !, and 
: specifiers:

replacement_field ::=  "{" f_expression ["="] ["!" conversion] [":" 
format_spec] "}"

However, when these components are used in the wrong order, the error messages, 
while understandable if you know the grammar, are not exactly helpful for users 
of all knowledge levels.


>>> foo = 12.345
>>> f'{foo=:.2f}'  # correct ordering of = and :
'foo=12.35'
>>> f'{foo:.2f=}'  # incorrect ordering of : and =
Traceback (most recent call last):
  File "", line 1, in 
ValueError: Invalid format specifier
>>> f'{foo=!r}'# correct ordering of = and !
'foo=12.345'
>>> f'{foo!r=}'# incorrect ordering of ! and =
  File "", line 1
SyntaxError: f-string: expecting '}'
>>> bar = 'abcd'
>>> f'{bar!r:.2s}' # correct ordering of ! and :
"'a"
>>> f'{bar:.2s!r}' # incorrect ordering of : and !
Traceback (most recent call last):
  File "", line 1, in 
ValueError: Invalid format specifier


It would be more helpful to have more descriptive error messages specifying the 
correct order of these features. f-string format specifiers, especially ! and 
=, are in my experience fairly poorly known features, and more descriptive 
feedback when they are used incorrectly would avoid discouraging users from 
using them at all upon encountering a cryptic error. 

Since __format__ can have an arbitrary implementation for different data types, 
and therefore there might be some user-defined class that accepts :.2f!r as a 
valid format specifier, the ValueErrors here might have to stay, but at least 
the SyntaxError from f'{foo!r=}' could be clearer.

--
components: Parser
messages: 393587
nosy: angus-lherrou, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: Unhelpful SyntaxError message with mis-ordering of f-string specifiers
type: enhancement
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



[issue37658] In some cases asyncio.wait_for can lead to socket leak.

2021-05-13 Thread Adam Liddell


Adam Liddell  added the comment:

Wrapping every resource allocating call like that is what we were trying to 
avoid, since it makes wait_for go from a simple one-line helper to something 
you have to be very careful with.

Conceptually, a user should expect that wait_for should behave the exact same 
as awaiting the underlying awaitable, just with auto-cancellation. The problem 
with the current wait_for is that there is a gap where the underlying task may 
have completed but a cancellation arrives. In this case, we need to raise the 
cancellation to be a good asyncio citizen, but the underlying task has no 
opportunity to act on the cancellation (to free the resource) since it is 
already complete and cannot be re-entered. So the resource returned by the 
completed task gets stuck in limbo, since we can't return it and we can't 
assume a generic 'close' behaviour.

See my comment in the PR for a suggestion about an alternative structure for 
wait_for, which may avoid this gap and hence prevent the leak (but I have not 
tested it!)

--

___
Python tracker 

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



[issue40938] urllib.parse.urlunsplit makes relative path to absolute (http:g -> http:///g)

2021-05-13 Thread Jonathan Schweder


Jonathan Schweder  added the comment:

Not exactly, in the RFC example they use a/b/c for the path, but when using 
http:g there is no nested path, so it should be http:///g, no?

--

___
Python tracker 

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



[issue44123] make function parameter sentinel value true singletons

2021-05-13 Thread Tal Einat


Tal Einat  added the comment:

Alternatively, sentinels can simply be classes:

class Sentinel:
def __new__(cls, *args, **kwargs):
raise TypeError(f'{cls.__qualname__} cannot be instantiated')

class MISSING(Sentinel):
pass

--

___
Python tracker 

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



[issue44124] Unhelpful error messages with mis-ordering of f-string specifiers

2021-05-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I could try to give it a go to this still with the current parser, I think we 
could have some improvements without a lot of refactoring.

Moving the whole f string to the grammar still don't ensure making this work 
easier unfortunately because is not clear how much backtracking the parser will 
require. When it requires enough backtracking, adding errors can be a pain.

--

___
Python tracker 

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



[issue44125] "make patchcheck" fails

2021-05-13 Thread miss-islington


miss-islington  added the comment:


New changeset 04ce4c773667b0d9d05a89aea4720f8cf84e834e by Miss Islington (bot) 
in branch '3.9':
bpo-44125: Fix "make patchcheck" on non-English locale (GH-26102)
https://github.com/python/cpython/commit/04ce4c773667b0d9d05a89aea4720f8cf84e834e


--

___
Python tracker 

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



[issue44074] patchcheck checks against branch "master" not "main"

2021-05-13 Thread miss-islington


miss-islington  added the comment:


New changeset 04ce4c773667b0d9d05a89aea4720f8cf84e834e by Miss Islington (bot) 
in branch '3.9':
bpo-44125: Fix "make patchcheck" on non-English locale (GH-26102)
https://github.com/python/cpython/commit/04ce4c773667b0d9d05a89aea4720f8cf84e834e


--

___
Python tracker 

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



[issue44126] Cross Compile Cython Modules

2021-05-13 Thread Jeff Moguillansky


New submission from Jeff Moguillansky :

Hi,
I was able to cross-compile Python 3.9.4 for Android.
How do I cross-compile cython modules?
I found one tool online: https://pypi.org/project/crossenv/
but it doesn't seem to be compatible with android clang?
Does cython support cross-compiling modules?

--
components: Cross-Build
messages: 393599
nosy: Alex.Willmer, jmoguill2
priority: normal
severity: normal
status: open
title: Cross Compile Cython Modules
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



[issue43504] Site linked in docs, effbot.org, down

2021-05-13 Thread Mark Roseman


Mark Roseman  added the comment:

I'd argue for removing the links altogether, given the material is very 
outdated and from what I recall anything that was there is better covered now 
by TkDocs, Shipman, or other resources.

--

___
Python tracker 

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



[issue43952] Multiprocessing UNIX socket connection: client freeze if authkey is an empty byte string

2021-05-13 Thread Antoine Pitrou


Change by Antoine Pitrou :


--
versions: +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



[issue38552] Colored Prompt broken in REPL in Windows in 3.8

2021-05-13 Thread William Minchin


William Minchin  added the comment:

I can't reproduce this today: Python 3.8.6 (or 3.9.5) with PowerShell 7.1.3 on 
Windows 10 with Windows Terminal. Maybe it got fixed by a bugfix release of 
Python 3.8?

I'll close it for now.

c.f. https://github.com/tartley/colorama/issues/233

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



[issue44074] patchcheck checks against branch "master" not "main"

2021-05-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +24750
pull_request: https://github.com/python/cpython/pull/26106

___
Python tracker 

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



[issue43933] Regression in python3.10 with traceback frame having lineno of -1

2021-05-13 Thread Ned Batchelder


Ned Batchelder  added the comment:

Thanks, this fixes my issue.

--

___
Python tracker 

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



[issue44098] Remove ParamSpec from __parameters__ of most typing generics

2021-05-13 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset c55ff1b352f8b82184f80d9dea220e832691acfc by Miss Islington (bot) 
in branch '3.10':
bpo-44098: Drop ParamSpec from most ``__parameters__`` in typing generics 
(GH-26013) (#26091)
https://github.com/python/cpython/commit/c55ff1b352f8b82184f80d9dea220e832691acfc


--

___
Python tracker 

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



[issue44126] Cross Compile Cython Modules

2021-05-13 Thread Ned Deily


Ned Deily  added the comment:

This issue tracker is for issues with cPython and the Python Standard Library. 
Cython is a third-party project that is not part of cPython. You should ask in 
a Cython forum (see https://cython.org/#development) or a general forum like 
StackOverflow.

--
nosy: +ned.deily
resolution:  -> third party
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue44114] Incorrect function signatures in dictobject.c

2021-05-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +24751
pull_request: https://github.com/python/cpython/pull/26107

___
Python tracker 

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



[issue44114] Incorrect function signatures in dictobject.c

2021-05-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +24753
pull_request: https://github.com/python/cpython/pull/26109

___
Python tracker 

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



[issue44114] Incorrect function signatures in dictobject.c

2021-05-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +24752
pull_request: https://github.com/python/cpython/pull/26108

___
Python tracker 

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



[issue8557] subprocess PATH semantics and portability

2021-05-13 Thread Henry Schreiner


Change by Henry Schreiner :


--
nosy: +Henry Schreiner

___
Python tracker 

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



[issue44114] Incorrect function signatures in dictobject.c

2021-05-13 Thread miss-islington


miss-islington  added the comment:


New changeset 04c46101944777dd131bbfe8dbfef5f4d328860d by Miss Islington (bot) 
in branch '3.9':
bpo-44114: Remove redundant cast. (GH-26098)
https://github.com/python/cpython/commit/04c46101944777dd131bbfe8dbfef5f4d328860d


--

___
Python tracker 

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



[issue44114] Incorrect function signatures in dictobject.c

2021-05-13 Thread miss-islington


miss-islington  added the comment:


New changeset c4c3beb5ad6b55c20b6dc7c6a92860f467afa75b by Miss Islington (bot) 
in branch '3.10':
bpo-44114: Remove redundant cast. (GH-26098)
https://github.com/python/cpython/commit/c4c3beb5ad6b55c20b6dc7c6a92860f467afa75b


--

___
Python tracker 

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



[issue44123] make function parameter sentinel value true singletons

2021-05-13 Thread Tal Einat


Tal Einat  added the comment:

... and they can be given excellent reprs by using a meta-class:

class Sentinel(type):
@classmethod
def __prepare__(cls, name, bases, **kwds):
d = super().__prepare__(name, bases, **kwds)
def __new__(cls_, *args, **kwargs):
raise TypeError(
f'{cls_!r} is a sentinel and cannot be instantiated')
d.update(__new__=__new__)
return d

def __repr__(cls):
return f'{cls.__module__}.{cls.__qualname__}'


class MISSING(metaclass=Sentinel): pass


This also has another nice benefit:

>>> type(MISSING)


--

___
Python tracker 

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



[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak

2021-05-13 Thread Antoine Pitrou


Change by Antoine Pitrou :


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



[issue44125] "make patchcheck" fails

2021-05-13 Thread Antoine Pitrou


New submission from Antoine Pitrou :

./python ./Tools/scripts/patchcheck.py
Getting base branch for PR ... Traceback (most recent call last):
  File "/home/antoine/cpython/default/./Tools/scripts/patchcheck.py", line 307, 
in 
main()
  File "/home/antoine/cpython/default/./Tools/scripts/patchcheck.py", line 267, 
in main
base_branch = get_base_branch()
  File "/home/antoine/cpython/default/./Tools/scripts/patchcheck.py", line 35, 
in call_fxn
result = fxn(*args, **kwargs)
  File "/home/antoine/cpython/default/./Tools/scripts/patchcheck.py", line 111, 
in get_base_branch
return upstream_remote + "/" + base_branch
TypeError: can only concatenate str (not "NoneType") to str
make: *** [Makefile:2006 : patchcheck] Erreur 1

--
assignee: pitrou
components: Demos and Tools
messages: 393591
nosy: pitrou
priority: normal
severity: normal
stage: needs patch
status: open
title: "make patchcheck" fails
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



[issue44125] "make patchcheck" fails

2021-05-13 Thread Antoine Pitrou


Antoine Pitrou  added the comment:

The patch from bpo-44074 does not account for a possibly non-English locale and 
blindly greps for "HEAD branch" in a possibly localized text.

--

___
Python tracker 

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



[issue44125] "make patchcheck" fails

2021-05-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +24749
pull_request: https://github.com/python/cpython/pull/26106

___
Python tracker 

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



[issue44074] patchcheck checks against branch "master" not "main"

2021-05-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +24748
pull_request: https://github.com/python/cpython/pull/26105

___
Python tracker 

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



[issue44125] "make patchcheck" fails

2021-05-13 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 1.0 -> 2.0
pull_requests: +24747
pull_request: https://github.com/python/cpython/pull/26105

___
Python tracker 

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



[issue44123] make function parameter sentinel value true singletons

2021-05-13 Thread Tal Einat


Tal Einat  added the comment:

Here is what I suggest working with sentinels would look like:


>>> from dataclasses import MISSING
>>> MISSING
dataclasses.MISSING
>>> M2 = pickle.loads(pickle.dumps(MISSING))
>>> M2
dataclasses.MISSING
>>> M2 is MISSING
True


Here's an implementation which ensures a single instance is used, even 
considering multi-threading and pickling, which sets a nice repr according to 
the module and class name:


try:
from threading import Lock
except ImportError:
class Lock:
def __enter__(self):
pass
def __exit__(self, exc_type, exc_value, traceback):
pass


class Sentinel:
_instance = None
_lock = Lock()
def __new__(cls):
if cls._instance is None:
with cls._lock:
if cls._instance is None:
cls._instance = super().__new__(cls)
return cls._instance
def __repr__(self):
*path_parts, classname = self.__class__.__qualname__.split('.')
return '.'.join([self.__class__.__module__, *path_parts, 
classname.removeprefix('_')])


class _MISSING(Sentinel):
pass
MISSING = _MISSING()

--

___
Python tracker 

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



[issue44074] patchcheck checks against branch "master" not "main"

2021-05-13 Thread Antoine Pitrou


Change by Antoine Pitrou :


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



[issue28146] Confusing error messages in str.format()

2021-05-13 Thread Antoine Pitrou


Change by Antoine Pitrou :


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



[issue44114] Incorrect function signatures in dictobject.c

2021-05-13 Thread Antoine Pitrou


Change by Antoine Pitrou :


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



[issue44125] "make patchcheck" fails

2021-05-13 Thread Antoine Pitrou


Change by Antoine Pitrou :


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

___
Python tracker 

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



[issue44074] patchcheck checks against branch "master" not "main"

2021-05-13 Thread Antoine Pitrou


Change by Antoine Pitrou :


--
nosy: +pitrou
nosy_count: 4.0 -> 5.0
pull_requests: +24744
pull_request: https://github.com/python/cpython/pull/26102

___
Python tracker 

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



[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak

2021-05-13 Thread Antoine Pitrou


Change by Antoine Pitrou :


--
nosy: +pitrou
nosy_count: 13.0 -> 14.0
pull_requests: +24745
pull_request: https://github.com/python/cpython/pull/26103

___
Python tracker 

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



[issue44124] Unhelpful error messages with mis-ordering of f-string specifiers

2021-05-13 Thread Eric V. Smith


Eric V. Smith  added the comment:

As you note, some of these likely cannot be improved.

There was talk last year about moving f-string's bespoke lexer/parser/compiler 
into the normal Python grammar. But I'm not sure if that ever got anywhere. If 
we did make that change, it would be easier to improve the error messages. 
Well, at least as easy as improving normal Python error messages.

--
nosy: +eric.smith
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



[issue42972] [C API] Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-05-13 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
pull_requests: +24746
pull_request: https://github.com/python/cpython/pull/26104

___
Python tracker 

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



[issue44074] patchcheck checks against branch "master" not "main"

2021-05-13 Thread miss-islington


miss-islington  added the comment:


New changeset 336dc523a4180f99955b0fdb65e86059a1abac32 by Miss Islington (bot) 
in branch '3.10':
bpo-44125: Fix "make patchcheck" on non-English locale (GH-26102)
https://github.com/python/cpython/commit/336dc523a4180f99955b0fdb65e86059a1abac32


--

___
Python tracker 

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



[issue44125] "make patchcheck" fails

2021-05-13 Thread Antoine Pitrou


Change by Antoine Pitrou :


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



[issue44125] "make patchcheck" fails

2021-05-13 Thread miss-islington


miss-islington  added the comment:


New changeset 336dc523a4180f99955b0fdb65e86059a1abac32 by Miss Islington (bot) 
in branch '3.10':
bpo-44125: Fix "make patchcheck" on non-English locale (GH-26102)
https://github.com/python/cpython/commit/336dc523a4180f99955b0fdb65e86059a1abac32


--

___
Python tracker 

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



[issue44109] missing dataclass decorator in match-statement example

2021-05-13 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



[issue44094] Remove PyErr_Set...WithUnicodeFilename APIs

2021-05-13 Thread Antoine Pitrou


Change by Antoine Pitrou :


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

___
Python tracker 

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



[issue28146] Confusing error messages in str.format()

2021-05-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +24755
pull_request: https://github.com/python/cpython/pull/26111

___
Python tracker 

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



[issue28146] Confusing error messages in str.format()

2021-05-13 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue28146] Confusing error messages in str.format()

2021-05-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +24756
pull_request: https://github.com/python/cpython/pull/26112

___
Python tracker 

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



[issue38291] Deprecate the typing.io and typing.re pseudo-modules

2021-05-13 Thread Guido van Rossum


Guido van Rossum  added the comment:

I agree, these namespaces were a mistake. Let's start deprecating them (and 
remove their mention from the docs again).

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



[issue44127] urllib.parse.ParseResult._replace() does not allow replacing username, password, hostname, port

2021-05-13 Thread Jamie Bliss


New submission from Jamie Bliss :

As it says in the title. ._replace() (inherited from namedtuple) doesn't  allow 
changing the generated properties.

While this is a natural consequence of how ParseResult is implemented, I would 
describe it as a deficiency of developer experience.

My work-around function for this is 
https://gist.github.com/AstraLuma/00e511feb1f619f407d07e968d69f36b

--
components: Library (Lib)
messages: 393614
nosy: AstraLuma
priority: normal
severity: normal
status: open
title: urllib.parse.ParseResult._replace() does not allow replacing username, 
password, hostname, port
versions: Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8, Python 
3.9

___
Python tracker 

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



[issue44109] missing dataclass decorator in match-statement example

2021-05-13 Thread Brandt Bucher


Brandt Bucher  added the comment:

I don't really think there is anything wrong with the documentation. I can 
copy-and-paste all of the code from the PEP 634 section of the 3.10 What's New 
into the REPL without any issues (provided that named subjects like 
point/points/test_variable/color are actually defined).

Note that none of the example snippets actually *create* Point instances. 
Rather, some of the patterns *match* Point instances... which is sort of the 
opposite of instantiation.

As the Point class is currently written, instantiation would probably look like:

>>> p = Point()
>>> p.x = 0
>>> p.y = 0

Sure, it would help to have an __init__ defined in real code, but I sort of 
feel like adding it to this example would just distract (especially since the 
example doesn't actually *need* it).

Thoughts from others?

--

___
Python tracker 

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



[issue28146] Confusing error messages in str.format()

2021-05-13 Thread miss-islington


miss-islington  added the comment:


New changeset 2d780237d95cd3d95401f52be2edeac8b458eb68 by Miss Islington (bot) 
in branch '3.10':
bpo-28146: Fix a confusing error message in str.format() (GH-24213)
https://github.com/python/cpython/commit/2d780237d95cd3d95401f52be2edeac8b458eb68


--

___
Python tracker 

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



[issue44126] Cross Compile Cython Modules

2021-05-13 Thread Jeff Moguillansky


Jeff Moguillansky  added the comment:

Sorry I meant cpython.
Distutils is part of cpython?
Currently it doesn't seem to support cross compiling?

On Thu, May 13, 2021, 1:08 PM Ned Deily  wrote:

>
> Ned Deily  added the comment:
>
> This issue tracker is for issues with cPython and the Python Standard
> Library. Cython is a third-party project that is not part of cPython. You
> should ask in a Cython forum (see https://cython.org/#development) or a
> general forum like StackOverflow.
>
> --
> nosy: +ned.deily
> resolution:  -> third party
> stage:  -> resolved
> status: open -> closed
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue42972] [C API] Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-05-13 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
pull_requests: +24759
pull_request: https://github.com/python/cpython/pull/26114

___
Python tracker 

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



[issue42972] [C API] Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-05-13 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

I've added a checkbox for types that fully implement the GC protocol to 
https://discuss.python.org/t/list-of-built-in-types-converted-to-heap-types/8403/1.

Heap types that fully implement the GC protocol:
* _abc._abc_data
* _bz2.BZ2Compressor
* _bz2.BZ2Decompressor
* _csv.Dialect
* _csv.reader
* _csv.writer
* _json.Encoder
* _json.Scanner
* _lzma.LZMACompressor
* _lzma.LZMADecompressor
* _multibytecodec.MultibyteCodec
* _struct.unpack_iterator
* _thread._local
* _thread.lock
* ast.AST

Heap types that do not fully implement the GC protocol:
* _curses_panel.panel
* _dbm.dbm
* _gdbm.gdbm
* _hashlib.HASH
* _hashlib.HASHXOF
* _lsprof.Profiler
* _md5.md5
* _multibytecodec.MultibyteIncrementalDecoder
* _multibytecodec.MultibyteIncrementalEncoder
* _multibytecodec.MultibyteStreamReader
* _multibytecodec.MultibyteStreamWriter
* _overlapped.Overlapped
* _queue.SimpleQueue
* _random.Random
* _sha1.sha1
* _sha256.sha224
* _sha256.sha256
* _sha512.sha384
* _sha512.sha512
* _sre.SRE_Scanner
* _ssl.MemoryBIO
* _ssl.SSLSession
* _ssl._SSLContext
* _ssl._SSLSocket
* _struct.Struct
* _thread.RLock
* _thread._localdummy
* _tkinter.Tcl_Obj
* _tkinter.tkapp
* _tkinter.tktimertoken
* array.array
* array.arrayiterator
* functools.KeyWrapper
* functools._lru_cache_wrapper
* functools._lru_list_elem
* functools.partial
* mmap.mmap
* operator.attrgetter
* operator.itemgetter
* operator.methodcaller
* posix.DirEntry
* posix.ScandirIterator
* pyexpat.xmlparser
* re.Match
* re.Pattern
* select.devpoll
* select.epoll
* select.kevent
* select.kqueue
* select.poll
* sqlite3.Cache
* sqlite3.Connection
* sqlite3.Cursor
* sqlite3.Node
* sqlite3.PrepareProtocol
* sqlite3.Row
* sqlite3.Statement
* ssl.SSLError
* unicodedata.UCD
* winapi__overlapped.Overlapped
* zlib.Compress
* zlib.Decompress

--

___
Python tracker 

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



[issue28146] Confusing error messages in str.format()

2021-05-13 Thread miss-islington


miss-islington  added the comment:


New changeset 133013e8a1ecd570266de766e2df9745a24343be by Miss Islington (bot) 
in branch '3.9':
bpo-28146: Fix a confusing error message in str.format() (GH-24213)
https://github.com/python/cpython/commit/133013e8a1ecd570266de766e2df9745a24343be


--

___
Python tracker 

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



[issue42109] Use hypothesis for testing the standard library, falling back to stubs

2021-05-13 Thread Guido van Rossum


Guido van Rossum  added the comment:

I would like to have a more thorough discussion about the desirability of using 
Hypothesis first, since I feel that there is a rather hard "sell" going on. I 
brought this up in the SC tracker 
(https://github.com/python/steering-council/issues/65) but I don't want to have 
the discussion there.

Copying some quoted text from there:

[me]
> > Can we perhaps have an open discussion on the merits of Hypothesis itself 
> > on python-dev before committing to this?

[Paul]
> You mean hypothesis specifically or property-based testing in general? I 
> think that if we add property-based testing, hypothesis is probably the only 
> natural choice. Of course, I can make this case on the thread if that was 
> your intention.

I don't even know what property-based testing means (for Python) other than 
Hypothesis. What other frameworks support that? In any case, nobody has been 
promoting anything else, but Zac has been on our case for over a year. :-)

[me]
> > It seems to promote a coding style that's more functional than is good for 
> > Python, and its inner workings seem too magical to me. Also the 
> > decorator-based DSL looks pretty inscrutable to me.

[Paul]
> Do you mean it's promoting a coding style within the tests, or in the public 
> API? When designing zoneinfo I didn't think about how easy it would be to 
> test with Hypothesis at all as part of the API and it was basically 
> frictionless.

I meant in the public API. I don't doubt that for zoneinfo this worked well, 
but that doesn't prove it's any better than any other framework (maybe you 
would have been ecstatic if you could have used pytest as well :-). 
Fundamentally, I am a bit suspicious of Hypothesis' origins, Haskell, which is 
a language and community that just have a different approach to programming 
than Python. Don't get me wrong, I don't think there's anything wrong with 
Haskell (except that I've noticed it's particularly popular with the IQ >= 150 
crowd :-). It's just different than Python, and just as we don't want to 
encourage writing "Fortran or Java in Python", I don't think it's a good idea 
to recommend writing "Haskell in Python".

> I think there are situations where it makes sense to write functional-style 
> strategies because it can in some situations give hypothesis more information 
> about how the strategies are transformed (and thus allow it to optimize how 
> the data is drawn rather than drawing from the full set and discarding a 
> bunch of stuff that doesn't match, or doing a bunch of extra logic on each 
> draw), but it's by no means required. I'd say most of my "complex strategies" 
> are decorated functions rather than chains of maps and filters.

Ah, here we get to the crux of the matter. What's a "strategy"? Maybe I would 
be more inclined to support Hypothesis if it was clearer what it does. I like 
libraries that do stuff for me that I know how to do myself. With Hypothesis, 
the deeper I get into the docs, the more I get the impression that there is 
deep magic going on that a poor sap like myself isn't supposed to understand. 
When I write @given(st.lists(st.integers)) what does that do? I haven't the 
foggiest idea, and from the docs I get the impression I'm not supposed to worry 
about it, and *that* worries me. Clearly it can't be generating all lists of 0 
integers followed by all lists of 1 integer followed by all lists of 2 integers 
... So in what order does it generate test data? The docs are pretty vague 
about that.

(I'm not playing dumb here. I really have no idea how to go about that, and it 
seems that this is at the heart of Hypothesis and its' Haskell ancestors. 
Presumably Ph.D theses went into making this sort of thing work. Perhaps more 
effort could be expended explaining this part to laypeople?)

> From the stdlib-property-tests repo, this seems like the most complicated 
> strategy I'm seeing employed, and I find it fairly simple to understand, and 
> I don't know how easy to read any code would be that generates trees of 
> arbitrary depth containing objects with specific properties.

I have never tried that sort of thing, so I'll take your word for it.

But there are other strategies. It seems that a lot of the strategies are 
answers to a series of questions, along the lines of "how do I generate valid 
URLs"; and then "email addresses"; and then "IP addresses"; and then suddenly 
we find a strategy that generates *functions*, and then we get "recursive 
things", and it keeps going. Timezone keys?! No wonder you found it easy to 
use. :-)

I think I've heard that there's a strategy somewhere that generates random 
Python programs. How would that even work? Would it help me find corner cases 
in the grammar? I suppose we could actually use something like that for the 
"faster CPython" project, to validate that the optimizer doesn't break things. 
But how? Do I just write

@given(st.python_programs(), st.values())
def test_optimizer(func, 

[issue38693] Use f-strings instead of str.format within importlib

2021-05-13 Thread Filipe Laíns

Filipe Laíns  added the comment:

Both importlib_metadata and importlib_resources have dropped support for Python 
2.7 and 3.5, this should now be unblocked.

--
nosy: +FFY00

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-05-13 Thread miss-islington


miss-islington  added the comment:


New changeset 3222b25b2f55d3b3d1dab4547bf7b5adaa1d874f by Miss Islington (bot) 
in branch '3.10':
[3.10] bpo-43908: Add What's New entry for Py_TPFLAGS_IMMUTABLETYPE flag 
(GH-25816) (GH-26115)
https://github.com/python/cpython/commit/3222b25b2f55d3b3d1dab4547bf7b5adaa1d874f


--

___
Python tracker 

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



[issue42972] [C API] Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-05-13 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
pull_requests:  -23226

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-05-13 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 11.0 -> 12.0
pull_requests: +24760
pull_request: https://github.com/python/cpython/pull/26115

___
Python tracker 

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



[issue43012] Remove pathlib accessors

2021-05-13 Thread Barney Gale


Change by Barney Gale :


--
type:  -> performance
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



[issue44128] zipfile: Deduplicate ZipExtFile code for init and resetting when seeking

2021-05-13 Thread Daniel Hillier


New submission from Daniel Hillier :

Integrating a refactor suggested in https://bugs.python.org/issue38334

The logic for preparing a ZipExtFile for reading (setting CRC state, read 
positions, etc) is currently in two locations: first initialisation and when 
seeking back to the start of a file.

This change moves the logic into the method `ZipExtFile.init_read()`

--
components: Library (Lib)
messages: 393619
nosy: dhillier, serhiy.storchaka
priority: normal
severity: normal
status: open
title: zipfile: Deduplicate ZipExtFile code for init and resetting when seeking
type: enhancement
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



[issue44114] Incorrect function signatures in dictobject.c

2021-05-13 Thread Antoine Pitrou


Change by Antoine Pitrou :


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



[issue28146] Confusing error messages in str.format()

2021-05-13 Thread Antoine Pitrou


Antoine Pitrou  added the comment:

It seems like this issue is entirely fixed now, closing.

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

___
Python tracker 

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



[issue38291] Deprecate the typing.io and typing.re pseudo-modules

2021-05-13 Thread Sebastian Rittau


Change by Sebastian Rittau :


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

___
Python tracker 

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



[issue38291] Deprecate the typing.io and typing.re pseudo-modules

2021-05-13 Thread Sebastian Rittau


Sebastian Rittau  added the comment:

I opened a PR to remove their mention from the docs for now. I can look into 
how to add a deprecation warning to a module if no one else beats me to it.

--

___
Python tracker 

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



[issue35089] Remove typing.io and typing.re from documentation

2021-05-13 Thread Sebastian Rittau


Change by Sebastian Rittau :


--
pull_requests: +24758
pull_request: https://github.com/python/cpython/pull/26113

___
Python tracker 

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



[issue42109] Use hypothesis for testing the standard library, falling back to stubs

2021-05-13 Thread Zac Hatfield-Dodds


Zac Hatfield-Dodds  added the comment:

(I think structuring this as a high-level explanation is clearer than 
point-by-point replies - it covers most of them, but the logic is hopefully 
easier to follow)


The core idea of Hypothesis is that making random choices is equivalent to 
parsing a random bitstring:
- wrap your test function in a decorator which calls it many times with 
random inputs
- describe those inputs with strategies, (which are parser combinators)
- the bytes parsed by strategies can be provided by a Random() instance, 
saved to and loaded from a database, edited and (maybe) re-parsed into related 
or simpler inputs, etc.
Minithesis [1] is a complete implementation of this core, including strategies, 
shrinking, and the database, in a few hundred lines of Python.  I think reading 
this will answer most of your implementation questions.

Hypothesis is not the *only* property-based testing library for Python (there's 
pytest-quickcheck), but in the same sense that `six` is not the only py2/py3 
compatibility layer.  I attribute this to a combination of a better underlying 
model [2], and brute implementation effort to provide great error messages, 
integration with popular libraries, lots of strategies, related tooling, and so 
on.

[1] https://github.com/DRMacIver/minithesis
See also https://hypothesis.works/articles/how-hypothesis-works/ for an 
older writeup; the implementation details are a little outdated but it explains 
the motivations better.
[2] https://hypothesis.works/articles/types-and-properties/



So a "strategy" is an object (implementation detail: a parser combinator, 
instance of SearchStrategy), which tells Hypothesis how to convert a random 
bytestring into whatever object you've asked for.  This is a little unusual, 
but I haven't found a better way which still makes it easy to mix the strategy 
primitives with arbitrary user code such as "pick a username, ensure it's in 
the database, and then pass it to my test method".

I share your distaste for "Haskell in Python"; I don't think Hypothesis 
introduces more of that flavor than Numpy would introduce Fortran idioms - 
there's occasionally a resemblance, but they're both Python-first libraries and 
I'd attribute it mostly to the problem being solved.  FWIW Hypothesis 
deliberately rejected most of the design choices of QuickCheck, and 
implementation-wise has more in common with unixy fuzzing tools like AFL.

The strategies in our API can generally be divided into useful primitives (e.g. 
integers, floats, lists, tuples, sampled_from, one_of) and pre-composed 
strategies (booleans = sampled_from, dictionaries = map+lists-of-kv-tuples, 
builds = tuples+fixed_dictionaries+map).
Very specific strategies like emails() are included because they're a common 
need, and a naive implementation usually omits exactly the weirder and 
error-prone features that might reveal bugs.

We _are_ deliberately vague about the order in which we generate test data, 
because the distribution is full of heuristics and adapts itself to the 
behaviour of the test - including over multiple runs, thanks to the database.  
The exact details are also considered an implementation detail, and subject to 
change as we discover heuristics and sampling techniques which find bugs faster.

The upside here is writing effective strategies is straightforward:
- expressing more possible (valid) inputs is good, because e.g. if the bug 
triggers on NaN we'd have to generate some NaNs to detect it; and
- limiting use of rejection sampling (hypothesis.assume(), the .filter() 
method) is an obvious performance improvement - if only 20% of inputs we try to 
generate are valid, the test will take five times longer.
following which Hypothesis' backend (the "conjecture" engine) uses a large 
helping of heuristics and fancy code to ensure that we get a nice diverse 
sample from the inputs space.  Unfortunately there's a direct tension between 
high performance and explainable behaviour; Minithesis is readable mostly by 
virtue of not handling the hard edge cases.



I'll take my Hypothesmith [3] project for random Python programs as an example 
of a complex strategy.  It was inspired by CSmith [4] - but is considerably 
less sophisticated.  CSmith constructs semantically valid C programs; 
Hypothesmith (for now!) constructs a subset of syntatically-valid Python.  The 
basic idea is to "invert" the grammar: start with the root node, recursively 
construct a valid parse tree, and then serialise it out to a parsable input 
string.  Doing a better job would require more time than I had for a 
proof-of-concept, but no new insights; and the same applies to defining a 
strategy for semantically-valid code.  Being based on the grammar I'd guess 
it's unlikely to find corner cases in the grammar, but it might do so in the 
parser, or via e.g. `(tree := ast.parse(code)) == ast.parse(ast.unparse(tree))`.

Your distrust of the python_programs() strategy 

[issue43757] pathlib: move 'resolve()' logic out of path flavour

2021-05-13 Thread Carol Willing


Carol Willing  added the comment:


New changeset ea14a0749a4f19b29236fc0acc4b556d9243bc6f by Miss Islington (bot) 
in branch '3.10':
bpo-43757: Document os.path.realpath(strict=True) in 3.10 whatsnew. (GH-26090) 
(#26099)
https://github.com/python/cpython/commit/ea14a0749a4f19b29236fc0acc4b556d9243bc6f


--
nosy: +willingc

___
Python tracker 

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



[issue43795] Implement PEP 652 -- Maintaining the Stable ABI

2021-05-13 Thread Carol Willing


Carol Willing  added the comment:


New changeset 373937182ee029c282bea58cdda57ab41990f404 by Miss Islington (bot) 
in branch '3.10':
bpo-43795: PEP 652 user documentation (GH-25668) (GH-26034)
https://github.com/python/cpython/commit/373937182ee029c282bea58cdda57ab41990f404


--
nosy: +willingc

___
Python tracker 

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



[issue44129] zipfile: Add descriptive global variables for general purpose bit flags

2021-05-13 Thread Daniel Hillier


New submission from Daniel Hillier :

In the zipfile module, masking of bit flags is done against hex numbers eg. if 
flags & 0x800...

To increase readability I suggest we replace these with global variables named 
for the purpose of the flag. From the example above:

if flags & 0x800
becomes:
if flags & _MASK_UTF_FILENAME

--
components: Library (Lib)
messages: 393622
nosy: dhillier, serhiy.storchaka
priority: normal
severity: normal
status: open
title: zipfile: Add descriptive global variables for general purpose bit flags
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



[issue43977] Implement the latest semantics for PEP 634 for matching collections

2021-05-13 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue44129] zipfile: Add descriptive global variables for general purpose bit flags

2021-05-13 Thread Daniel Hillier


Change by Daniel Hillier :


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

___
Python tracker 

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



[issue43977] Implement the latest semantics for PEP 634 for matching collections

2021-05-13 Thread Carol Willing


Carol Willing  added the comment:


New changeset e7d25d3f3b335eb46d102137b447325f54750e31 by Miss Islington (bot) 
in branch '3.10':
bpo-43977: Update pattern matching language reference docs (GH-25917) (GH-26117)
https://github.com/python/cpython/commit/e7d25d3f3b335eb46d102137b447325f54750e31


--
nosy: +willingc

___
Python tracker 

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



[issue44115] Improve conversions for fractions

2021-05-13 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Note for posterity:   I tried out pattern matching here but it was a little 
tricky and it slowed down the code a bit.  At at least it worked.

if denominator is None:
match numerator:
case int(x) if type(numerator) is int:
self._numerator = numerator
self._denominator = 1
return self
case numbers.Rational(numerator=numerator, 
denominator=denominator):
self._numerator = numerator
self._denominator = denominator
return self
case object(as_integer_ratio=_):
self._numerator, self._denominator = 
numerator.as_integer_ratio()
return self
case str(x):
m = _RATIONAL_FORMAT.match(numerator)
if m is None:
raise ValueError('Invalid literal for Fraction: %r' %
 numerator)
numerator = int(m.group('num') or '0')
denom = m.group('denom')
if denom:
denominator = int(denom)
else:
denominator = 1
decimal = m.group('decimal')
if decimal:
scale = 10**len(decimal)
numerator = numerator * scale + int(decimal)
denominator *= scale
exp = m.group('exp')
if exp:
exp = int(exp)
if exp >= 0:
numerator *= 10**exp
else:
denominator *= 10**-exp
if m.group('sign') == '-':
numerator = -numerator
case _:
raise TypeError("argument should be a string "
"or a Rational instance")

--

___
Python tracker 

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



[issue44115] Improve conversions for fractions

2021-05-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It was proposed before in issue37884.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue44069] pathlib.Path.glob's generator is not a real generator

2021-05-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

The reason is different. The scandir() iterator should be closed before we go 
recursively deep in the directory tree. Otherwise we can reach the limit of 
open file descriptors (especially if several glob()s are called in parallel). 
See issue22167.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue44120] logging.config.fileConfig/dictConfig can not import class

2021-05-13 Thread Hiroaki Mizuguchi


New submission from Hiroaki Mizuguchi :

This bug is loading bar.logging.FooBarFormatter is occur "ModuleNotFoundError: 
No module named 'bar.logging.FooBarFormatter'; 'bar.logging' is not a package" 
when bar module has 'import logging' directive.

logging.config._resolve and logging.config.BaseConfiguration.resolve has the 
bug.

See also my testcase repository: 
https://github.com/akihiro/python-logging-config-testcase

--
components: Library (Lib)
messages: 393557
nosy: akihiro
priority: normal
severity: normal
status: open
title: logging.config.fileConfig/dictConfig can not import class
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



[issue44119] Use glob.glob() to implement pathlib.Path.glob()

2021-05-13 Thread Barney Gale


Barney Gale  added the comment:

Flawed implementation, timings were bogus. Closing in shame.

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



[issue512981] readline /dev/tty problem

2021-05-13 Thread Pierre


Pierre  added the comment:

A workaround consists in replacing fd(0) with /dev/tty without modifying 
sys.stdin


import os

stdin = os.dup(0)
os.close(0)
tty = os.open("/dev/tty", os.O_RDONLY)
assert tty == 0

import readline
print("input:", input())
print("in:", os.read(stdin, 128))

--

___
Python tracker 

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



[issue44114] Incorrect function signatures in dictobject.c

2021-05-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +24733
pull_request: https://github.com/python/cpython/pull/26093

___
Python tracker 

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



[issue44114] Incorrect function signatures in dictobject.c

2021-05-13 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue44114] Incorrect function signatures in dictobject.c

2021-05-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +24734
pull_request: https://github.com/python/cpython/pull/26094

___
Python tracker 

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



[issue44114] Incorrect function signatures in dictobject.c

2021-05-13 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
type: behavior -> crash
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



[issue44114] Incorrect function signatures in dictobject.c

2021-05-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Good catch! The signature of dictkeys_reversed was already fixed (for purity 
reason), but the same bug in dictvalues_reversed and dictitems_reversed was 
missed. It is nice that such bugs can now be caught by tools.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue44122] let linter allow defining attribute outside __init__ if called in __init__

2021-05-13 Thread Ohad Shemesh


New submission from Ohad Shemesh :

A have a simple scenario in which I have a class with some initialized 
attribute that I want to be able to reset again. 
In order to avoid code duplication I'd to to something like this - 

class A:
def __init__(self):
self.reset()

def reset(self):
self.ls: List[datetime] = []

However this behavior makes the linter (in my case in pycharm) say "instance 
attribute defined outside __init__".
I think it'd be for the better if the linter allows this kind of definition if 
the function (i.e reset) is called in __init__.

--
components: Parser
messages: 393568
nosy: lys.nikolaou, ohadsunny, pablogsal
priority: normal
severity: normal
status: open
title: let linter allow defining attribute outside __init__ if called in 
__init__
type: behavior
versions: Python 3.7

___
Python tracker 

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



[issue39093] tkinter objects garbage collected from non-tkinter thread cause crash

2021-05-13 Thread Ivan Naydonov


Ivan Naydonov  added the comment:

I recently faced this problem and this bug was very helpful to understand whats 
going on. Especially the comment about a problem being a tkinter reference 
leaked to a thread.

Most of the discussions in google results doesn't mention it (or at least it's 
not easy to find).

I understand that fixing this problem on tkinter side won't be easy (if even 
possible), but I think it would be very useful for everyone to extend error 
message to explain the problem and ideally add some information that can help 
identify problematic reference - at least the name of the thread it was deleted 
from.

--
nosy: +samogot

___
Python tracker 

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



  1   2   >