[issue45804] IDLE - faster shell writing

2021-11-13 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Thank you Roger.  Good to hear from you.  

https://stackoverflow.com/questions/66286367/why-is-my-function-faster-than-pythons-print-function-in-idle,
 Feb 2021, was about this issue.  In my answer I verified the claim and then 
showed in further experiments that batching prints solved the issue.  #43283 
added a paragraph to the IDLE doc explaining the problem and suggesting that 
users could work around it by batching and joining before printing.  Buffering 
the streams to do so is an appealing alternative.  I intended to make sure that 
exceptions are completely and not just partly joined and sent in one write.

Some immediate questions:

Can buffering the output streams have any negative consequences.  Does it 
affect isatty, for instance, or anything checking line buffering?  

In case a user is interactively developing a tkinter GUI, IDLE already runs 
tcl.update() in a 50 ms after loop.  Could this be used to trigger writes, by 
calling flush()?

Did you consider using io.TextIOWrapper instead the current TextIOBase as base 
class for the output classes?

I am guessing that you do not have a python/cpython clone for making PRs.  
Tomorrow, I will try to find out how to make apply a .patch file to mine and do 
so.

--
versions: +Python 3.11 -Python 3.10

___
Python tracker 

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



[issue45752] copy module doc wrongly says it doesn't copy arrays

2021-11-13 Thread Stefan Pochmann


Stefan Pochmann  added the comment:

Just saw that it's in copy.py's docstring as well:

"This version does not copy types like module, class, function, method,
nor stack trace, stack frame, nor file, socket, window, nor array, nor
any similar types."

https://github.com/python/cpython/blob/3.10/Lib/copy.py#L41-L43

--

___
Python tracker 

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



[issue45804] IDLE - faster shell writing

2021-11-13 Thread Roger Serwy


New submission from Roger Serwy :

The shell provided by IDLE uses synchronous sys.stdout.write() calls between 
the subprocess and the front-end, leading to very slow writes. The provided 
patch proposes buffering the stdout/stderr streams in the subprocess and then 
sending a single update after 50ms. The patch also provides back pressure on 
the buffer so that it doesn't grow without bound.

When trying the behavior of the patch, disable the squeezer extension, or set 
its limit to 1000. Then in the shell, run:

for i in range(500): print(i)

The output will instantly appear in the shell.

--
files: idlelib_buffer_output.patch
keywords: patch
messages: 406306
nosy: roger.serwy, terry.reedy
priority: normal
severity: normal
stage: patch review
status: open
title: IDLE - faster shell writing
type: enhancement
versions: Python 3.10
Added file: https://bugs.python.org/file50438/idlelib_buffer_output.patch

___
Python tracker 

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



[issue45054] json module should issue warning about duplicate keys

2021-11-13 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
assignee:  -> bob.ippolito

___
Python tracker 

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



[issue45738] 3.11 exec raises SystemError instead of SyntaxError on char after line continuation

2021-11-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 142fcb40b6e460fa9b4a89fe9846b1ce4176354e by Pablo Galindo Salgado 
in branch '3.9':
bpo-45738: Fix computation of error location for invalid continuation 
characters in the parser (GH-29550) (GH-29552)
https://github.com/python/cpython/commit/142fcb40b6e460fa9b4a89fe9846b1ce4176354e


--

___
Python tracker 

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



[issue45738] 3.11 exec raises SystemError instead of SyntaxError on char after line continuation

2021-11-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

This should be fixed by now, but please, check if everything is in order in 
your respective test suites and confirm here.

--

___
Python tracker 

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



[issue45738] 3.11 exec raises SystemError instead of SyntaxError on char after line continuation

2021-11-13 Thread miss-islington


miss-islington  added the comment:


New changeset bf26a6da7aaedb526c9eb1cb56b0e46d1c10384c by Miss Islington (bot) 
in branch '3.10':
bpo-45738: Fix computation of error location for invalid continuation (GH-29550)
https://github.com/python/cpython/commit/bf26a6da7aaedb526c9eb1cb56b0e46d1c10384c


