[issue11838] IDLE: make interactive code savable as a runnable script

2021-09-26 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
priority: normal -> high

___
Python tracker 

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



[issue11838] IDLE: make interactive code savable as a runnable script

2021-09-26 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

This should be easier to do with the new shell with indents fixed.

--
nosy:  -roger.serwy, tlesher
versions: +Python 3.11 -Python 3.6, Python 3.7

___
Python tracker 

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



[issue41271] Add support for io_uring to cpython

2021-09-26 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
nosy:  -terry.reedy

___
Python tracker 

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



[issue45296] IDLE: Change Ctrl-Z note in exit/quit repr on Windows

2021-09-26 Thread Terry J. Reedy


Change by Terry J. Reedy :


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

___
Python tracker 

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



[issue45299] SMTP.send_message() does from mangling when it should not

2021-09-26 Thread Grant Edwards


New submission from Grant Edwards :

SMTP.send_message() does from mangling even when the message's policy
has that disabled. The problem is in the send_messsage() function
shown below:


   912  def send_message(self, msg, from_addr=None, to_addrs=None,
   913   mail_options=(), rcpt_options=()):
   914  """Converts message to a bytestring and passes it to sendmail.
   ...
   963  # Make a local copy so we can delete the bcc headers.
   964  msg_copy = copy.copy(msg)
   ...
   977  with io.BytesIO() as bytesmsg:
   978  if international:
   979  g = email.generator.BytesGenerator(
   980  bytesmsg, policy=msg.policy.clone(utf8=True))
   981  mail_options = (*mail_options, 'SMTPUTF8', 
'BODY=8BITMIME')
   982  else:
   983  g = email.generator.BytesGenerator(bytesmsg)
   984  g.flatten(msg_copy, linesep='\r\n')
   985  flatmsg = bytesmsg.getvalue()

If 'international' is True, then the BytesGenerator is passed
msg.policy with utf8 added, and from mangling is only done if the
message's policy has from mangling enabled. This is correct behavior.

If 'international' is False, then the generator always does from
mangling regardless of the message'spolicy. From mangling is only used
when writing message to mbox format files. When sending a message via
SMTP It is wrong to do it when the message's policy says not to.

This needs to be fixed by passing the message's policy to BytesGenerator()
in the 'else' clause also.  I would suggest changing

   983  g = email.generator.BytesGenerator(bytesmsg)
to

   983  g = email.generator.BytesGenerator(bytesmsg, 
policy=msg.policy)


The problem is that if neither mangle_from_ nor policy arguments are
passed to email.generator.BytesGenerator(), then mangle_from_ defaults
to True, and the mangle_from_ setting in the message is ignored. This is
not really documented:

  
https://docs.python.org/3/library/email.generator.html#email.generator.BytesGenerator

If optional mangle_from_ is True, put a > character in front of
any line in the body that starts with the exact string "From ",
that is From followed by a space at the beginning of a
line. mangle_from_ defaults to the value of the mangle_from_
setting of the policy.
   
Where "the policy" refers to the one passed to BytesGenerator(). Note
that this section does _not_ state what happens if neither
mangle_from_ nor policy are passed to BytesGenerator(). What actually
happens is that in that case mangle_from_ defaults to True. (Not a
good choice for default, since that's only useful for the one case
where you're writing to an mbox file.)

However, there is also a misleading sentence later in that same
section:

If policy is None (the default), use the policy associated with
the Message or EmailMessage object passed to flatten to control
the message generation.

That's only partially true. If you don't pass a policy to
BytesGenerator(), only _some_ of the settings from the message's
policy will be used. Some policy settings (e.g. mangle_from_) are
obeyed when passed to BytesGenerator(), but ignored in the message's
policy even if there was no policy passed to BytesGenerator().

The documentation needs to be changed to state that mangle_from_
defaults to True if neitehr mangle_from_ nor policy are passed to
BytesGenerator(), and that last sentence needs to be changed to state
that when no policy is passed to BytesGenerator() only _some_ of the
fields in the message's policy are used to control the message
generation. (An actual list of policy fields are obeyed from the
message's policy would be nice.)

--
components: Library (Lib)
messages: 402690
nosy: grant.b.edwards
priority: normal
severity: normal
status: open
title: SMTP.send_message() does from mangling when it should not
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



[issue45296] IDLE: Change Ctrl-Z note in exit/quit repr on Windows

2021-09-26 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Tal, Paine: should be use exactly the raw REPL message or something that might 
be clearer to beginners, like 'Ctrl-D (end-of-file)'?

--
nosy: +epaine, taleinat

___
Python tracker 

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



[issue45296] IDLE: Change Ctrl-Z note in exit/quit repr on Windows

2021-09-26 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
assignee:  -> terry.reedy
components: +IDLE
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



[issue41994] Refcount issues in import

2021-09-26 Thread Gregory Szorc


Gregory Szorc  added the comment:

While testing 3.10.0rc2, I noticed that commit 
4db8988420e0a122d617df741381b0c385af032c removed 
_PyImport_FindExtensionObject() from libpython. This breaks both PyOxidizer and 
py2exe, which rely on this function for a custom implementation of 
Loader.create_module() to enable loading Windows DLLs from memory.

It can probably be worked around. But I wanted to note it here in case it was 
an unwanted regression.

--
nosy: +indygreg

___
Python tracker 

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



[issue45069] python 3.9.2 contains libcrypto-1_1.dll and libssl-1_1.dll associates CVE-2021-23840\CVE-2021-3450\CVE-2021-3711\CVE-2021-3712\CVE-2021-23841\CVE-2021-3449 of openssl-1.1.1i

2021-09-26 Thread Ned Deily


Change by Ned Deily :


--
status: open -> closed

___
Python tracker 

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



[issue45298] SIGSEGV when access a fork Event in a spawn Process

2021-09-26 Thread Keming


New submission from Keming :

Code to trigger this problem:

```python
import multiprocessing as mp
from time import sleep


def wait_for_event(event):
while not event.is_set():
sleep(0.1)


def trigger_segment_fault():
event = mp.get_context("fork").Event()
p = mp.get_context("spawn").Process(target=wait_for_event, args=(event,))
p.start()  # this will show the exitcode=-SIGSEGV
sleep(1)
print(p)
event.set()
p.terminate()


if __name__ == "__main__":
trigger_segment_fault()
```

Accessing this forked event in a spawned process will result in a segment fault.

I have found a related report: https://bugs.python.org/issue43832. But I think 
it's not well documented in the Python 3 multiprocessing doc.

Will it be better to explicit indicate that the event is related to the start 
method context in the documentation?

--
assignee: docs@python
components: Documentation
messages: 402687
nosy: docs@python, kemingy
priority: normal
severity: normal
status: open
title: SIGSEGV when access a fork Event in a spawn Process
type: crash

___
Python tracker 

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



[issue45297] Improve the IDLE shell save command

2021-09-26 Thread Steven D'Aprano


New submission from Steven D'Aprano :

See this question on Discuss:

https://discuss.python.org/t/what-is-this-syntax-i-dont-know-how-to-fix-it/10844

It seems that IDLE allows you to save the shell output, complete with welcome 
message and prompts, as a .py file, and then reopen it and attempt to run it, 
which obviously fails. When it does fail, it is confusing.

Suggested enhancements:

- When saving the complete shell session, save it to a text file, not .py. That 
would be useful for anyone wanting a full record of the interpreter session.

- When saving the shell session as a .py file, strip out the welcome message, 
the prompts, and any output, leaving only what will hopefully be runnable code.

I don't know what sort of UI this should have. Two different menu commands? A 
checkbox in the Save dialog?

My thoughts are that the heuristic to reconstruct runnable code from the 
interpreter session may not be foolproof, but better than nothing. Something 
like the doctest rules might work reasonably well.

- strip the welcome message;

- any line (or block) starting with the prompt >>> that is followed by a 
traceback should be thrown out;

- any other text not starting with the prompt >>> is interpreter output and 
should be thrown out;

- you should be left with just blocks starting with the prompt, so remove the 
prompt, adjust the indents, and hopefully you're left with valid runnable code.

--
assignee: terry.reedy
components: IDLE
messages: 402686
nosy: steven.daprano, terry.reedy
priority: normal
severity: normal
status: open
title: Improve the IDLE shell save command
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



[issue43914] Highlight invalid ranges in SyntaxErrors

2021-09-26 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +26959
pull_request: https://github.com/python/cpython/pull/28576

___
Python tracker 

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



[issue45069] python 3.9.2 contains libcrypto-1_1.dll and libssl-1_1.dll associates CVE-2021-23840\CVE-2021-3450\CVE-2021-3711\CVE-2021-3712\CVE-2021-23841\CVE-2021-3449 of openssl-1.1.1i

2021-09-26 Thread Ned Deily


Change by Ned Deily :


--
stage:  -> resolved
status: pending -> open

___
Python tracker 

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



[issue45249] Update doctect SyntaxErrors for location range

2021-09-26 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +26958
pull_request: https://github.com/python/cpython/pull/28575

___
Python tracker 

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



[issue44933] python3.9-intel64 hardened runtime not enabled

2021-09-26 Thread Ned Deily


Ned Deily  added the comment:

> the "reliable way to run under rosetta" is using "arch -x86_64 python3". I 
> don't particularly like having another executable to accomplish the same goal.

Unfortunately, using "arch" is *not* a reliable way in general. It works fine 
for the initial invocation of the interpreter but things fall apart when a 
Python program tries to invoke another Python interpreter in a subprocess. The 
standard idiom for finding the location of the running interpreter is to use 
the contents of sys.executable. But that merely contains the name of the 
interpreter file, thus the additional "arch" arguments are lost and the 
interpreter will launch in the subprocess using the default arch, which may 
result in a failure (if you are lucky) or, worse, will silently run under the 
wrong architecture potentially giving misleading results. The most notable 
example of this is while running the python test suite. We ran into this same 
issue years ago with the "intel" universal-arch build option which is why we 
added a "python3-32" executable to provide a reliable way to force 32-bit 
execution on a 64-bit-capable Mac. The need for "python3-intel64" will 
eventually go a
 way once Rosetta2 is no longer supported.

--

___
Python tracker 

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



[issue44493] Missing terminated NUL in the length of sockaddr_un

2021-09-26 Thread Ned Deily


Change by Ned Deily :


--
resolution: fixed -> 
versions: +Python 3.11 -Python 3.6

___
Python tracker 

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



[issue42969] pthread_exit & PyThread_exit_thread from PyEval_RestoreThread etc. are harmful

2021-09-26 Thread Jeremy Maitin-Shepard


Jeremy Maitin-Shepard  added the comment:

Yes, I would agree that the new APIs are a useful addition regardless of the 
PyThread_exit_thread change.

As far as the proposed `Py_SetThreadExitCallback` that seems like a fine thing 
for applications to use, as long as it doesn't impact how extensions need to be 
written to be safe from crashes/memory corruption.  So for example if the 
default is to hang, then changing it to log and then hang, or optionally log 
and terminate the program, would be fine, since extensions aren't affected 
either way.

Conversely, if one of the possible behaviors may be `_endthreadex` or 
`pthread_exit`, then libraries must be written to be safe under that behavior 
anyway, which is unfortunate.  Furthermore, say for a library that only 
supports POSIX, maybe it is written to be safe under `pthread_exit` because it 
uses destructors to do cleanup, but then it will cause deadlock if the callback 
chooses to hang the thread instead.  Thus, I think allowing the callback to 
change the behavior in a way that could impact extensions is not a great idea.

The callback also doesn't seem like a very good mechanism for an extension that 
is incompatible with `pthread_exit` or `_endthreadex`, such as one using 
pybind11, to try to mitigate that problem, since an individual library 
shouldn't be changing application-wide behavior unless the library is 
specifically being used by the application for that purpose.

--

___
Python tracker 

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



[issue44958] [sqlite3] only reset statements when needed

2021-09-26 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 7b88f63e1dd4006b1a08b9c9f087dd13449ecc76 by Erlend Egeberg 
Aasland in branch 'main':
bpo-44958: Revert GH-27844 (GH-28574)
https://github.com/python/cpython/commit/7b88f63e1dd4006b1a08b9c9f087dd13449ecc76


--

___
Python tracker 

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



[issue36717] Allow retrieval of return value from the target of a threading.Thread

2021-09-26 Thread STINNER Victor


STINNER Victor  added the comment:

Storing the result of Thread.run() can keep Python objects alive longer than 
expected and it may require a lock on it. I don't think that the additional 
complexity is worth it. I suggest to reorganize your code to pass the result 
differently to the caller thread. You can use a queue, a variable, whatever 
works.

--
nosy: +vstinner
resolution:  -> wont fix
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



[issue27978] concurrent.futures.threading: Add a timeout to Executor shutdown() method

2021-09-26 Thread STINNER Victor


Change by STINNER Victor :


--
title: [threading] Executor#shutdown with timeout -> 
concurrent.futures.threading: Add a timeout to Executor shutdown() method

___
Python tracker 

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



[issue1736792] dict reentrant/threading request

2021-09-26 Thread STINNER Victor


STINNER Victor  added the comment:

> As I first mentioned in my post[1] on comp.lang.python, it seems possible to 
> modify a dict while a lookup is ongoing, without causing the lookup to 
> restart.

That's a bad practice. Python dict raises an exception in some cases: 
RuntimeError("dict mutated during update").

Detecting any change during a lookup would slow down, whereas dict performance 
is key in Python performance in general, since dict is used everywhere for 
Python namespaces.

I close the issue as "wont fix".

--
nosy: +vstinner
resolution:  -> wont fix
stage: test needed -> 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



[issue45292] Implement PEP 654: Exception Groups

2021-09-26 Thread STINNER Victor


Change by STINNER Victor :


--
title: Implement PEP 654 -> Implement PEP 654: Exception Groups

___
Python tracker 

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



[issue45261] Unreliable (?) results from timeit (cache issue?)

2021-09-26 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Given that there isn't an actual bug here, please move this discussion to 
python-ideas.

--
nosy: +rhettinger
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



[issue45293] List inplace addition different from normal addition

2021-09-26 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Kapil, this behavior was intentional (not a bug), but later regarded as a 
design mistake.  GvR has said that if he had to do it over again list.__iadd__ 
would only accept other lists.  The problem arises when people write "somelist 
+= 'hello'" and expect it to add a single string with one word rather than five 
one letter strings.  That said, the current behavior is guaranteed, people rely 
on it, and we cannot change it.

As Karthikeyan points out, this is documented.  However since the docs have 
grown so voluminous, it is often difficult to find any one particular fact.

--
nosy: +rhettinger
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



[issue45296] IDLE: Change Ctrl-Z note in exit/quit repr on Windows

2021-09-26 Thread Terry J. Reedy


New submission from Terry J. Reedy :

On Windows:
>>> exit
'Use exit() or Ctrl-Z plus Return to exit'
>>> quit
'Use quit() or Ctrl-Z plus Return to exit'
>>> exit.eof
'Ctrl-Z plus Return'

On *nix, 'Ctrl-Z plus Return' is 'Ctrl-D (i.e, EOF)'
IDLE uses the latter even on Windows, and Ctrl-Z does not work.

Both exit and quit are instances of _sitebuiltins.Quitter
https://github.com/python/cpython/blob/e14d5ae5447ae28fc4828a9cee8e9007f9c30700/Lib/_sitebuiltins.py#L13-L26
class Quitter(object):
def __init__(self, name, eof):
self.name = name
self.eof = eof
def __repr__(self):
return 'Use %s() or %s to exit' % (self.name, self.eof)
def __call__ [not relevant here]

We just need to replace current exit/quit.eof as indicated above on startup.

--
messages: 402678
nosy: terry.reedy
priority: normal
severity: normal
status: open
title: IDLE: Change Ctrl-Z note in exit/quit repr on Windows

___
Python tracker 

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



[issue44958] [sqlite3] only reset statements when needed

2021-09-26 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
pull_requests: +26956
pull_request: https://github.com/python/cpython/pull/28574

___
Python tracker 

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



[issue44958] [sqlite3] only reset statements when needed

2021-09-26 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

I'll revert PR 27844 for now (except the tests).

Since SQLite works better when we keep the number of non-reset statements to a 
minimum, we need to ensure that we reset statements when we're done with them 
(sqlite3_step() returns SQLITE_DONE or an error). Before doing such a change, 
we should clean up _pysqlite_query_execute() so we don't need to sprinkle that 
function with pysqlite_statement_reset's. I plan to do this before attempting 
to clean up reset usage again.

--

___
Python tracker 

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



[issue45113] [subinterpreters][C API] Add a new function to create PyStructSequence from Heap.

2021-09-26 Thread Hai Shi


Change by Hai Shi :


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

___
Python tracker 

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



[issue45288] Inspect - Added sort_result parameter on getmembers function.

2021-09-26 Thread Cristobal Riaga


Cristobal Riaga  added the comment:

So there is no way to get members in the order you defined them?

--

___
Python tracker 

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



[issue45288] Inspect - Added sort_result parameter on getmembers function.

2021-09-26 Thread Cristobal Riaga


Cristobal Riaga  added the comment:

So there is no way to get the members in order?

--

___
Python tracker 

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



[issue45280] Empty typing.NamedTuple creation is not tested

2021-09-26 Thread Łukasz Langa

Łukasz Langa  added the comment:

Thanks, Nikita! ✨  ✨

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



[issue45280] Empty typing.NamedTuple creation is not tested

2021-09-26 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset d452b2963ba91d6bce29bb96733ed8bd1c0448b0 by Miss Islington (bot) 
in branch '3.10':
bpo-45280: Add test for empty `NamedTuple` in `test_typing` (GH-28559) 
(GH-28571)
https://github.com/python/cpython/commit/d452b2963ba91d6bce29bb96733ed8bd1c0448b0


--

___
Python tracker 

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



[issue45280] Empty typing.NamedTuple creation is not tested

2021-09-26 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 08e387ab82331230d7f6608e949723d8a8e09229 by Miss Islington (bot) 
in branch '3.9':
bpo-45280: Add test for empty `NamedTuple` in `test_typing` (GH-28559) 
(GH-28570)
https://github.com/python/cpython/commit/08e387ab82331230d7f6608e949723d8a8e09229


--

___
Python tracker 

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



[issue45283] Top / function argument level ClassVar should not be allowed during `get_type_hints()`

2021-09-26 Thread Łukasz Langa

Łukasz Langa  added the comment:

> Is it an official position?

No, we need to decide what will happen to PEP 563 and PEP 649 in Python 3.11.

--
nosy: +lukasz.langa

___
Python tracker 

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



[issue45249] Update doctect SyntaxErrors for location range

2021-09-26 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

One important thing is that "traceback.print_exception" should correctly print 
syntax errors .

--

___
Python tracker 

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



[issue45280] Empty typing.NamedTuple creation is not tested

2021-09-26 Thread miss-islington


Change by miss-islington :


--
pull_requests: +26954
pull_request: https://github.com/python/cpython/pull/28571

___
Python tracker 

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



[issue45280] Empty typing.NamedTuple creation is not tested

2021-09-26 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue45280] Empty typing.NamedTuple creation is not tested

2021-09-26 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset f56268a2cd38b3fe2be1e4361d3d8b581e73559b by Nikita Sobolev in 
branch 'main':
bpo-45280: Add test for empty `NamedTuple` in `test_typing` (GH-28559)
https://github.com/python/cpython/commit/f56268a2cd38b3fe2be1e4361d3d8b581e73559b


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue45295] _PyObject_GetMethod/LOAD_METHOD for C classmethods

2021-09-26 Thread Ken Jin


New submission from Ken Jin :

LOAD_METHOD + CALL_METHOD currently doesn't work for Python @classmethod and C 
classmethod (METH_CLASS). They still create bound classmethods which are fairly 
expensive.

I propose supporting classmethods. I have an implementation for C classmethods. 
It passes most of the test suite, and I've also got it to play along with PEP 
659 specialization.

Some numbers from Windows release build (PGO build will likely be less 
favorable):

python.exe -m timeit "int.from_bytes(b'')"
Main:
200 loops, best of 5: 107 nsec per loop
Patched:
500 loops, best of 5: 72.4 nsec per loop

Funnily enough, `(1).from_bytes()` still needs a bound classmethod, but I think 
people usually use the other form.

A toy PR will be up for review. I will then split the change into two parts 
(one for _PyObject_GetMethod changes, another for PEP 659 specialization) to 
help decide if the maintenance-perf ratio is worth it.

--
components: Interpreter Core
messages: 402668
nosy: kj
priority: normal
severity: normal
status: open
title: _PyObject_GetMethod/LOAD_METHOD for C classmethods
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



[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-09-26 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

> That is true, but there are a couple setups where that doesn't work 
> (those keypresses are consumed by something else). I may not be a good 
> data point though.

Can you give an example of a setup where Ctrl-D is consumed but "import 
sys ENTER sys.exit() ENTER" is not?

--

___
Python tracker 

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



[issue45294] Conditional import fails and produce UnboundLocalError, if a variable machting import name is used before

2021-09-26 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

In the future, please remember that this is not a help desk for getting help 
with your code, it is for reporting bugs. There are many forums that are happy 
to help you understand why your code is not working as you expect (if you are a 
beginner to Python, the answer is *almost never* "a bug in Python").

You can find help at Reddit's r/learnpython, or at the forums and mailing lists 
here:

https://www.python.org/community/forums/

https://www.python.org/community/lists/

--

___
Python tracker 

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



[issue45294] Conditional import fails and produce UnboundLocalError, if a variable machting import name is used before

2021-09-26 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

This is not a bug, you are trying to print the value of the local variable 
DiaObjectFactoryHelper before you have defined the variable.

UnboundLocalError is a subclass of NameError that is used when the undefined 
name is a local variable instead of a global.

--
nosy: +steven.daprano
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



[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-09-26 Thread Filipe Laíns

Filipe Laíns  added the comment:

> Without disagreeing with the general sentiment, just note that you can always 
> do Ctrl-D.

That is true, but there are a couple setups where that doesn't work (those 
keypresses are consumed by something else). I may not be a good data point 
though.

> Running the REPL with -S is unusual, so having to use sys.exit() or `raise 
> SystemExit` in that case shouldn't be an issue. 

Yes, it is unusual, however I have found myself asking people to do that when 
debugging, and I always have to tell people "oh, btw, exit() doesn't work, you 
have to do ...", which is not nice.

> Even if you are running the REPL without the site module (so that exit 
and quit are not available) the import sys solution is surely the worst 
of the lot, UX-wise.

Two of the solutions you gave (exit and quit) don't work with -S, and 
Ctrl-D/Ctrl-Z doesn't work in all setups. raise SystemExit is the only real 
alternative I would consider when I am explaining things to people and want to 
avoid issues. I standardized in `import sys; sys.exit()` as it's generally 
easier for people starting out, even though it's 5 more keypresses.

---

Anyway, my point is simply that exiting on python -S does not have a great UX, 
something that I think should be considered when looking at this proposal. If 
you think the use-case is relevant enough to not warrant a change like this, 
that is a valid opinion.

My personal opinion is that we should optimize the UX for the people who are 
not that knowledgeable, as those are the ones that will have most trouble, 
while keeping it usable for the rest of users.
I think this change is a net positive considering those parameters, and I think 
the arguments against this proposal have not properly taken them into account.

FWIW, I consider myself a reasonably knowledgeable user, but still end up 
making this mistake myself a staggering amount of times.

$ rg 'exit\(\)$' ~/.python_history | wc -l
553
$ rg 'exit$' ~/.python_history | wc -l
132

--

___
Python tracker 

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



[issue45294] Conditional import fails and produce UnboundLocalError, if a variable machting import name is used before

2021-09-26 Thread arts stars


New submission from arts stars :

Hello,

I have this situation:

def test():

if True :
print("Exception"+DiaObjectFactoryHelper)
else:
from . import DiaObjectFactoryHelper
pass

test()
---
it generates instead of (like the the line 'from . import' is commented) : 
"NameError: name 'DiaObjectFactoryHelper' is not defined"
this:
UnboundLocalError: local variable 'DiaObjectFactoryHelper' referenced before 
assignment


PS: The github authentificatiion did not work, did not manage to grab email 
even if set public

--
messages: 402663
nosy: stars-of-stras
priority: normal
severity: normal
status: open
title: Conditional import fails and produce UnboundLocalError, if a variable 
machting import name is used before
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



[issue45249] Update doctect SyntaxErrors for location range

2021-09-26 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

Terry: please take a look - https://github.com/python/cpython/pull/28567/files .

--

___
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

2021-09-26 Thread Irit Katriel


New submission from Irit Katriel :

We will implement Exception Groups and except* in a series of PRs:

1. Add the ExceptionGroup and BaseExceptionGroup classes
2. Update traceback rendering code (python and C) for exception groups.
3. Implement except*
4. Write documentation sections.

--

___
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

2021-09-26 Thread Irit Katriel


Change by Irit Katriel :


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

___
Python tracker 

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



[issue45249] Update doctect SyntaxErrors for location range

2021-09-26 Thread Andrei Kulakov


Change by Andrei Kulakov :


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

___
Python tracker 

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



[issue45293] List inplace addition different from normal addition

2021-09-26 Thread Karthikeyan Singaravelan

Karthikeyan Singaravelan  added the comment:

https://docs.python.org/3/faq/programming.html#faq-augmented-assignment-tuple-error

> for lists, __iadd__ is equivalent to calling extend on the list and returning 
> the list. That’s why we say that for lists, += is a “shorthand” for 
> list.extend

This example is calling extend on list of strings with another string as 
argument. Hence the target string is iterated and each character is added as an 
element. __add__ is different compared __iadd__. For += __iadd__ is called if 
defined and falls back to __add__

--
nosy: +xtreak

___
Python tracker 

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



[issue45293] List inplace addition different from normal addition

2021-09-26 Thread Eric V. Smith


Eric V. Smith  added the comment:

For those not in front of a computer, the error is:

>>> l = l + 'de'
Traceback (most recent call last):
  File "", line 1, in 
TypeError: can only concatenate list (not "str") to list

--
nosy: +eric.smith

___
Python tracker 

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



[issue45293] List inplace addition different from normal addition

2021-09-26 Thread Kapil Bansal


New submission from Kapil Bansal :

Hi,

I tried addition and in-place addition on a list.

>>> l = ['a', 'b', 'c']

>>> l = l + 'de' (raises an error)

>>> l += 'de'
>>> print(l)
['a', 'b' , 'c', 'd', 'e']

I want to ask why the behaviour of both these are different?? If it is done 
intentionally, then it should be there in the documentation but I am not able 
to find any reference.

--
messages: 402658
nosy: KapilBansal320
priority: normal
severity: normal
status: open
title: List inplace addition different from normal addition
type: behavior
versions: 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



[issue45292] Implement PEP 654

2021-09-26 Thread Irit Katriel


Change by Irit Katriel :


--
assignee: iritkatriel
components: Documentation, Interpreter Core, Library (Lib)
nosy: iritkatriel
priority: normal
severity: normal
status: open
title: Implement PEP 654
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



[issue45291] Some instructions in the "Using Python on Unix platforms" document do no work on CentOS 7

2021-09-26 Thread Yiyang Zhan


Change by Yiyang Zhan :


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

___
Python tracker 

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



[issue45291] Some instructions in the "Using Python on Unix platforms" document do no work on CentOS 7

2021-09-26 Thread Yiyang Zhan


New submission from Yiyang Zhan :

The instructions in "Custom OpenSSL" section of "Using Python on Unix 
platforms" do not work on CentOS 7: 
https://github.com/python/cpython/blob/v3.10.0rc2/Doc/using/unix.rst#custom-openssl.

CPython's ./configure script assumes the OpenSSL's library resides in 
"$ssldir/lib". This isn't guaranteed with the current instruction, because 
OpenSSL might create for example lib64 for the .so files. See 
https://github.com/openssl/openssl/blob/openssl-3.0.0/INSTALL.md#libdir:

> Some build targets have a multilib postfix set in the build configuration. 
> For these targets the default libdir is lib. Please use 
> --libdir=lib to override the libdir if adding the postfix is undesirable.

Therefore it's better to explicitly set --libdir=lib.

--
assignee: docs@python
components: Documentation
messages: 402657
nosy: docs@python, zhanpon
priority: normal
severity: normal
status: open
title: Some instructions in the "Using Python on Unix platforms" document do no 
work on CentOS 7
type: enhancement
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



[issue41271] Add support for io_uring to cpython

2021-09-26 Thread Dima Tisnek


Dima Tisnek  added the comment:

Would now, a year later, be a good time to consider io_uring?

--
nosy: +Dima.Tisnek

___
Python tracker 

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