--

___
Python tracker 

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



[issue45738] 3.11 exec raises SystemError instead of SyntaxError on char after line continuation

2021-11-13 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +27801
pull_request: https://github.com/python/cpython/pull/29552

___
Python tracker 

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



[issue45054] json module should issue warning about duplicate keys

2021-11-13 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

-0 on doing this. The suggested warning/error adds overhead that everyone would 
pay for but would almost never be of benefit.  I haven't seen this particular 
problem arise in practice.  The likely reasons it doesn't come up are 1) that 
generated data doesn't normally produce mixed type keys, 2) because mixed type 
keys don't round-trip, and 3) even using numeric keys only (not mixed) is 
uncommon because it results in poor outcomes that fail round-trip invariants.

Andrei Kulakov is right in saying that such data suggests deeper problems with 
the design and that static typing would be beneficial.

One last thought:  Even with regular dicts, we don't normally warn about 
encountering duplicate keys:

>>> dict([(1, 'run'), (1, 'zoo'), (3, 'tree')])
{1: 'zoo', 3: 'tree'}

--
nosy: +rhettinger

___
Python tracker 

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



[issue45738] 3.11 exec raises SystemError instead of SyntaxError on char after line continuation

2021-11-13 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue45738] 3.11 exec raises SystemError instead of SyntaxError on char after line continuation

2021-11-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 25835c518aa7446f3680b62c1fb43827e0f190d9 by Pablo Galindo Salgado 
in branch 'main':
bpo-45738: Fix computation of error location for invalid continuation (GH-29550)
https://github.com/python/cpython/commit/25835c518aa7446f3680b62c1fb43827e0f190d9


--

___
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-11-13 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

These speedups all to be significant and worth doing.

--

___
Python tracker 

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



[issue45738] 3.11 exec raises SystemError instead of SyntaxError on char after line continuation

2021-11-13 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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

___
Python tracker 

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



[issue45765] importlib.metadata fails to find distributions in empty path

2021-11-13 Thread Jason R. Coombs


Change by Jason R. Coombs :


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



[issue45799] Fix confusing wording in Doc/library/__main__.rst

2021-11-13 Thread Eric V. Smith


Eric V. Smith  added the comment:

Thanks for your contribution!

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



[issue45243] [sqlite3] add support for changing connection limits

2021-11-13 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


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



[issue45801] Incorrect "Perhaps you forgot a comma" hint

2021-11-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I will close this but will try to think for another issue into an error for the 
parens -> braket. Thanks for opening the issue!

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



[issue45799] Fix confusing wording in Doc/library/__main__.rst

2021-11-13 Thread miss-islington


miss-islington  added the comment:


New changeset 28326ac5f87ede140268376f0c87c3b2aba62906 by Miss Islington (bot) 
in branch '3.10':
bpo-45799: [Doc] improve confusing sentence in __main__.rst (GH-29546)
https://github.com/python/cpython/commit/28326ac5f87ede140268376f0c87c3b2aba62906


--

___
Python tracker 

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



[issue45803] make_dataclass is missing the documented kw_only argument

2021-11-13 Thread Eric V. Smith


Change by Eric V. Smith :


--
assignee:  -> eric.smith
components: +Library (Lib) -ctypes
nosy: +eric.smith
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



[issue45799] Fix confusing wording in Doc/library/__main__.rst

2021-11-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +27798
pull_request: https://github.com/python/cpython/pull/29549

___
Python tracker 

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



[issue45799] Fix confusing wording in Doc/library/__main__.rst

2021-11-13 Thread miss-islington


miss-islington  added the comment:


New changeset f8da00ef04fdadf7cd9821e8ec4b317ecf3ed663 by Jack DeVries in 
branch 'main':
bpo-45799: [Doc] improve confusing sentence in __main__.rst (GH-29546)
https://github.com/python/cpython/commit/f8da00ef04fdadf7cd9821e8ec4b317ecf3ed663


--
nosy: +miss-islington

___
Python tracker 

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



[issue45801] Incorrect "Perhaps you forgot a comma" hint

2021-11-13 Thread Andre Roberge


Andre Roberge  added the comment:

I understand.

I reported this issue when one of my newest tests failed with Python 3.10 and 
3.11. Actually, using friendly-traceback, using the location of the exception 
as indicated by cPython 3.10 and 3.11, here's part of the explanation it gives:

The following lines of code would not cause any `SyntaxError`:

sum + [i for i in [1, 2, 3] if i%2==0]
sum - [i for i in [1, 2, 3] if i%2==0]
sum * [i for i in [1, 2, 3] if i%2==0]
sum, [i for i in [1, 2, 3] if i%2==0]
Note: these are just some of the possible choices and that
some of them might raise other types of exceptions.

So, I agree with you that suggesting a comma would be appropriate.  (I also 
miss the suggestion of inserting an equal sign above).

Meanwhile, with prior versions of cPython, here's the suggestion that was 
offered:

You used square brackets, `[...]` instead of parentheses.
Write the following instead:

sum(i for i in [1, 2, 3] if i%2==0)

So, since using the suggestion currently by cPython (3.10, 3.11), one could get 
a syntactically valid statement by adding a comma, I cannot really argue that 
this is a bug. (Sorry, I should have checked in more details before.)

Therefore, I agree that this issue should probably be closed ... unless you 
find that suggesting a missing comma while there are many other possible 
operators that could be inserted could be considered as misleading.

--

___
Python tracker 

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



[issue45765] importlib.metadata fails to find distributions in empty path

2021-11-13 Thread Jason R. Coombs


Jason R. Coombs  added the comment:


New changeset ed55426acd58f030ccc0cf1297e66078f538797c by Miss Islington (bot) 
in branch '3.10':
[bpo-45765] Fix distribution discovery on empty path. (GH-29487) (GH-29510)
https://github.com/python/cpython/commit/ed55426acd58f030ccc0cf1297e66078f538797c


--

___
Python tracker 

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



[issue45765] importlib.metadata fails to find distributions in empty path

2021-11-13 Thread Jason R. Coombs


Jason R. Coombs  added the comment:


New changeset 3e0b830e859ca8792401bfd1402d659f56f99941 by Jason R. Coombs in 
branch '3.9':
[3.9] [bpo-45765] Fix distribution discovery on empty path. (GH-29487). 
(GH-29511)
https://github.com/python/cpython/commit/3e0b830e859ca8792401bfd1402d659f56f99941


--

___
Python tracker 

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



[issue45801] Incorrect "Perhaps you forgot a comma" hint

2021-11-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I think this is correct because if you add a comma, indeed is valid syntax:

>>> sum,[i for i in [1, 2, 3] if i%2==0]
(, [2])

Here the problem is that you are mentally mapping the construct to sum(...) 
where the parens are substituted with brackets, which is not what the parser 
sees, the parser sees two expressions glued together like

>> f() g()
  File "", line 1
f() g()
^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?

and it surrounds the whole expression. 

Do you have an idea on what you would prefer here? Otherwise, I suggest to 
close as "not a bug".

--

___
Python tracker 

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



[issue45803] make_dataclass is missing the documented kw_only argument

2021-11-13 Thread Tsvetan Kintisheff


Tsvetan Kintisheff  added the comment:

to clarify, the documentation permalink is: 
https://docs.python.org/3/library/dataclasses.html#dataclasses.make_dataclass

--

___
Python tracker 

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



[issue45803] make_dataclass is missing the documented kw_only argument

2021-11-13 Thread Tsvetan Kintisheff


New submission from Tsvetan Kintisheff :

According to the 3.10 documentation, make_dataclass includes the kw_only 
argument: 
https://github.com/python/cpython/blob/3f15792d60011639d9b170d8a76c6db7f6e83665/Lib/dataclasses.py#L1327

However, the source code referred to by the same doc does not appear to include 
the kw_only argument:
https://github.com/python/cpython/blob/3f15792d60011639d9b170d8a76c6db7f6e83665/Lib/dataclasses.py#L1327

--
components: ctypes
messages: 406290
nosy: kintisheff
priority: normal
severity: normal
status: open
title: make_dataclass is missing the documented kw_only argument
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



[issue45762] Missing `list` symbols in the object inventory

2021-11-13 Thread Éric Araujo

Éric Araujo  added the comment:

If you search in the index, there is no entry like 'append (list method)', only 
'append (sequence method)': https://docs.python.org/3/genindex-A.html
This goes to the reference docs, where list methods are documented indirectly 
by reference to the Sequence protocol described just above the list section: 
https://docs.python.org/3/library/stdtypes.html#lists

The tutorial page lists all methods for people learning, with noindex markup to 
avoid pointing from the index to the reference: 
https://github.com/python/cpython/blob/3.10/Doc/tutorial/datastructures.rst#L19

The individual decisions make sense, but I think the results is not 
satisfactory: there is no reference to list.append (etc) in the index or the 
sphinx inventory (only 'list.sort' is there, from the entry in the 
library/stdtypes list section).  I think index markup should be added for all 
built-in types in the stdtypes page so that links are generated.  
Alternatively, add a sphinx directive to register that a type matches the 
sequence (etc) protocol, so that index entries for all protocol methods can be 
generated automatically.

--

___
Python tracker 

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



[issue45752] copy module doc wrongly says it doesn't copy arrays

2021-11-13 Thread Mohammad Mostafa Farzan


Change by Mohammad Mostafa Farzan :


--
keywords: +patch
nosy: +m2_farzan
nosy_count: 4.0 -> 5.0
pull_requests: +27797
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/29548

___
Python tracker 

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



[issue42248] Raised exception in Enum keeping user objects alive unnecessarily

2021-11-13 Thread Ethan Furman


Change by Ethan Furman :


--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

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



[issue44559] Enum: revert to 3.9

2021-11-13 Thread Ethan Furman


Change by Ethan Furman :


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



[issue45802] MozillaCookieJar can't read cookies, should support cookies.sqlite

2021-11-13 Thread Akkana Peck


New submission from Akkana Peck :

http.cookiejar.MozillaCookieJar only reads from cookies.txt, a format that 
Mozilla hasn't used in over a decade. It should read the file mozilla actually 
uses, cookies.sqlite.

Here's some code that works to turn cookies.sqlite into cookies.txt in order to 
read it in to MozillaCookieJar:
 http://blog.mithis.net/archives/python/90-firefox3-cookies-in-python

This was requested in 2008 in issue 2277, around the time Mozilla made the 
switch. The issue was rejected back then because it was too late to make the 
final beta for Python 2.6/3.0. I'd like to bring it up again now.

I can write a patch (since a real fix should read the cookies into the 
cookiejar directly, not use StringIO to create an intermediate cookies.txt) if 
there's any chance it would be accepted.

--
components: Library (Lib)
messages: 406288
nosy: akkana
priority: normal
severity: normal
status: open
title: MozillaCookieJar can't read cookies, should support cookies.sqlite

___
Python tracker 

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



[issue45801] Incorrect "Perhaps you forgot a comma" hint

2021-11-13 Thread Andre Roberge


New submission from Andre Roberge :

Python 3.10 and 3.11:

>>> sum[i for i in [1, 2, 3] if i%2==0]
  File "", line 1
sum[i for i in [1, 2, 3] if i%2==0]
^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?

Furthermore, I don't find that highlighting the entire statement (or parts of 
it, if we use print(sum[...]) is very useful in attempting to find the source 
of the error.

In previous versions, we would get the following:

>>> sum[i for i in [1, 2, 3] if i%2==0]
  File "", line 1
sum[i for i in [1, 2, 3] if i%2==0]
  ^
SyntaxError: invalid syntax

--
components: Parser
messages: 406287
nosy: aroberge, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: Incorrect "Perhaps you forgot a comma" hint
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



[issue44924] logging.handlers.QueueHandler does not maintain the exc_text

2021-11-13 Thread Jack_B


Jack_B  added the comment:

OK, I had a misunderstanding about what record.stack_info was. I see it is a 
string, so doesn't need to be stripped. Ignore my first con and the previous 
message.  Sorry for the noise.

--

___
Python tracker 

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



[issue44924] logging.handlers.QueueHandler does not maintain the exc_text

2021-11-13 Thread Jack_B


Jack_B  added the comment:

Whoops! I've been a bit inconsistent between the code and my pros and cons 
about whether exc_text gets record.stack_info as well as record.exc_info. But 
either option is possible.  As an aside, I'm not sure why stack info is not 
cached in e.g. record.stack_text for the same reasons that exc_text is cached.

--

___
Python tracker 

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



[issue45756] mock raises exception when using a spec with an attribute that raises exception on access

2021-11-13 Thread Jaap Roes


Jaap Roes  added the comment:

I think I encountered this when trying to mock `requests.Response`:  
https://github.com/psf/requests/issues/5944

--
nosy: +jaap3

___
Python tracker 

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



[issue44924] logging.handlers.QueueHandler does not maintain the exc_text

2021-11-13 Thread Jack_B


Jack_B  added the comment:

This also tripped me up recently.  More broadly, I assumed that handlers 
downstream of the QueueHandler/QueueListener would get complete log records. 
Having looked at it, I can see they need to be pickled, and that means 
stripping some information. But like Mikael, I found the current behaviour a 
bit confusing.

The solution I am using is to override logging.Formatter.format and 
QueueHandler.Prepare like so:

class _OptionalExcFormatter(logging.Formatter):
def format(self, record, with_exc=True, with_stack=True):
"""
Format the specified record as text.

Same as superclass except it only adds the exc_info and stack_info if
the corresponding arguments are True.
"""
record.message = record.getMessage()
if self.usesTime():
record.asctime = self.formatTime(record, self.datefmt)
s = self.formatMessage(record)
if record.exc_info and with_exc:
# Cache the traceback text to avoid converting it multiple times
# (it's constant anyway)
if not record.exc_text:
record.exc_text = self.formatException(record.exc_info)
if record.exc_text and with_exc:
if s[-1:] != "\n":
s = s + "\n"
s = s + record.exc_text
if record.stack_info and with_stack:
if s[-1:] != "\n":
s = s + "\n"
s = s + self.formatStack(record.stack_info)
return s

class _QueueHandlerExc(QueueHandler):
def prepare(self, record):
# bpo-35726: make copy of record to avoid affecting other handlers in 
the chain.
record = copy.copy(record)
# Get a formatter. It must support the with_exc and with_stack args to 
f.format
if self.formatter is None:
f = _OptionalExcFormatter()
else:
f = self.formatter
# Merge args into message and strip them as they may not be pickleable
msg = f.format(record, with_exc=False, with_stack=False)
record.message = msg
record.msg = msg
record.args = None
# Convert exc_info into exc_text and strip it as it may not be 
pickleable
if record.exc_info is not None:
record.exc_text = f.formatException(record.exc_info)
record.exc_info = None
return record

Pros:
 - The record feels "less mangled"
 - It does not require another formatter to have already populated exc_text, 
and allows the use of a specific formatter to do so.
 - Having the message and exc_text separate seems logical, and allows 
downstream handlers/formatters to treat them differently.
 - logging.Formatter can get the changes above in a back-compatible way
Cons:
 - exc_text now contains the stack trace as well as the usual exc_info, which 
is a little odd, but it still seems to be a better place for it than the 
message.
 - If QueueHandler gets the changes above, it will break code where 
QueueHandler is used with a custom Formatter which overrides Formatter.format. 
This is probably not OK. 

I think the changes to logging.Formatter might also be useful elsewhere, as it 
would enable you to do:
class _NoStackFormatter(logging.Formatter):
def format(self, record):
return super().format(record, with_exc=True, with_stack=False)
to have a formatter which omits stack traces.

--
nosy: +Jack_B

___
Python tracker 

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



[issue45773] Compiler hangs during jump elimination

2021-11-13 Thread Brandt Bucher


Change by Brandt Bucher :


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

___
Python tracker 

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



[issue45791] __instancecheck__ being checked on type(cls) instead of cls

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



[issue45800] Move expat handling into configure and Makefile

2021-11-13 Thread Christian Heimes


Change by Christian Heimes :


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

___
Python tracker 

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



[issue45800] Move expat handling into configure and Makefile

2021-11-13 Thread Christian Heimes


Christian Heimes  added the comment:

An intermediate libexpat.a simplifies Modules/Setup.

The explicit rules are required to support BSD make. bmake does neither have 
"%.o: %.c" nor target variable overrides like GNU make.

--

___
Python tracker 

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



[issue45800] Move expat handling into configure and Makefile

2021-11-13 Thread Christian Heimes


New submission from Christian Heimes :

Move logic for --with-system-expat out of setup.py into configure and Makefile. 
This will enable --with-system-expat in Modules/Setup without manual patching.

* Set CFLAGS and LDFLAGS for pyexpat and libexpat in configure.
* Build a static libexpat.a from our copy of expat when --with-system-expat is 
not given
* Either link pyexpat with libexpat.a or system libexpat.

Basically use the same approach as decimal changeset bpo-45798.

--
assignee: christian.heimes
components: Build
messages: 406281
nosy: christian.heimes
priority: normal
severity: normal
status: open
title: Move expat handling into configure and Makefile
type: enhancement
versions: Python 3.11

___
Python tracker 

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



[issue45755] Specialized generic class does not return class attributes in dir

2021-11-13 Thread Guido van Rossum

Guido van Rossum  added the comment:

Isn’t the solution to use the unspecialized class?

--

___
Python tracker 

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



[issue45799] Fix confusing wording in Doc/library/__main__.rst

2021-11-13 Thread Jack DeVries


Change by Jack DeVries :


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

___
Python tracker 

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



[issue45799] Fix confusing wording in Doc/library/__main__.rst

2021-11-13 Thread Jack DeVries


New submission from Jack DeVries :

I was reading this bit last night and thought it was a typo. In the light of 
day, I realized it wasn't *technically* a typo, but definitely confusing 
wording. This PR fixes the confusing sentence.

--
assignee: docs@python
components: Documentation
messages: 406279
nosy: docs@python, jack__d
priority: normal
severity: normal
status: open
title: Fix confusing wording in Doc/library/__main__.rst
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



[issue45292] Implement PEP 654: Exception Groups

2021-11-13 Thread Irit Katriel


Change by Irit Katriel :


--
pull_requests: +27794
pull_request: https://github.com/python/cpython/pull/29545

___
Python tracker 

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



[issue45798] Move _decimal build setup into configure

2021-11-13 Thread Christian Heimes


Change by Christian Heimes :


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



[issue45798] Move _decimal build setup into configure

2021-11-13 Thread Christian Heimes


Christian Heimes  added the comment:

I tested the --with-system-libmpdec successfully on my system. Most vendors are 
using the internal copy of libmpdec any way. AFAIK only Debian-based systems 
use their own system libmpdec.

$ ./configure -C --with-system-libmpdec
$ make
...
building '_decimal' extension
gcc -pthread -fPIC -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 
-Wextra -Wno-unused-parameter -Wno-missing-field-initializers 
-Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal 
-I./Include -I. -I/usr/local/include -I/home/heimes/dev/python/cpython/Include 
-I/home/heimes/dev/python/cpython -c 
/home/heimes/dev/python/cpython/Modules/_decimal/_decimal.c -o 
build/temp.linux-x86_64-3.11/home/heimes/dev/python/cpython/Modules/_decimal/_decimal.o
 -DCONFIG_64=1 -DASM=1
gcc -pthread -shared 
build/temp.linux-x86_64-3.11/home/heimes/dev/python/cpython/Modules/_decimal/_decimal.o
 -L/usr/local/lib -o 
build/lib.linux-x86_64-3.11/_decimal.cpython-311-x86_64-linux-gnu.so -lmpdec
...
$ ldd build/lib.linux-x86_64-3.11/_decimal.cpython-311-x86_64-linux-gnu.so 
linux-vdso.so.1 (0x7ffde21e1000)
libmpdec.so.3 => /lib64/libmpdec.so.3 (0x7f4f3b4cf000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x7f4f3b4ae000)
libc.so.6 => /lib64/libc.so.6 (0x7f4f3b2df000)
libm.so.6 => /lib64/libm.so.6 (0x7f4f3b19b000)
/lib64/ld-linux-x86-64.so.2 (0x7f4f3b554000)

--

___
Python tracker 

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



[issue45781] Deleting __debug__ should be an SyntaxError

2021-11-13 Thread Carl Friedrich Bolz-Tereick


Carl Friedrich Bolz-Tereick  added the comment:

ouch, apologies for not checking that!

--

___
Python tracker 

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



[issue45798] Move _decimal build setup into configure

2021-11-13 Thread Christian Heimes


Christian Heimes  added the comment:

Thanks for the quick review, Mark!

--

___
Python tracker 

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



[issue45798] Move _decimal build setup into configure

2021-11-13 Thread Christian Heimes


Christian Heimes  added the comment:


New changeset 0486570f7b2b5a75812e5a01a8dca58bfadc2437 by Christian Heimes in 
branch 'main':
bpo-45798: Move _decimal build setup into configure (GH-29541)
https://github.com/python/cpython/commit/0486570f7b2b5a75812e5a01a8dca58bfadc2437


--

___
Python tracker 

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



[issue31842] pathlib: "Incorrect function" during resolve()

2021-11-13 Thread Eryk Sun


Change by Eryk Sun :


--
stage:  -> needs patch
type:  -> behavior

___
Python tracker 

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



[issue31842] pathlib: "Incorrect function" during resolve()

2021-11-13 Thread Eryk Sun


Eryk Sun  added the comment:

> perfectly valid redirected paths (winfsp ram drives for example)

I mounted a WinFsp MEMFS filesystem on a directory, which set a mountpoint that 
targets the root path of a volume device in the native "\Device" object 
directory. It didn't create a volume GUID name, which means the mountpoint 
manager isn't supported in this configuration.

The error code ERROR_UNRECOGNIZED_VOLUME (1005) is meaningless in this case. 
The mountpoint manager queries a volume with IOCTLs such as 
IOCTL_MOUNTDEV_QUERY_DEVICE_NAME, which the WinFsp virtual volume (in the above 
configuration) doesn't support. Weirdly, it returns the error code 
STATUS_UNRECOGNIZED_VOLUME instead of STATUS_INVALID_DEVICE_REQUEST. It does 
this as a lazy workaround for various IOCTLs it receives from filesystem 
drivers while the volume is in the process of being mounted [1][2]. The side 
effect is that it returns STATUS_UNRECOGNIZED_VOLUME for unhandled IOCTLs even 
when it's not getting mounted. This behavior should have been restricted to 
when the volume parameter block (VPB) is unmounted. Otherwise it should return 
the expected error code STATUS_INVALID_DEVICE_REQUEST (i.e. 
ERROR_INVALID_FUNCTION) instead of confusing users with a meaningless error.

WinFsp does support the mountpoint manager, in a restricted fashion. The mount 
target has to be a drive device name in the form "\\.\X:". This gets registered 
with the mountpoint manager as the canonical DOS name of the volume. Since it's 
a global name, administrator access is required. It also creates a GUID volume 
name. Run mountvol.exe without arguments to find the volume name that's 
associated with the drive letter. Then run it again as `mountvol  
`, where  is an empty directory on which to mount the 
volume. Note that Python's os.path.realpath() will resolve the volume to the 
canonical drive name, even if the path traverses a directory mountpoint for the 
volume.

A new issue should be created to ignore ERROR_UNRECOGNIZED_VOLUME in 3.10+, for 
which Path.resolve() was updated to call os.path.realpath(). For 3.9, fixing 
Path.resolve() is still possible. There are 3 remaining bug releases planned: 
3.9.9: (2022-01-03), 3.9.10 (2022-02-28), and 3.9.11 (2022-05-02).

---
[1] https://github.com/billziss-gh/winfsp/blob/v1.9/src/sys/devctl.c#L49
[2] https://github.com/billziss-gh/winfsp/issues/177

--

___
Python tracker 

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



[issue40222] "Zero cost" exception handling

2021-11-13 Thread Ruairidh MacLeod


Change by Ruairidh MacLeod :


--
nosy: +rkm

___
Python tracker 

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



[issue43878] ./configure fails on Apple Silicon with coreutils uname

2021-11-13 Thread Ivan Pozdeev


Ivan Pozdeev  added the comment:

> Someone nonchalantly updated these in 
> https://github.com/python/cpython/commit/2fc857a5721a5b42bcb696c9cae1bbcc82a91b17
>  so this bug is now fixed

That PR only goes into 3.11. While this ticket claims to have fixed the problem 
for 3.10 as well.

Should that PR be backported? Alternatively, 
https://github.com/python/cpython/pull/25450 should be merged, but into `3.10` 
instead of `master`.

--
nosy: +ivan.pozdeev.gm

___
Python tracker 

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



[issue45798] Move _decimal build setup into configure

2021-11-13 Thread Christian Heimes


Christian Heimes  added the comment:

PS: I had to add an explicit make rule for each object file. "%.o: %c" 
templates are not portable.

--

___
Python tracker 

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



[issue45798] Move _decimal build setup into configure

2021-11-13 Thread Christian Heimes


Change by Christian Heimes :


--
keywords: +patch
pull_requests: +27793
pull_request: https://github.com/python/cpython/pull/29541

___
Python tracker 

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



[issue45798] Move _decimal build setup into configure

2021-11-13 Thread Christian Heimes


New submission from Christian Heimes :

Compiler and linker flags for _decimal and internal libmpdec are currently 
handled by a mix of configure checks and if/else chains in setup.py. The split 
makes it harder to build _decimal correctly from Modules/Setup. The 
Modules/Setup file also does not handle --with-system-mpdec.

I have a working PR that moves all logic into configure.ac. The new system:

* sets LIBMPDEC_CFLAGS and LIBMPDEC_LDFLAGS based on --with-system-libmpdec 
value.

* detects libmpdec_machine by looking at ac_sys_system, MACOSX_DEFAULT_ARCH, 
ac_cv_sizeof_size_t, ac_cv_gcc_asm_for_x64, ac_cv_type___uint128_t, and 
ac_cv_gcc_asm_for_x87.

* sets libmpdec compiler args based on libmpdec_machine, 
have_ipa_pure_const_bug, and have_glibc_memmove_bug.

* if --with-system-libmpdec is not given, then our Makefile compiles libmpdec 
objects and puts them into a libmpdec.a archive.

* finally it either links _decimal with our libmpdec.a or with system's 
libmpdec shared library.

I went for libmpdec.a because it makes the logic for the internal path look 
similar to the logic with linking with an external shared library.

Modules/Setup

--
assignee: christian.heimes
components: Build
messages: 406271
nosy: christian.heimes, mark.dickinson, pitrou
priority: normal
severity: normal
stage: patch review
status: open
title: Move _decimal build setup into configure
type: enhancement
versions: Python 3.11

___
Python tracker 

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