[issue42852] pprint fails in transformming non-breaking space

2021-01-06 Thread Xinmeng Xia


New submission from Xinmeng Xia :

"pprint" can transform unicode like "print". However, pprint fails to transform 
non-breaking space('\240') . See the following example:

Python 3.10.0a2 (default, Nov 24 2020, 14:18:46) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

Example 1(Results as expected):
-
>>> import pprint
>>> print(u'\041 hello')
! hello
>>> pprint.pprint(u'\041 hello')
'! hello'

Example 2(Results not as expected):
-
>>> print(u'\240 hello')
  hello
>>> pprint.pprint(u'\240 hello')
'\xa0 hello'

Expected output: the output of pprint.pprint(u'\240 hello') should be 
consistent with output of print(u'\240 hello')

--
components: Unicode
messages: 384564
nosy: ezio.melotti, vstinner, xxm
priority: normal
severity: normal
status: open
title: pprint fails in transformming non-breaking space
type: behavior
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



[issue42851] Subclassing Enum with ipaddress.IPv4Network/IPv6Network raises TypeError.

2021-01-06 Thread Mariusz Felisiak


New submission from Mariusz Felisiak :

We noticed a behavior change in Python3.10.0a4 (it works properly in 
Python3.10.0a3) when running Django's test suite[1]. Subclassing `enum.Enum` 
with `ipaddress.IPv4Network/IPv6Network` raises `TypeError`, e.g.

>>> import enum
>>> import ipaddress
>>> class NewEnum(ipaddress.IPv4Address, enum.Enum):
... pass
... 
>>> class NewEnum(ipaddress.IPv4Network, enum.Enum):
... pass
... 
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python3.10/enum.py", line 239, in __new__
enum_class.__bases__ = enum_class.__bases__[1:] #or (object, )
  File "/usr/local/lib/python3.10/enum.py", line 483, in __setattr__
super().__setattr__(name, value)
TypeError: __bases__ assignment: 'IPv4Network' object layout differs from 
'_NoInitSubclass'

It still works for `ipaddress.IPv4Address/IPv6Address`.

[1] 
https://github.com/django/django/blob/102d92fc09849e1a9004dd3f9a14a0ea9ca392cd/tests/model_enums/tests.py#L225-L235

--
components: Library (Lib)
messages: 384563
nosy: barry, eli.bendersky, ethan.furman, felixxm
priority: normal
severity: normal
status: open
title: Subclassing Enum with ipaddress.IPv4Network/IPv6Network raises TypeError.
type: crash
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



[issue42850] Process hangs when calling urllib.request in a multiprocessing.Process with import of sounddevice package

2021-01-06 Thread Robin Scheibler


New submission from Robin Scheibler :

I am having an issue with using urllib in a multiprocessing.Process when the 
package sounddevice (https://github.com/spatialaudio/python-sounddevice) has 
been already imported.

The sub-process hangs upon calling urllib.request.urlopen (and methods from the 
requests package too).

1. If the package sounddevice is not imported, things work as expected.
2. If the package sounddevice is imported, but urllib.request.urlopen is called 
once prior to launching thee sub-process, then things also work as expected.

I have attached a file containing code to reproduce the issue.

I have run this example file in:
- Python 3.7.9 (conda distribution)
- Mac OS X 10.15.7

# Running the code as is reproduces the problem
> python ./test_mp_req.py
Nothing in the queue. Leave.
wait for process to terminate...
finished

# Running the code with either line 8 commented *or* line 32 uncommented
# gives the expected output
> python ./test_mp_req.py
Received https://api.github.com. Send GET request... done.
Received https://www.google.com. Send GET request... done.
https://api.github.com: ok
https://www.google.com: ok
Nothing in the queue. Leave.
wait for process to terminate...
finished

--
components: Interpreter Core, Library (Lib), ctypes
files: test_mp_req.py
messages: 384562
nosy: fakufaku
priority: normal
severity: normal
status: open
title: Process hangs when calling urllib.request in a multiprocessing.Process 
with import of sounddevice package
type: crash
versions: Python 3.7
Added file: https://bugs.python.org/file49724/test_mp_req.py

___
Python tracker 

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



[issue19683] test_minidom has many empty tests

2021-01-06 Thread karl


karl  added the comment:

@zach.ware 
@r.david.murray

I'm going through the source currently. 

I see that the test file is using:

class MinidomTest(unittest.TestCase):
def confirm(self, test, testname = "Test"):
self.assertTrue(test, testname)


Is there a specific reason to use this form instead of just directly using 
self.assertEqual or similar forms for new tests or reorganizing some of the 
tests. 


I see that it is used for example for giving a testname but

def testAAA(self):
dom = parseString("")
el = dom.documentElement
el.setAttribute("spam", "jam2")
self.confirm(el.toxml() == '', "testAAA")


testAAA is not specifically helping. :)

--

___
Python tracker 

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



[issue42849] pool worker can't be terminated

2021-01-06 Thread Zhesi Huang


New submission from Zhesi Huang :

i see a case, the worker proc of pool can't be terminated, i try kill -SIGTERM 
or -SIGINT, but it still can't terminated the worker proc, then the pool 
__exit__ will hang forever

```
class NonDaemonProcess(multiprocessing.Process):
# 
https://stackoverflow.com/questions/6974695/python-process-pool-non-daemonic

# make 'daemon' attribute always return False
def _get_daemon(self):
return False

def _set_daemon(self, value):
pass

daemon = property(_get_daemon, _set_daemon)


def wrapper_copy_parallel(output_name, local_output_path, obs_path):
log_thread('upload the content of [%s] outputs' % output_name)
try:
if os.path.exists(local_output_path):
log_thread('%s has %d files to be uploaded' % (output_name, 
len(file_list)))

xx

log_thread('upload the content of [%s] outputs successfully' % 
output_name)
log_thread('it can be accessed at obs path [%s]' % obs_path)
else:
log_thread('local output path is not found, skip upload the content 
of [%s] outputs' % output_name)
except Exception as upload_exception:
err_thread('upload the content of [%s] outputs failed: %s' % 
(output_name, str(upload_exception)))
return 255

return 0


def upload_to_s3():
"""
upload the content of local path to s3, handle action [on_completed]
:return:
"""
outputs = []
for local_output_path, (output_name, obs_path, action, _, _) in 
local_to_target.items():
if action == ACTION_ON_COMPLETED:
outputs.append((output_name, local_output_path, obs_path))

if len(outputs) == 0:
return 0

with NonDaemonPool(processes=len(outputs)) as pool:
results = pool.starmap(wrapper_copy_parallel, outputs)

for result in results:
if result != 0:
return result

return 0
```

stdout/stderr log

[ma-test Service Log][INFO][2021/01/05 03:07:49,218]: registered signal handler
[ma-test Service Log][INFO][2021/01/05 03:09:40,299]: output-handler finalizing
[ma-test Service Log][INFO][2021-01-05 03:09:40,309][NonDaemonPoolWorker-1]: 
child process calling self.run()
[ma-test Service Log][INFO][2021-01-05 03:09:40,311][NonDaemonPoolWorker-1]: 
upload the content of [] outputs
[ma-test Service Log][INFO][2021-01-05 03:09:41,331][Process-1:1]: child 
process calling self.run()
[ma-test Service Log][INFO][2021-01-05 03:09:41,333][Process-1:2]: child 
process calling self.run()
[ma-test Service Log][INFO][2021-01-05 03:09:41,338][Process-1:3]: child 
process calling self.run()
[ma-test Service Log][INFO][2021-01-05 03:09:41,351][Process-1:1]: process 
shutting down
[ma-test Service Log][INFO][2021-01-05 03:09:41,351][Process-1:1]: process 
exiting with exitcode 0
[ma-test Service Log][INFO][2021-01-05 03:09:41,386][Process-1:2]: process 
shutting down
[ma-test Service Log][INFO][2021-01-05 03:09:41,386][Process-1:2]: process 
exiting with exitcode 0
[ma-test Service Log][INFO][2021-01-05 03:09:41,410][Process-1:3]: process 
shutting down
[ma-test Service Log][INFO][2021-01-05 03:09:41,410][Process-1:3]: process 
exiting with exitcode 0
[ma-test Service Log][INFO][2021-01-05 03:09:41,415][NonDaemonPoolWorker-1]: 
upload the content of [] outputs successfully
[ma-test Service Log][INFO][2021-01-05 03:09:41,415][NonDaemonPoolWorker-1]: it 
can be accessed at obs path 
[s3://ma-test-algorancher-intel/model_evaluation/6e5746ff-2839-400a-ba93-df38311415f4/dac957b0-b43b-43e2-ab19-0b45672a7ea0/]

18 (pid) proc python stacktrace

>>>
Interrupting process at following point:
  File "/home/ma-user/runtime-scripts-v2/init-container/outputs-handler.py", 
line 396, in 
ret_code = upload_to_obs()
  File "/home/ma-user/runtime-scripts-v2/init-container/outputs-handler.py", 
line 287, in upload_to_obs
results = pool.starmap(wrapper_copy_parallel, outputs)
  File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/pool.py", line 
623, in __exit__
self.terminate()
  File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/pool.py", line 
548, in terminate
self._terminate()
  File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/util.py", line 
201, in __call__
res = self._callback(*self._args, **self._kwargs)
  File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/pool.py", line 
617, in _terminate_pool
p.join()
  File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/process.py", 
line 140, in join
res = self._popen.wait(timeout)
  File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/popen_fork.py", 
line 48, in wait
return self.poll(os.WNOHANG if timeout == 0.0 else 0)
  File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/popen_fork.py", 
line 28, in poll
pid, sts = os.waitpid(self.pid, flag)

18 (pid) proc gdb bt

#0  0x7f15c2c5ff7b in waitpid () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  

[issue42848] asyncio produces an unexpected traceback with recursive __getattribute__

2021-01-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

I meant Irit. Silly autocorrect.

--

___
Python tracker 

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



[issue42848] asyncio produces an unexpected traceback with recursive __getattribute__

2021-01-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

No problem. Riot, are you interested in this?

--
nosy: +Guido.van.Rossum, iritkatriel

___
Python tracker 

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



[issue42848] asyncio produces an unexpected traceback with recursive __getattribute__

2021-01-06 Thread asleep-cult


asleep-cult  added the comment:

I'm not sure I have a deep enough understanding of how this works, so no

--

___
Python tracker 

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



[issue42848] asyncio produces an unexpected traceback with recursive __getattribute__

2021-01-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

The recursion error is actually inside the traceback module. The reason is that 
the code there calls itself recursively for each level of context. Since bar() 
builds up an endless chain of contexts as it calls itself recursively, that 
chain is very long.

Given that, do you feel comfortable trying to come up with a fix and submit a 
PR?

--

___
Python tracker 

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



[issue42848] asyncio produces an unexpected traceback with recursive __getattribute__

2021-01-06 Thread asleep-cult


asleep-cult  added the comment:

Didn't show enough of the traceback to show that the latter does not suppress 
the Test exception

Traceback (most recent call last):
  File "c:/Development/test/test.py", line 11, in bar
x()
  File "c:/Development/test/test.py", line 7, in x
raise Test('Hello World!')
__main__.Test: Hello World!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:/Development/test/test.py", line 19, in 
bar()
  File "c:/Development/test/test.py", line 14, in bar
bar()
  File "c:/Development/test/test.py", line 14, in bar
bar()
  File "c:/Development/test/test.py", line 14, in bar
bar()
  [Previous line repeated 994 more times]
  File "c:/Development/test/test.py", line 11, in bar
x()
  File "c:/Development/test/test.py", line 7, in x
raise Test('Hello World!')
RecursionError: maximum recursion depth exceeded while calling a Python object

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:/Development/test/test.py", line 21, in 
traceback.print_exc()
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 163, in print_exc
print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 103, in print_exception
for line in TracebackException(
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 493, in __init__
context = TracebackException(
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 493, in __init__
context = TracebackException(
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 493, in __init__
context = TracebackException(
  [Previous line repeated 495 more times]
RecursionError: maximum recursion depth exceeded

--

___
Python tracker 

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



[issue42848] asyncio produces an unexpected traceback with recursive __getattribute__

2021-01-06 Thread asleep-cult


asleep-cult  added the comment:

I did test it with a simple recursive function but a more realistic test 
confirms that its not just __getattribute__ (which makes sense)

import asyncio

class Test(Exception):
...

def x():
raise Test('Hello World!')

def bar():
try:
x()
except Test as e:
try:
bar()
except Test as e:
raise e

async def foo():
bar()

loop = asyncio.get_event_loop()
loop.create_task(foo())
loop.run_forever()

Traceback:

Exception in default exception handler
Traceback (most recent call last):
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py",
 line 1733, in call_exception_handlerself.default_exception_handler(context)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py",
 line 1707, in default_exception_handler
logger.error('\n'.join(log_lines), exc_info=exc_info)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", 
line 1471, in error
self._log(ERROR, msg, args, **kwargs)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", 
line 1585, in _log
self.handle(record)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", 
line 1595, in handle
self.callHandlers(record)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", 
line 1665, in callHandlers
lastResort.handle(record)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", 
line 950, in handle
self.emit(record)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", 
line 1081, in emit
msg = self.format(record)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", 
line 925, in format
return fmt.format(record)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", 
line 672, in format
record.exc_text = self.formatException(record.exc_info)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", 
line 622, in formatException
traceback.print_exception(ei[0], ei[1], tb, None, sio)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 103, in print_exception
for line in TracebackException(
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 493, in __init__
context = TracebackException(
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 493, in __init__
context = TracebackException(
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 493, in __init__
context = TracebackException(
  [Previous line repeated 488 more times]
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 476, in __init__
_seen.add(id(exc_value))
RecursionError: maximum recursion depth exceeded while calling a Python object

The Test('Hello World') exception is suppressed entirely

try:
bar()
except:
traceback.print_exc()

but when running it this way the traceback looks like this:

File "c:/Development/test/test.py", line 7, in x
raise Test('Hello World!')
RecursionError: maximum recursion depth exceeded while calling a Python object

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:/Development/test/test.py", line 21, in 
traceback.print_exc()
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 163, in print_exc
print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 103, in print_exception
for line in TracebackException(
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 493, in __init__
context = TracebackException(
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 493, in __init__
context = TracebackException(
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 493, in __init__
context = TracebackException(
  [Previous line repeated 495 more times]
RecursionError: maximum recursion depth exceeded

--

___
Python tracker 

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



[issue42848] asyncio produces an unexpected traceback with recursive __getattribute__

2021-01-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

Is there anything specific about __getattribute__ here? Wouldn't you have the 
same issue for *any* function that raises RecursionError called inside an async 
def?

--
nosy: +gvanrossum

___
Python tracker 

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



[issue42783] asyncio.sleep(0) idiom is not documented

2021-01-06 Thread Nick Coghlan


Nick Coghlan  added the comment:

I merged the update to the 3.10 docs, but the automated backport to 3.9 to 
update the online docs failed.

--
resolution:  -> fixed
stage: patch review -> backport needed
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



[issue42848] asyncio produces an unexpected traceback with recursive __getattribute__

2021-01-06 Thread asleep-cult


New submission from asleep-cult :

The code below produces an unexpected traceback format that makes the source of 
an error very hard to find, this more than likely happens in less specific 
situations but this is how I came across it. I'm also not sure if this is an 
issue with asyncio, logging or the traceback module.


import asyncio

class Bar:
def __init__(self):
self.y = None

class Foo:
def __init__(self):
self._bar = Bar()
self.y

def __getattribute__(self, name):
try:
attr = super().__getattribute__(name)
except AttributeError as e:
try:
attr = self.ooops_spelled_bar_wrong.__getattribute__(name)
except AttributeError:
raise e
return attr

async def foo():
Foo()

loop = asyncio.get_event_loop()
loop.create_task(foo())
loop.run_forever()


Traceback:


Exception in default exception handler
Traceback (most recent call last):
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py",
 line 1733, in call_exception_handlerself.default_exception_handler(context)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py",
 line 1707, in default_exception_handler
logger.error('\n'.join(log_lines), exc_info=exc_info)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", 
line 1471, in error
self._log(ERROR, msg, args, **kwargs)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", 
line 1585, in _log
self.handle(record)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", 
line 1595, in handle
self.callHandlers(record)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", 
line 1665, in callHandlers
lastResort.handle(record)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", 
line 950, in handle
self.emit(record)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", 
line 1081, in emit
msg = self.format(record)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", 
line 925, in format
return fmt.format(record)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", 
line 672, in format
record.exc_text = self.formatException(record.exc_info)
  File 
"C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", 
line 622, in formatException
traceback.print_exception(ei[0], ei[1], tb, None, sio)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 103, in print_exception
for line in TracebackException(
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 493, in __init__
context = TracebackException(
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 493, in __init__
context = TracebackException(
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 493, in __init__
context = TracebackException(
  [Previous line repeated 488 more times]
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", 
line 476, in __init__
_seen.add(id(exc_value))
RecursionError: maximum recursion depth exceeded while calling a Python object
``` 

The code below procures the expected traceback

 
import traceback

class Bar:
def __init__(self):
self.y = None

class Foo:
def __init__(self):
self._bar = Bar()
self.y

def __getattribute__(self, name):
try:
attr = super().__getattribute__(name)
except AttributeError as e:
try:
attr = self.ooops_spelled_bar_wrong.__getattribute__(name)
except AttributeError:
raise e
return attr

try:
Foo()
except:
traceback.print_exc()


Traceback:


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:/Development/test/test.py", line 15, in __getattribute__
attr = super().__getattribute__(name)
AttributeError: 'Foo' object has no attribute 'ooops_spelled_bar_wrong'

# The part above is repeated hundreds of times

Traceback (most recent call last):
  File "c:/Development/test/test.py", line 24, in 
Foo()
  File "c:/Development/test/test.py", line 11, in __init__
self.y
  File "c:/Development/test/test.py", line 18, in __getattribute__
attr = self.ooops_spelled_bar_wrong.__getattribute__(name)
  File "c:/Development/test/test.py", line 18, in __getattribute__
attr = self.ooops_spelled_bar_wrong.__getattribute__(name)
  File "c:/Development/test/test.py", line 18, in __getattribute__
attr = self.ooops_spelled_bar_wrong.__getattribute__(name)
  [Previous line repeated 992 more times]
  File 

[issue42783] asyncio.sleep(0) idiom is not documented

2021-01-06 Thread Nick Coghlan


Nick Coghlan  added the comment:


New changeset 5c30145afb6053998e3518befff638d207047f00 by Simon Willison in 
branch 'master':
bpo-42783: Documentation for asyncio.sleep(0) (#24002)
https://github.com/python/cpython/commit/5c30145afb6053998e3518befff638d207047f00


--
nosy: +ncoghlan

___
Python tracker 

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



[issue10572] Move test sub-packages to Lib/test

2021-01-06 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
pull_requests: +22976
pull_request: https://github.com/python/cpython/pull/24148

___
Python tracker 

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



[issue42847] Normalise file encodings in Lib/sqlite3/test/

2021-01-06 Thread Berker Peksag


Berker Peksag  added the comment:

iso-8859-1 is still commonly used in some parts of Nordic countries, but I 
don't see a reason not to change it here :) Thank you, Erlend!

--
components: +Tests -Library (Lib)
type:  -> enhancement

___
Python tracker 

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



[issue42847] Normalise file encodings in Lib/sqlite3/test/

2021-01-06 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg 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



[issue42847] Normalise file encodings in Lib/sqlite3/test/

2021-01-06 Thread Berker Peksag


Berker Peksag  added the comment:


New changeset deab1e54ff1695cdbe87f8db3d2c382d8e78330f by Erlend Egeberg 
Aasland in branch 'master':
bpo-42847: Normalise Lib/sqlite3/test/* file encodings (GH-24147)
https://github.com/python/cpython/commit/deab1e54ff1695cdbe87f8db3d2c382d8e78330f


--

___
Python tracker 

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



[issue42847] Normalise file encodings in Lib/sqlite3/test/

2021-01-06 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


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

___
Python tracker 

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



[issue40823] Don't use obsolete unittest.makeSuite() in sqlite3 tests

2021-01-06 Thread Berker Peksag


Berker Peksag  added the comment:

Thank you!

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



[issue40823] Don't use obsolete unittest.makeSuite() in sqlite3 tests

2021-01-06 Thread Berker Peksag


Berker Peksag  added the comment:


New changeset 849e339a925fb398be31e566c31b99ce6cdb6006 by Erlend Egeberg 
Aasland in branch 'master':
bpo-40823: Use loadTestsFromTestCase() iso. makeSuite() in sqlite3 tests 
(GH-20538)
https://github.com/python/cpython/commit/849e339a925fb398be31e566c31b99ce6cdb6006


--

___
Python tracker 

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



[issue42847] Normalise file encodings in Lib/sqlite3/test/

2021-01-06 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Indeed it is. I'll create a PR as soon as GH-20538 is merged.

--

___
Python tracker 

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



[issue42847] Normalise file encodings in Lib/sqlite3/test/

2021-01-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

SGTM, the use of ISO-8859 is surely a legacy issue.

--
nosy: +gvanrossum

___
Python tracker 

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



[issue42847] Normalise file encodings in Lib/sqlite3/test/

2021-01-06 Thread Erlend Egeberg Aasland


New submission from Erlend Egeberg Aasland :

GitHub does not play well with other file encodings than UTF-8. For example, 
when the "suggestion" in 
https://github.com/python/cpython/pull/20538#discussion_r552926126 was applied, 
GitHub silently converted Lib/sqlite3/test/types.py from ISO-8859 to UTF-8, as 
seen in the resulting commit fd4f65141925f2d84e0efd17ca4b9395c171d7ba. Apart 
from being annoying, this created an inconsistency between the `#-*- coding: 
iso-8859-1 -*-` header in Lib/sqlite3/test/types.py and its actual encoding 
(now UTF-8).

I suggest to convert Lib/sqlite3/test/* to UTF-8 encoding for consistency.

$ file Lib/sqlite3/test/*.py
Lib/sqlite3/test/backup.py:Python script text executable, ASCII text
Lib/sqlite3/test/dbapi.py: Python script text executable, ISO-8859 text
Lib/sqlite3/test/dump.py:  Python script text executable, ASCII text
Lib/sqlite3/test/factory.py:   Python script text executable, ISO-8859 text
Lib/sqlite3/test/hooks.py: Python script text executable, ISO-8859 text
Lib/sqlite3/test/regression.py:Python script text executable, ISO-8859 text
Lib/sqlite3/test/transactions.py:  Python script text executable, ISO-8859 text
Lib/sqlite3/test/types.py: Python script text executable, ISO-8859 text
Lib/sqlite3/test/userfunctions.py: Python script text executable, UTF-8 Unicode 
text

--
components: Library (Lib)
messages: 384543
nosy: berker.peksag, erlendaasland
priority: normal
severity: normal
status: open
title: Normalise file encodings in Lib/sqlite3/test/
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



[issue42179] Clarify chaining exceptions in tutorial/errors.rst

2021-01-06 Thread Vladimir Ryabtsev


Vladimir Ryabtsev  added the comment:

The issue won't be fixed, but other useful changes applied.

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



[issue42846] Using _multibytecodec module on Windows, test_threading/embed get failure

2021-01-06 Thread neonene


New submission from neonene :

After 
https://github.com/python/cpython/commit/0b858cdd5d114f0890b11b6c4d6559d0ceb468ab
(bpo-1635741: Convert _multibytecodec to multi-phase init),

On Windows x64/x86 with chinese/japanese/korean system-locale,
MultibyteCodec_Check() in multibytecodec.c returns false and
PyExc_TypeError follows. This affects some tests and PGO training.



1) python -m test --verbose test_threading

==
FAIL: test_daemon_threads_fatal_error (test.test_threading.SubinterpThreadi
ngTests)
--
Traceback (most recent call last):
  File "C:\cpython-0b858\lib\test\test_threading.py", line 1124, in test_da
emon_threads_fatal_error
self.assertIn("Fatal Python error: Py_EndInterpreter: "
AssertionError: 'Fatal Python error: Py_EndInterpreter: not the last thread
' not found in 'TypeError: codec is unexpected type\nFatal Python error: _P
yThreadState_Delete: tstate 003FF980 is still current\nPython runti
me state: initialized\n\nThread 0x0710 (most recent call first):\n\n'



2) python -m test --verbose test_embed

==
FAIL: test_audit_subinterpreter (test.test_embed.AuditingTests)
--
Traceback (most recent call last):
  File "C:\cpython-0b858\lib\test\test_embed.py", line 1433, in test_audit_
subinterpreter
self.run_embedded_interpreter("test_audit_subinterpreter")
  File "C:\cpython-0b858\lib\test\test_embed.py", line 104, in run_embedded
_interpreter
self.assertEqual(p.returncode, returncode,
AssertionError: 3221225477 != 0 : bad returncode 3221225477, stderr is 'Typ
eError: codec is unexpected type\nFatal Python error: _PyThreadState_Delete
: tstate 0050CAF0 is still current\nPython runtime state: initializ
ed\n\nThread 0x09d8 (most recent call first):\n\n'

==
FAIL: test_subinterps_different_ids (test.test_embed.EmbeddingTests)
--
Traceback (most recent call last):
  File "C:\cpython-0b858\lib\test\test_embed.py", line 169, in test_subinte
rps_different_ids
for run in self.run_repeated_init_and_subinterpreters():
  File "C:\cpython-0b858\lib\test\test_embed.py", line 110, in run_repeated
_init_and_subinterpreters
out, err = self.run_embedded_interpreter("test_repeated_init_and_subint
erpreters")
  File "C:\cpython-0b858\lib\test\test_embed.py", line 104, in run_embedded
_interpreter
self.assertEqual(p.returncode, returncode,
AssertionError: 3221225477 != 0 : bad returncode 3221225477, stderr is 'Typ
eError: codec is unexpected type\nFatal Python error: _PyThreadState_Delete
: tstate 0041C960 is still current\nPython runtime state: initializ
ed\n\nThread 0x0a40 (most recent call first):\n\n'

==
FAIL: test_subinterps_distinct_state (test.test_embed.EmbeddingTests)
--
Traceback (most recent call last):
  File "C:\cpython-0b858\lib\test\test_embed.py", line 177, in test_subinte
rps_distinct_state
for run in self.run_repeated_init_and_subinterpreters():
  File "C:\cpython-0b858\lib\test\test_embed.py", line 110, in run_repeated
_init_and_subinterpreters
out, err = self.run_embedded_interpreter("test_repeated_init_and_subint
erpreters")
  File "C:\cpython-0b858\lib\test\test_embed.py", line 104, in run_embedded
_interpreter
self.assertEqual(p.returncode, returncode,
AssertionError: 3221225477 != 0 : bad returncode 3221225477, stderr is 'Typ
eError: codec is unexpected type\nFatal Python error: _PyThreadState_Delete
: tstate 0047C960 is still current\nPython runtime state: initializ
ed\n\nThread 0x0b34 (most recent call first):\n\n'

==
FAIL: test_subinterps_main (test.test_embed.EmbeddingTests)
--
Traceback (most recent call last):
  File "C:\cpython-0b858\lib\test\test_embed.py", line 163, in test_subinte
rps_main
for run in self.run_repeated_init_and_subinterpreters():
  File "C:\cpython-0b858\lib\test\test_embed.py", line 110, in run_repeated
_init_and_subinterpreters
out, err = self.run_embedded_interpreter("test_repeated_init_and_subint
erpreters")
  File "C:\cpython-0b858\lib\test\test_embed.py", line 104, in run_embedded
_interpreter
self.assertEqual(p.returncode, returncode,
AssertionError: 3221225477 != 0 : bad returncode 3221225477, stderr is 'Typ
eError: codec is unexpected type\nFatal Python error: _PyThreadState_Delete
: tstate 0032C960 is still current\nPython runtime state: initializ
ed\n\nThread 0x0bf0 (most 

[issue38413] Remove or change "Multithreading" section

2021-01-06 Thread Berker Peksag


Change by Berker Peksag :


--
resolution:  -> fixed
type:  -> behavior

___
Python tracker 

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



[issue38413] Remove or change "Multithreading" section

2021-01-06 Thread Berker Peksag


Berker Peksag  added the comment:


New changeset 49c150f1f16398a4e77e051244f27adc5ac7b47b by Vladimir in branch 
'3.9':
bpo-38413: Remove outdated section about multithreading in sqlite3 (GH-23159)
https://github.com/python/cpython/commit/49c150f1f16398a4e77e051244f27adc5ac7b47b


--

___
Python tracker 

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



[issue40601] [C API] Hide static types from the limited C API

2021-01-06 Thread STINNER Victor


STINNER Victor  added the comment:

PC/python3dll.c exports 66 types in the stable ABI:

Py_GenericAliasType
PyObject_Type
_PyWeakref_CallableProxyType
_PyWeakref_ProxyType
_PyWeakref_RefType
PyBaseObject_Type
PyBool_Type
PyByteArray_Type
PyByteArrayIter_Type
PyBytes_Type
PyBytesIter_Type
PyCallIter_Type
PyCapsule_Type
PyCFunction_Type
PyClassMethodDescr_Type
PyComplex_Type
PyDict_Type
PyDictItems_Type
PyDictIterItem_Type
PyDictIterKey_Type
PyDictIterValue_Type
PyDictKeys_Type
PyDictProxy_Type
PyDictValues_Type
PyEllipsis_Type
PyEnum_Type
PyExc_TypeError
PyFilter_Type
PyFloat_Type
PyFrozenSet_Type
PyGetSetDescr_Type
PyList_Type
PyListIter_Type
PyListRevIter_Type
PyLong_Type
PyLongRangeIter_Type
PyMap_Type
PyMemberDescr_Type
PyMemoryView_Type
PyMethodDescr_Type
PyModule_Type
PyModuleDef_Type
PyNullImporter_Type
PyODict_Type
PyODictItems_Type
PyODictIter_Type
PyODictKeys_Type
PyODictValues_Type
PyProperty_Type
PyRange_Type
PyRangeIter_Type
PyReversed_Type
PySeqIter_Type
PySet_Type
PySetIter_Type
PySlice_Type
PySortWrapper_Type
PySuper_Type
PyTraceBack_Type
PyTuple_Type
PyTupleIter_Type
PyType_Type
PyUnicode_Type
PyUnicodeIter_Type
PyWrapperDescr_Type
PyZip_Type

--

___
Python tracker 

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



[issue41798] [C API] Revisit usage of the PyCapsule C API with multi-phase initialization API

2021-01-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 1ab045933b90d1954af983cc08d1bf0bc46b6240 by Hai Shi in branch 
'master':
bpo-41798: Allocate the _datetime.datetime_CAPI on the heap memory (GH-24096)
https://github.com/python/cpython/commit/1ab045933b90d1954af983cc08d1bf0bc46b6240


--

___
Python tracker 

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



[issue41798] [C API] Revisit usage of the PyCapsule C API with multi-phase initialization API

2021-01-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset f22b7ca1afd98a7381a9fe9e53bd6dfa2a5eba16 by Erlend Egeberg 
Aasland in branch 'master':
bpo-41798: Allocate _socket module C API on the heap (GH-24126)
https://github.com/python/cpython/commit/f22b7ca1afd98a7381a9fe9e53bd6dfa2a5eba16


--

___
Python tracker 

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



[issue38413] Remove or change "Multithreading" section

2021-01-06 Thread Vladimir Ryabtsev


Change by Vladimir Ryabtsev :


--
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.10 -Python 3.7

___
Python tracker 

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



[issue42299] Remove formatter module

2021-01-06 Thread Ernest W. Durbin III


Ernest W. Durbin III  added the comment:

Issues relating to documentation build likely need to be looked at and 
addressed by Julien. If it does end up being an infra issue, feel free to read 
me to nosy.

--
nosy: +mdk

___
Python tracker 

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



[issue42299] Remove formatter module

2021-01-06 Thread Christian Heimes


Christian Heimes  added the comment:

https://docs.python.org/3.10/library/index.html no longer links to 
https://docs.python.org/3.10/library/misc.html but misc.html and formatter.html 
are still there. It looks like a bug in the build and update process. I bet 
it's not removing files.

Ee, could you take a look, please?

--
nosy: +EWDurbin

___
Python tracker 

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



[issue38413] Remove or change "Multithreading" section

2021-01-06 Thread Vladimir Ryabtsev


Change by Vladimir Ryabtsev :


--
pull_requests: +22974
pull_request: https://github.com/python/cpython/pull/24145

___
Python tracker 

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



[issue42115] Caching infrastructure for the evaluation loop: specialised opcodes

2021-01-06 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Agreed. In that regard the most standard thing that we have is the 
pyperformance suite, which are almost all macro benchmarks. Is also what is 
displayed in speed.python.org

--

___
Python tracker 

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



[issue42840] `type` takes **kwargs for __init_subclass__

2021-01-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

Excellent!

--

___
Python tracker 

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



[issue42839] SourceFileLoader does not (fully) accept path-like objects

2021-01-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

If Brett's theory is right, compile() has a bug though -- it shouldn't plug a 
non-string into the code object. Or possibly the code object constructor should 
reject such objects (or extract the string).

--

___
Python tracker 

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



[issue42839] SourceFileLoader does not (fully) accept path-like objects

2021-01-06 Thread Brett Cannon

Brett Cannon  added the comment:

importlib is probably not os.PathLike-clean due to its bootstrapping 
restrictions of not getting to use anything implemented in Python from 'os' 
(i.e. if it isn't being managed in posixmodule.c then it probably won't work).

If you follow the traceback it's trying to marshal a code object for the 
eventual .pyc file and failing 
(https://github.com/python/cpython/blob/faf49573963921033c608b4d2f398309d9f0d2b5/Lib/importlib/_bootstrap_external.py#L604).
 The real question is why is any unmarshallable object getting passed in the 
first place since that object is the code object that compile() returned.

Best guess? The compile() function is being given the path-like object (via 
https://github.com/python/cpython/blob/faf49573963921033c608b4d2f398309d9f0d2b5/Lib/importlib/_bootstrap_external.py#L848)
 and it's blindly setting it on the code object itself, and then marhsal fails 
since it can't handle pathlib.Path. If my hunch is right, then the possible 
solutions are:

- Don't do that 
- Make compile() aware of path-like objects
- Have importlib explicitly work around compile()'s shortcoming by doing the 
right thing for path-like objects before passing in the the 'path' argument.

--

___
Python tracker 

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



[issue42840] `type` takes **kwargs for __init_subclass__

2021-01-06 Thread Erik Soma


Erik Soma  added the comment:

Can do.

I have found a blurb in the 3.6 What's New that confirms it was purposeful 
(https://docs.python.org/3/whatsnew/3.6.html#index-37).

--

___
Python tracker 

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



[issue38780] SysLogHandler crash atexit

2021-01-06 Thread Vinay Sajip


Vinay Sajip  added the comment:

> As far as I know, this only happens during shutdown. During shutdown it has 
> already removed the attribute as part of the teardown process. In this case 
> adding the attribute at the begining will do no good.

Certainly, that's true - there are a number of issues that get laid at 
logging's door because of interpreter shutdown sometimes intersecting with 
asyncio, threads and error handling using logging to report, which then fails 
in turn because of inconsistent interpreter state during shutdown. That would 
then perhaps be a "wontfix" or "cantfix" because there is no good solution. But 
the missing socket attribute in SysLogHandler might cause other problems in the 
future - I'm just saying that the approach you suggested is, to me, preferable 
to the NullSocket approach to deal with a similar issue in this area.

--

___
Python tracker 

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



[issue42299] Remove formatter module

2021-01-06 Thread Miro Hrončok

Miro Hrončok  added the comment:

I am confused. Why is this still online when the source was removed?

https://docs.python.org/3.10/library/formatter.html

--
nosy: +hroncok

___
Python tracker 

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



[issue42841] Add bitwise or operator to collections.abc Mapping and MutableMapping

2021-01-06 Thread Yurii Karabas


Yurii Karabas <1998uri...@gmail.com> added the comment:

Thanks, for the replies, didn't know about that.

Interesting thing that `collections.abc.Set` base class has implementations of 
`__and__`, `__or__`, `__sub__` and `__xor__` methods, it also provide 
`_from_iterable` class method that is used to create `Set` instance from 
iterable (all of those operators use this method).
```
class Set(Collection):
...
@classmethod
def _from_iterable(cls, it):
'''Construct an instance of the class from any iterable input.

Must override this method if the class constructor signature
does not accept an iterable for an input.
'''
return cls(it)
```

Basically, my proposition was to do smth similar to `collections.abc.Mapping`, 
but I understand your motivation not to implement this feature.

--

___
Python tracker 

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



[issue42115] Caching infrastructure for the evaluation loop: specialised opcodes

2021-01-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

Undoubtedly -- but impact should be measured on what typical users would see, 
not on narrow benchmarks.

--

___
Python tracker 

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



[issue42811] Update docs for importlib.util.resolve_name() to use __spec__.parent instead of __package__

2021-01-06 Thread Brett Cannon


Change by Brett Cannon :


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



[issue42811] Update docs for importlib.util.resolve_name() to use __spec__.parent instead of __package__

2021-01-06 Thread miss-islington


miss-islington  added the comment:


New changeset ff8458b918050168acda1ad6d079f52b8effa821 by Yair Frid in branch 
'master':
bpo-42811: Update importlib.utils.resolve_name() docs to use __spec__.parent 
(GH-24100)
https://github.com/python/cpython/commit/ff8458b918050168acda1ad6d079f52b8effa821


--

___
Python tracker 

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



[issue42811] Update docs for importlib.util.resolve_name() to use __spec__.parent instead of __package__

2021-01-06 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue42839] SourceFileLoader does not (fully) accept path-like objects

2021-01-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

Maybe Brett can help?

--
nosy: +brett.cannon, gvanrossum

___
Python tracker 

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



[issue42841] Add bitwise or operator to collections.abc Mapping and MutableMapping

2021-01-06 Thread Brandt Bucher


Brandt Bucher  added the comment:

(Also, it would break virtual subclasses.)

--
nosy: +brandtbucher

___
Python tracker 

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



[issue42840] `type` takes **kwargs for __init_subclass__

2021-01-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

That sounds intentional to me (else the class statement would have a capability 
that cannot be dynamically emulated by calling type()).

We should probably update the docs (if you could submit a small PR that would 
be appreciated) and also typeshed (ditto).

--
nosy: +gvanrossum

___
Python tracker 

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



[issue38780] SysLogHandler crash atexit

2021-01-06 Thread Alan Robertson


Alan Robertson  added the comment:

As far as I know, this only happens during shutdown. During shutdown it has 
already removed the attribute as part of the teardown process. In this case 
adding the attribute at the begining will do no good.

On Wed, Jan 6, 2021, at 10:30 AM, Vinay Sajip wrote:
> 
> Vinay Sajip  added the comment:
> 
> TBH as I said in the now-closed PR, using a NullSocket seems overkill. 
> As mentioned in msg359594, it seems to make more sense to assign a 
> socket attribute to None early in the constructor. If an error occurs 
> during socket creation, the socket attribute will remain at None. When 
> closing, just ensure the socket attribute isn't None before trying to 
> close it. This mirrors what SocketHandler does.
> 
> --
> 
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue38780] SysLogHandler crash atexit

2021-01-06 Thread Alan Robertson


Alan Robertson  added the comment:

On Wed, Jan 6, 2021, at 10:30 AM, Vinay Sajip wrote:
> 
> Vinay Sajip  added the comment:
> 
> TBH as I said in the now-closed PR, using a NullSocket seems overkill. 
> As mentioned in msg359594, it seems to make more sense to assign a 
> socket attribute to None early in the constructor. If an error occurs 
> during socket creation, the socket attribute will remain at None. When 
> closing, just ensure the socket attribute isn't None before trying to 
> close it. This mirrors what SocketHandler does.
> 
> --
> 
> ___
> Python tracker 
> 
> ___
>

-- 
  Alan Robertson
  al...@unix.sh

--

___
Python tracker 

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



[issue42841] Add bitwise or operator to collections.abc Mapping and MutableMapping

2021-01-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

This was discussed during the PEP review and rejected. The main reason is that 
this operator would need to create a new instance, and there is no standard API 
that's part of the Mapping protocol that can be used (the constructor of a 
Mapping instance might have unknown parameters).

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



[issue38780] SysLogHandler crash atexit

2021-01-06 Thread Vinay Sajip


Vinay Sajip  added the comment:

TBH as I said in the now-closed PR, using a NullSocket seems overkill. As 
mentioned in msg359594, it seems to make more sense to assign a socket 
attribute to None early in the constructor. If an error occurs during socket 
creation, the socket attribute will remain at None. When closing, just ensure 
the socket attribute isn't None before trying to close it. This mirrors what 
SocketHandler does.

--

___
Python tracker 

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



[issue42845] Third Party Module Installation using pip fails in Python 3.10.0a3

2021-01-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

This is expected -- those modules contain C extensions for which no 3.10 wheels 
are available from PyPI yet, so pip tries to build them locally.

If you want to help testing, please install the recommended free version of the 
MS C++ compiler.  From CPython/PCbuild/readme.txt:

1.  Install Microsoft Visual Studio 2017 with Python workload and
Python native development component.

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



[issue42842] module 'logging' has not attribute 'handlers'

2021-01-06 Thread Vinay Sajip


Vinay Sajip  added the comment:

This is not a bug - this is how it is supposed to work. The handlers module 
isn't automatically loaded; you have to import it. The basic handlers 
(NullHandler, StreamHandler, FileHandler) are in the logging module - 
additional handlers are in logging.handlers.

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



[issue42844] Turtle Module -- "onclick" arguments enchancement

2021-01-06 Thread Stephen


Change by Stephen :


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

___
Python tracker 

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



[issue42845] Third Party Module Installation using pip fails in Python 3.10.0a3

2021-01-06 Thread Shreyan Avigyan


New submission from Shreyan Avigyan :

A few days ago, I tried installing Python 3.10.a3 for testing. After 
installing, I tried using the Python built-in modules, they were working fine. 
Then I tried going for installing third party modules using pip from the 
command prompt. While installing I noticed that some modules I could install 
perfectly but for most of the modules, they failed to install. After trying to 
install them, I tried looking for the full error message. After a lot of 
searching I found out that it is looking for Microsoft Visual C++ and couldn't 
find it because I haven't installed it and gave me that error. I haven't tried 
installing Python 3.10.0a4 yet and I don't know if it's already solved or not 
but this problem is continuously occurring in Python 3.10.0a3.

--
components: Installation
messages: 384515
nosy: shreyanavigyan
priority: normal
severity: normal
status: open
title: Third Party Module Installation using pip fails in Python 3.10.0a3
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



[issue42843] What min_sphinx for Python 3.10

2021-01-06 Thread Julien Palard


Julien Palard  added the comment:

In favor of Sphinx 3 only :

- We have :no-trim-doctest-flags: which fixes https://bugs.python.org/issue36675
- backslash handing is different in Sphinx 2 and Sphinx 3: 
https://bugs.python.org/issue42822


In favor of keeping compatibility with Sphinx 2 :

- Some distribs may want/need to ship Python 3.10 along with Sphinx 2?

So I'm personally in favor of a full witch to Sphinx 3 with Python 3.10, but 
I'm open to hear everybody.

--

___
Python tracker 

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



[issue42844] Turtle Module -- "onclick" arguments enchancement

2021-01-06 Thread Stephen

New submission from Stephen :

I have created an enhancement in the Turtle module. When a programmer wants to 
have an action performed after clicking on a Turtle object, the programmer is 
currently unable to supply any arguments into the method that is run when 
"on_clicked" which is extremely limiting, especially to beginners who are 
looking to modify multiple objects on the screen at one time, such as in a 
game. I have modified the implementation of the “on_clicked” method to be able 
to provide keyword arguments into the method through a dictionary that is later 
unpacked into the target method. Attached is an example of the benefits of this 
enhancement to the turtle module.

--
components: Library (Lib)
files: on_click_arguments_example.py
messages: 384513
nosy: sc1341
priority: normal
severity: normal
status: open
title: Turtle Module -- "onclick" arguments enchancement
type: enhancement
versions: Python 3.10
Added file: https://bugs.python.org/file49723/on_click_arguments_example.py

___
Python tracker 

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



[issue42843] What min_sphinx for Python 3.10

2021-01-06 Thread Julien Palard


Change by Julien Palard :


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

___
Python tracker 

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



[issue42843] What min_sphinx for Python 3.10

2021-01-06 Thread Julien Palard


New submission from Julien Palard :

According to [1] there's no concensus on which minimum Sphinx version we should 
use for Python 3.10.

"sadly" since https://github.com/python/cpython/pull/23620 which make use of a 
Sphinx 3.2.0 only feature, we should bump it to 3.2, but it may not work for 
everybody.

[1]: https://github.com/python/cpython/pull/23620#issuecomment-755420205

--
assignee: mdk
components: Documentation
messages: 384512
nosy: mdk
priority: normal
severity: normal
status: open
title: What min_sphinx for Python 3.10

___
Python tracker 

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



[issue42842] module 'logging' has not attribute 'handlers'

2021-01-06 Thread hai shi


Change by hai shi :


--
nosy: +vinay.sajip

___
Python tracker 

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



[issue42309] BUILD: AIX-64-bit segmentation fault using xlc-v11

2021-01-06 Thread Michael Felt


Michael Felt  added the comment:

OK - looking at this again.

This looks very similiar to another 'coredump' issue (will have to look for the 
number later). iirc, when something called 'pgen', or similiar was modified.

Here is a lengthy `dbx` dump.

If I am reading this correctly, it is 'starting' in this area:

_PyPegen_run_parser(p = 0x0fffcb40), line 1121 in "pegen.c"
_PyPegen_run_parser_from_string(str = "compile", start_rule = 1, filename_ob = 
0x0001100ee2b0, flags = 0x0707fb30, arena = 0x070d3330), 
line 1250 in "pegen.c"
PyPegen_ASTFromStringObject(str = warning: Unable to access address 0x15d4 from 
core
(invalid char ptr (0x15d4)), filename = (nil), mode = 268435455, 
flags = 0x482448c2, arena = 0x0001001a1e3c), line 27 in "peg_api.c"
Py_CompileStringObject(str = "", filename = (nil), start = 268435455, flags = 
0x0707fb30, optimize = 268435455), line 1274 in "pythonrun.c"
builtin_compile_impl(module = 0x000100077a0c, source = (nil), filename = 
0x00011e28, mode = "", flags = 1, dont_inherit = 1, optimize = 0, 
feature_version = 0), line 819 in "bltinmodule.c"
builtin_compile(module = (nil), args = 0x0001100741c0, nargs = 2, kwnames = 
0x070068f0), line 274 in "bltinmodule.c.h"
cfunction_vectorcall_FASTCALL_KEYWORDS(func = 0x0fffd030, args = 
0x1300, nargsf = 0, kwnames = 0x0008), line 457 in 
"methodobject.c"


Here is the complete 'where' status:

(dbx) where
strncmp.strncmp(??, ??, ??) at 0x901b3a0
_get_keyword_or_name_type(p = 0x0020, name = (nil), name_len = 0), 
line 535 in "pegen.c"
_PyPegen_fill_token(p = 0x0001001be088), line 638 in "pegen.c"
_PyPegen_is_memoized(p = 0x0020, type = 0, pres = 
0x0fffc370), line 716 in "pegen.c"
dotted_name_rule(p = 0x0fffc400), line 3443 in "parse.c"
dotted_as_name_rule@AF452_298(??), line 3410 in "parse.c"
_gather_36_rule@AF453_127(??), line 17755 in "parse.c"
dotted_as_names_rule@AF454_299(??), line 3368 in "parse.c"
import_name_rule(p = 0x0fffc660), line 3000 in "parse.c"
import_stmt_rule@AF462_305(??), line 2932 in "parse.c"
small_stmt_rule(p = 0x0fffc7a0), line 1606 in "parse.c"
unnamed block in simple_stmt_rule(p = 0x0001000df758), line 1428 in 
"parse.c"
simple_stmt_rule(p = 0x0001000df758), line 1428 in "parse.c"
unnamed block in statement_rule(p = 0x15d5), line 1262 in "parse.c"
statement_rule(p = 0x15d5), line 1262 in "parse.c"
_loop1_11_rule(p = 0x0001000df6d4), line 16254 in "parse.c"
statements_rule@AF475_318(??), line 1197 in "parse.c"
file_rule@AF476_324(??), line 730 in "parse.c"
_PyPegen_run_parser(p = 0x0fffcb40), line 1121 in "pegen.c"
_PyPegen_run_parser_from_string(str = "compile", start_rule = 1, filename_ob = 
0x0001100ee2b0, flags = 0x0707fb30, arena = 0x070d3330), 
line 1250 in "pegen.c"
PyPegen_ASTFromStringObject(str = warning: Unable to access address 0x15d4 from 
core
(invalid char ptr (0x15d4)), filename = (nil), mode = 268435455, 
flags = 0x482448c2, arena = 0x0001001a1e3c), line 27 in "peg_api.c"
Py_CompileStringObject(str = "", filename = (nil), start = 268435455, flags = 
0x0707fb30, optimize = 268435455), line 1274 in "pythonrun.c"
builtin_compile_impl(module = 0x000100077a0c, source = (nil), filename = 
0x00011e28, mode = "", flags = 1, dont_inherit = 1, optimize = 0, 
feature_version = 0), line 819 in "bltinmodule.c"
builtin_compile(module = (nil), args = 0x0001100741c0, nargs = 2, kwnames = 
0x070068f0), line 274 in "bltinmodule.c.h"
cfunction_vectorcall_FASTCALL_KEYWORDS(func = 0x0fffd030, args = 
0x1300, nargsf = 0, kwnames = 0x0008), line 457 in 
"methodobject.c"
PyVectorcall_Call(callable = 0x0fffd0c0, tuple = 0x070b9900, 
kwargs = 0x070bf1c8), line 257 in "call.c"
do_call_core(tstate = 0x0001, func = 0x0002, callargs = 
0x0001, kwdict = 0x0001100741c0), line 5092 in "ceval.c"
_PyEval_EvalFrameDefault(tstate = 0x0fffd370, f = 0x070aced8, 
throwflag = 1), line 3580 in "ceval.c"
_PyEval_EvalCode(tstate = 0x9f63fdf1699118db, _co = 0x0704ed80, globals 
= 0x070754c0, locals = 0x07051070, args = 0x0fffd4a0, 
argcount = 4765972565237396600, kwnames = 0x0001000bb5e4, kwargs = 
0x070683b0, kwcount = 2, kwstep = 0, defs = (nil), defcount = 0, kwdefs 
= (nil), closure = (nil), name = 0x07055ad0, qualname = 
0x07055ad0), line 40 in "pycore_ceval.h"
_PyFunction_Vectorcall(func = 0x0fffd560, stack = 0x0001100aefa8, 
nargsf = 1152921504606836064, kwnames = 0x070b70f0), line 413 in 
"call.c"
_PyEval_EvalFrameDefault(tstate = 0x00010001c9c4, f = 0x000b99c0, 
throwflag = 268435455), line 621 in "abstract.h"

[issue42842] module 'logging' has not attribute 'handlers'

2021-01-06 Thread sasquatchplatypus


Change by sasquatchplatypus :


--
title: import logging.handlers shows weird behavior -> module 'logging' has not 
attribute 'handlers'

___
Python tracker 

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



[issue30044] shutil.copystat should (allow to) copy ownership, and other attributes

2021-01-06 Thread Eryk Sun


Eryk Sun  added the comment:

> For Windows though, I'm unsure.

If copystat() gains the ability to copy the file's owner and group in POSIX, it 
is not a priority to mirror this capability in Windows, which doesn't implement 
anything like the Unix owner-group-other permission model. The only security 
metadata that I expect to be copied in Windows is the file's resource 
attributes, which are named attributes set on an object -- and considered 
inherent to the object -- for use in conditional access-control entries. 
Normally, the rest of the security descriptor is not copied, including the 
owner, group, mandatory label (integrity level and read-up/write-up/execute-up 
access), discretionary access-control list, and system access-control list 
(audit entries). That level of deep copying is a backup and restore operation 
of the complete file context, not a normal file copy.

Regarding copy2(), what I've seen proposed a couple of times for Windows is to 
implement it via CopyFileExW(). The documentation of copy2() would have to be 
special cased to explain that the platform copy routine is used in Windows, 
which copies all named (alternate) data streams and settable file attributes, 
extended attributes, and resource attributes. It would also need to be 
emphasized that copy2() is not equivalent to copyfile() + copystat() in Windows.

--

___
Python tracker 

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



[issue42842] import logging.handlers shows weird behavior

2021-01-06 Thread sasquatchplatypus


New submission from sasquatchplatypus :

when trying to import a handler from logging.handlers, you have to explicitely 
import logging.handlers, because trying to get it from logging directly (for 
example import logging, logging.handlers.RotatingFileHandlers)
raises this error: AttributeError: module 'logging' has no attribute 'handlers'

--
messages: 384509
nosy: sasquatchplatypus
priority: normal
severity: normal
status: open
title: import logging.handlers shows weird behavior
type: behavior
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



[issue42837] Symbol table incorrectly identifies code as a generator, when 'yield' occurs in an annotation

2021-01-06 Thread Guido van Rossum


Change by Guido van Rossum :


--
nosy: +gvanrossum, lys.nikolaou, pablogsal

___
Python tracker 

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



[issue42725] PEP 563: Should the behavior change for yield/yield from's

2021-01-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

Yield in an annotation should be a syntax error.

--

___
Python tracker 

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



[issue42841] Add bitwise or operator to collections.abc Mapping and MutableMapping

2021-01-06 Thread Yurii Karabas


Change by Yurii Karabas <1998uri...@gmail.com>:


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

___
Python tracker 

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



[issue42841] Add bitwise or operator to collections.abc Mapping and MutableMapping

2021-01-06 Thread Yurii Karabas


Change by Yurii Karabas <1998uri...@gmail.com>:


--
components: +Library (Lib)
type:  -> enhancement

___
Python tracker 

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



[issue42841] Add bitwise or operator to collections.abc Mapping and MutableMapping

2021-01-06 Thread Yurii Karabas


New submission from Yurii Karabas <1998uri...@gmail.com>:

In python3.9 `dict` `bitwise or` operator was introduced.

I think it will be great if `collections.abc.Mapping` and 
`collections.abc.MutableMapping` will have a default implementation of `bitwise 
or` operator.

--
messages: 384507
nosy: uriyyo
priority: normal
severity: normal
status: open
title: Add bitwise or operator to collections.abc Mapping and MutableMapping

___
Python tracker 

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



[issue42840] `type` takes **kwargs for __init_subclass__

2021-01-06 Thread Erik Soma


New submission from Erik Soma :

The documentation (https://docs.python.org/3/library/functions.html#type) shows 
type's signature as:

class type(object)
class type(name, bases, dict)


But the "actual" 2nd signature in CPython 3.6+ is:

class type(name, bases, dict, **kwargs)


**kwargs here gets passed to __init_subclass__ in the same way that keywords in 
a class statement do so that:

type("Bar", (Foo,), {}, spam='ham')

is equivalent to

class Bar(Foo, spam='ham'): pass


It's not clear to me whether this is behavior to rely on. I started using this 
intuitively, but found that my type checker reasonably complained.

Looking through the commit that implemented PEP 487 (d78448e9), it seems this 
may have been incidental. Additionally I haven't found mention of this in PEP 
487 or the documentation and I can't seem to find any tests for it.

--
messages: 384506
nosy: esoma
priority: normal
severity: normal
status: open
title: `type` takes **kwargs for __init_subclass__
type: behavior
versions: Python 3.10, 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



[issue42823] Incorrect frame.f_lineno when frame.f_trace is set

2021-01-06 Thread Ned Batchelder


Ned Batchelder  added the comment:

OK, thanks.  I guess the parallels between the Python frame object and the C 
frame object made it easy to think I could use the fields directly.  I'm 
updating the coverage.py code.

--

___
Python tracker 

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



[issue42839] SourceFileLoader does not (fully) accept path-like objects

2021-01-06 Thread favonia


New submission from favonia :

If one uses the loader created by 
importlib.machinery.SourceFileLoader(module_name, path) in a meta path finder, 
where path is not a str, then the following error would happen at the moment 
the module is being imported. Note that, the error would not occur if the 
corresponding bytecode cache (__pycache__/*.pyc) is present.

  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 1030, in _gcd_import
  File "", line 1007, in _find_and_load
  File "", line 972, in _find_and_load_unlocked
  File "", line 228, in _call_with_frames_removed
  File "", line 1030, in _gcd_import
  File "", line 1007, in _find_and_load
  File "", line 986, in _find_and_load_unlocked
  File "", line 680, in _load_unlocked
  File "", line 786, in exec_module
  File "", line 932, in get_code
  File "", line 604, in 
_code_to_timestamp_pyc
ValueError: unmarshallable object

Here is an example that could trigger the error. The package unipath is not 
very important except that unipath.Path is not marshallable. (Any library with 
a fancy, unmarshallable path-like object would work.) The choice of 'local' and 
the use of 'os.getcwd()' are also irrelevant. The actual production code is 
quite complicated, using different path-like objects and convoluted logic. I 
made up this example from scratch.

import os
import sys
import importlib
import importlib.abc
import importlib.util
from unipath import Path # just an example

class DummyFinder(importlib.abc.MetaPathFinder):
def __init__(self):
self.cwd = os.getcwd()
def find_spec(self, fullname, path, target=None):
if fullname == 'local':
initpath = os.path.join(self.cwd, '__init__.py')
if os.path.isfile(initpath):
loader = importlib.machinery.SourceFileLoader(fullname, 
Path(initpath)) # some non-str Path-like object here
return importlib.util.spec_from_file_location(fullname, 
initpath,
loader = loader, submodule_search_locations=[self.cwd])
else:
return None

sys.meta_path.append(DummyFinder())
importlib.import_module("local.test2")

If this is indeed a bug, there might be other classes and functions in 
importlib that share the same problem.

--
components: Library (Lib)
messages: 384504
nosy: favonia
priority: normal
severity: normal
status: open
title: SourceFileLoader does not (fully) accept path-like objects
type: enhancement
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



[issue42838] Wait for cleanup coroutines before event loop is closed.

2021-01-06 Thread xloem


New submission from xloem <0xl...@gmail.com>:

To handle destruction of resources especially during exceptions, it would be 
nice if there were some way to provide coroutines/tasks that run at the 
termination or closure of an event loop.  There are a lot of api options here.  
Maybe a simple one would be to have close() call a run_until_closed() function 
that starts all of these and steps the loop to wait for them, before closing, 
and provide run_close() functions to queue them for delay.

--
components: asyncio
messages: 384503
nosy: asvetlov, xloem, yselivanov
priority: normal
severity: normal
status: open
title: Wait for cleanup coroutines before event loop is closed.
type: enhancement
versions: Python 3.10, Python 3.8

___
Python tracker 

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



[issue42823] Incorrect frame.f_lineno when frame.f_trace is set

2021-01-06 Thread Mark Shannon


Mark Shannon  added the comment:

It looks like you are accessing the c field "f_lineno" directly.
That was never guaranteed to work, it just happened to.
You should use PyFrame_GetLineNumber()
If "f_lineno" is up to date, then it will be almost efficient as the direct 
field access (the overhead is a C call).
If "f_lineno" is not up to date, PyFrame_GetLineNumber() will compute the 
correct value.

In the interest of efficiency it makes sense that the internal f_line field is 
updated before CALL and RETURN trace events.
I'll make that change, but you really ought to use the API rather than probing 
into the frame internals.

--

___
Python tracker 

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



[issue39457] Add an autocommit property to sqlite3.Connection with a PEP 249 compliant manual commit mode and migrate

2021-01-06 Thread mike bayer


mike bayer  added the comment:

I think this issue just discusses the naming of an attribute called 
".autocommit".  for the discussion for SQLite's unusual starting of 
transactions, that's all in two other issues:

https://bugs.python.org/issue9924 

https://bugs.python.org/issue10740

so I would encourage folks to read those discussions.  at issue is the 
limitation of SQLite that it locks the whole file for transactions, which is 
the main rationale for why SQLite is hesitant to begin a transaction.  however, 
without configurability, this means it's not compatible with SAVEPOINT or 
serializable isolation levels.   when users want to use those two features we 
have them set isolation_level=None and emit "BEGIN" on the connection directly. 
   the connection.commit() and connection.rollback() methods continue to be 
functional

--

___
Python tracker 

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



[issue42823] Incorrect frame.f_lineno when frame.f_trace is set

2021-01-06 Thread Ned Batchelder


Ned Batchelder  added the comment:

This change seems like it has caused a problem.  Python trace functions behave 
as they did in Python 3.9, but C trace functions no longer get line numbers for 
call or return events.


Running this test code:

def gen(inp):
for n in inp:
yield n

list(gen([1,2,3]))

With my C trace function logging what it is passed, in Python 3.9 I got this:

trace: CALL @ coverage_test_2616437928787223.py 1
trace: LINE @ coverage_test_2616437928787223.py 1
trace: LINE @ coverage_test_2616437928787223.py 5
trace: CALL @ coverage_test_2616437928787223.py 1
trace: LINE @ coverage_test_2616437928787223.py 2
trace: LINE @ coverage_test_2616437928787223.py 3
trace: RET  @ coverage_test_2616437928787223.py 3
trace: CALL @ coverage_test_2616437928787223.py 3
trace: LINE @ coverage_test_2616437928787223.py 2
trace: LINE @ coverage_test_2616437928787223.py 3
trace: RET  @ coverage_test_2616437928787223.py 3
trace: CALL @ coverage_test_2616437928787223.py 3
trace: LINE @ coverage_test_2616437928787223.py 2
trace: LINE @ coverage_test_2616437928787223.py 3
trace: RET  @ coverage_test_2616437928787223.py 3
trace: CALL @ coverage_test_2616437928787223.py 3
trace: LINE @ coverage_test_2616437928787223.py 2
trace: RET  @ coverage_test_2616437928787223.py 2
trace: RET  @ coverage_test_2616437928787223.py 5

With 3.10 (commit 1a9f51ed12feb4d95ad6d0faf610a030c05b9f5e) I get:

trace: CALL @ coverage_test_40117094849631774.py 0
trace: LINE @ coverage_test_40117094849631774.py 1
trace: LINE @ coverage_test_40117094849631774.py 5
trace: CALL @ coverage_test_40117094849631774.py 0
trace: LINE @ coverage_test_40117094849631774.py 2
trace: LINE @ coverage_test_40117094849631774.py 3
trace: RET  @ coverage_test_40117094849631774.py 0
trace: CALL @ coverage_test_40117094849631774.py 0
trace: LINE @ coverage_test_40117094849631774.py 2
trace: LINE @ coverage_test_40117094849631774.py 3
trace: RET  @ coverage_test_40117094849631774.py 0
trace: CALL @ coverage_test_40117094849631774.py 0
trace: LINE @ coverage_test_40117094849631774.py 2
trace: LINE @ coverage_test_40117094849631774.py 3
trace: RET  @ coverage_test_40117094849631774.py 0
trace: CALL @ coverage_test_40117094849631774.py 0
trace: LINE @ coverage_test_40117094849631774.py 2
trace: RET  @ coverage_test_40117094849631774.py 0
trace: RET  @ coverage_test_40117094849631774.py 0

All of the call and return events now get a frame with f_lineno == 0.

Python trace functions seem unaffected.

The C code producing this debug output is here: 
https://github.com/nedbat/coveragepy/blob/a498ebc28273fd21b6a047a173b2e4443b91f563/coverage/ctracer/tracer.c#L786-L813

--
nosy: +nedbat
status: closed -> open

___
Python tracker 

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



[issue39457] Add an autocommit property to sqlite3.Connection with a PEP 249 compliant manual commit mode and migrate

2021-01-06 Thread James Oldfield

James Oldfield  added the comment:

There's some confusion here over what autocommit=True would do. I believe the 
last three comments give three different interpretations! Géry said 
conn.autocommit would change to False when I start a transaction with 
execute("BEGIN"), Mike said it wouldn't (because it represents the driver's 
state, not the engine's, by analogy with other DB API drivers), and Marc-Andre 
says execute("BEGIN") wouldn't be allowed in the first place (or at least it 
would issue a warning).

To reiterate, the ability to control transactions manually is already supported 
in the sqlite3 driver, in the form of isolation_mode=None. My first request is 
simply that **this ability continues to exist**. This functionality was 
implemented deliberately - the original author of pysqlite recommended this 
usage, and care has been taken over the years not to break it. Please do not 
point out that this is not DB API compliant; I know that, and I just don't 
care! So long as DB API compliant usage is _also_ supported, even the default, 
that doesn't prevent this other mode from existing too. Many others are using 
the mode, even if they are not commenters here, so I don't believe it is 
feasible to break or remove this functionality, even if you're not a fan.

My second request was: feel free to rename this option from 
"isolation_mode=None" to something else if you wish, but please don't call it 
"autocommit=True" because that's just too confusing. I feel like the confusion 
in the comments above justifies this point of view.

As I see it, that leaves two options:

Option 1: Suck it up and use autocommit=True as the option name. It's 
confusing, but there's so much precedent that it has to be so. This is Mike 
Bayer's suggestion (except he didn't say it was confusing, that's just my 
commentary). I think that this option is only feasible if conn.autocommit only 
refer's the driver's state, not the underlying engine's state, confusing though 
that is i.e. once set to true it would *always* be true, even if a transaction 
is started.

Option 2: Reserve autocommit=True for the underlying SQLite engine autocommit 
mode. That means detecting when there's an attempt to use execute("BEGIN") or 
similar, and then issuing a warning or error. It also means supplying some 
other, third, option for what I'm asking (like today's isolation_mode=None).

Although option 2 is closer to what I originally requested, I do worry it means 
that the non-DBAPI mode will appear unsupported and fall into neglect. If the 
API for accessing it is to set autocommit=None, to mean legacy behaviour, and 
then also isolation_mode=None to mean the type of legacy behaviour, then it 
doesn't look like the most recommended API ever. And yet, for those that don't 
care about DB API (which I imagine is most users of the sqlite3 driver), this 
is probably the best API to use.

So I reluctantly agree that option 1, using autocommit=True, is actually best 
overall. I would ask that there is at least a note in the documentation so that 
it's clear this is allowed to work. Something like this:

If autocommit=True then the sqlite3 module will never automatically start 
transactions. The underlying SQLite database engine operates in autocommit mode 
whenever no transactions are active, so the net effect of this is to use 
SQLite's autocommit mode [1].

Note that, when autocommit=True, the sqlite3 module will not intercept and 
stop a statement to explicitly start a transaction, such as with 
execute("BEGIN"). In that case, a transaction is started and the underlying 
SQLite engine is no longer in autocommit mode. (The sqlite3 Connection object 
will still report autocommit=True; this does not indicate that the SQLite 
engine is autocommit mode, just that the sqlite3 module is not going to 
implicitly start any transactions.)

The connection commit() and rollback() methods may be used for transactions 
started explictly when autocommit=True, and the connection may be used as a 
context manager, just as it can be when autocommit=False. If no transaction is 
currently active then those methods silent pass with no effect.

[1] 
https://sqlite.org/lang_transaction.html#implicit_versus_explicit_transactions

Side note: When I started down this rabbit hole several weeks ago, I repeatedly 
came across the extremely confusing phrase "SQLite operates in autocommit mode 
by default". It took me a while to realise that autocommit is not a flag that 
it is possible to turn off on a connection *when you open it*. The text I used 
above, "The underlying SQLite database engine operates in autocommit mode 
whenever no transactions are active" was carefully chosen and I consider it to 
be much clearer, regardless of whatever else ends up happening.

--

___
Python tracker 

___
___

[issue42528] Improve the docs of most Py*_Check{,Exact} API calls

2021-01-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset faf49573963921033c608b4d2f398309d9f0d2b5 by Miss Islington (bot) 
in branch '3.9':
bpo-42528: Improve the docs of most Py*_Check{,Exact} API calls (GH-23602) 
(GH-24139)
https://github.com/python/cpython/commit/faf49573963921033c608b4d2f398309d9f0d2b5


--

___
Python tracker 

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



[issue42827] pegen parser: Multiline eval with assignment to function call: assertion failed

2021-01-06 Thread Lysandros Nikolaou


Change by Lysandros Nikolaou :


--
pull_requests: +22969
pull_request: https://github.com/python/cpython/pull/24140

___
Python tracker 

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



[issue42115] Caching infrastructure for the evaluation loop: specialised opcodes

2021-01-06 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I subscribe that but is also a matter of what are the optimizations with higher 
ratio impact/(cost+complexity). Caching the function pointers on binary 
operations or (better IMHO) comparisons is likely a good candidate

--

___
Python tracker 

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



[issue42528] Improve the docs of most Py*_Check{,Exact} API calls

2021-01-06 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue22213] Make pyvenv style virtual environments easier to configure when embedding Python

2021-01-06 Thread STINNER Victor


STINNER Victor  added the comment:

See also "Configure Python initialization (PyConfig) in Python"
https://mail.python.org/archives/list/python-...@python.org/thread/HQNFTXOCDD5ROIQTDXPVMA74LMCDZUKH/#X45X2K4PICTDJQYK3YPRPR22IGT2CDXB

And bpo-42260: [C API] Add PyInterpreterState_SetConfig(): reconfigure an 
interpreter.

--

___
Python tracker 

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



[issue42837] Symbol table incorrectly identifies code as a generator, when 'yield' occurs in an annotation

2021-01-06 Thread Mark Shannon


Mark Shannon  added the comment:

OK, I won't merge anything yet.

--

___
Python tracker 

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



[issue41798] [C API] Revisit usage of the PyCapsule C API with multi-phase initialization API

2021-01-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset fe9f446afe46bd716592eda9fa2af8d9f46bbce4 by Erlend Egeberg 
Aasland in branch 'master':
bpo-41798: Allocate _decimal extension module C API on the heap (GH-24117)
https://github.com/python/cpython/commit/fe9f446afe46bd716592eda9fa2af8d9f46bbce4


--

___
Python tracker 

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



[issue42528] Improve the docs of most Py*_Check{,Exact} API calls

2021-01-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 315fc52db17b19fe30aa9193f26adf69e18d8844 by Antonio Cuni in 
branch 'master':
bpo-42528: Improve the docs of most Py*_Check{,Exact} API calls (GH-23602)
https://github.com/python/cpython/commit/315fc52db17b19fe30aa9193f26adf69e18d8844


--

___
Python tracker 

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



[issue42681] Incorrect range checks/documentation in curses

2021-01-06 Thread STINNER Victor


STINNER Victor  added the comment:

Great work, thank you Serhiy!

--

___
Python tracker 

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



[issue42837] Symbol table incorrectly identifies code as a generator, when 'yield' occurs in an annotation

2021-01-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Then why not fix the compiler?

As I understand, it is not clear yet what behavior should be, and discussing it 
is the matter of issue42725. Any changes before the decision be made are 
preliminary.

It is very likely that the decision will be in favor of ignoring annotations. 
In that case your PR or even more radical changes can be merged.

--

___
Python tracker 

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



[issue41629] __class__ not set defining 'X' as

2021-01-06 Thread Richard Neumann


Richard Neumann  added the comment:

I just stumbled across this issue trying to resolve this: 
https://bugs.python.org/issue42765?

While this fails:

from typing import NamedTuple


class Spamm(NamedTuple):

foo: int
bar: str

def __getitem__(self, index_or_key):
"""Returns the respective item."""
if isinstance(index_or_key, str):
try:
return getattr(self, index_or_key)
except AttributeError:
raise IndexError(index_or_key) from None

return super().__getitem__(index_or_key)

def keys(self):
return self._fields


def main():

spamm = Spamm(12, 'hello')
print(dir(spamm))
print(spamm._fields)
d = dict(spamm)
print(d)


if __name__ == '__main__':
main()


with

Traceback (most recent call last):
  File "/home/neumann/test.py", line 4, in 
class Spamm(NamedTuple):
RuntimeError: __class__ not set defining 'Spamm' as . 
Was __classcell__ propagated to type.__new__?


The following works:

from typing import NamedTuple


def _getitem(instance, index_or_key):
"""Returns the respective item."""

if isinstance(index_or_key, str):
try:
return getattr(instance, index_or_key)
except AttributeError:
raise IndexError(index_or_key) from None

return super().__getitem__(index_or_key)


def dicttuple(cls: tuple):
"""Extends a tuple class with methods for the dict constructor."""

cls.keys = lambda self: self._fields
cls.__getitem__ = _getitem
return cls


@dicttuple
class Spamm(NamedTuple):

foo: int
bar: str


def main():

spamm = Spamm(12, 'hello')
print(dir(spamm))
print(spamm._fields)
d = dict(spamm)
print(d)


if __name__ == '__main__':
main()


And produces:

['__add__', '__annotations__', '__class__', '__class_getitem__', 
'__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', 
'__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', 
'__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', 
'__lt__', '__module__', '__mul__', '__ne__', '__new__', '__orig_bases__', 
'__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__setattr__', 
'__sizeof__', '__slots__', '__str__', '__subclasshook__', '_asdict', 
'_field_defaults', '_fields', '_make', '_replace', 'bar', 'count', 'foo', 
'index', 'keys']
('foo', 'bar')
{'foo': 12, 'bar': 'hello'}


I am a bit baffled, why it works when the method is injected via a decorator.

--
nosy: +conqp

___
Python tracker 

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



[issue42837] Symbol table incorrectly identifies code as a generator, when 'yield' occurs in an annotation

2021-01-06 Thread Mark Shannon


Mark Shannon  added the comment:

The aim is to change the behavior of the symbol table to match the compiler.
The behavior has already changed at module scope.

Python 3.9.0+
>>> x:(yield None)
  File "", line 1
SyntaxError: 'yield' outside function
>>> 


Python 3.10.0a4+
>>> x:(yield None)
>>>

--

___
Python tracker 

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



[issue42765] Introduce new data model method __iter_items__

2021-01-06 Thread Richard Neumann


Richard Neumann  added the comment:

Okay, I found the solution. Not using super() works:

from typing import NamedTuple


class Spamm(NamedTuple):

foo: int
bar: str

def __getitem__(self, index_or_key):
if isinstance(index_or_key, str):
try:
return getattr(self, index_or_key)
except AttributeError:
raise KeyError(index_or_key) from None

return tuple.__getitem__(self, index_or_key)

def keys(self):
yield 'foo'
yield 'bar'


def main():

spamm = Spamm(12, 'hello')
print(spamm.__getitem__)
print(spamm.__getitem__(1))
d = dict(spamm)
print(d)


if __name__ == '__main__':
main()

Result:


hello
{'foo': 12, 'bar': 'hello'}

--

___
Python tracker 

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



[issue42541] Tkinter colours wrong on MacOS universal2

2021-01-06 Thread E. Paine


E. Paine  added the comment:

This does not appear to be a problem anymore on Tk 8.6.11 so I think this issue 
can be closed.

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

___
Python tracker 

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



[issue42765] Introduce new data model method __iter_items__

2021-01-06 Thread Richard Neumann


Richard Neumann  added the comment:

Thank you all for your input.
I had a look at aforementioned discussion and learned something new.
So I tried to implement the dict data model by implementing keys() and 
__getitem__() accordingly:

from typing import NamedTuple


class Spamm(NamedTuple):

foo: int
bar: str

def __getitem__(self, item):
if isinstance(item, str):
try:
return getattr(self, item)
except AttributeError:
raise KeyError(item) from None

return super().__getitem__(item)

def keys(self):
yield 'foo'
yield 'bar'


def main():

spamm = Spamm(12, 'hello')
print(spamm.__getitem__)
print(spamm.__getitem__(1))
d = dict(spamm)


if __name__ == '__main__':
main()


Unfortunately this will result in an error:

Traceback (most recent call last):
  File "/home/neumann/test.py", line 4, in 
class Spamm(NamedTuple):
RuntimeError: __class__ not set defining 'Spamm' as . 
Was __classcell__ propagated to type.__new__?

Which seems to be caused by the __getitem__ implementation.
I found a corresponding issue here: https://bugs.python.org/issue41629
Can I assume, that this is a pending bug and thusly I cannot implement the 
desired behaviour until a fix?

--

___
Python tracker 

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



[issue39457] Add an autocommit property to sqlite3.Connection with a PEP 249 compliant manual commit mode and migrate

2021-01-06 Thread Marc-Andre Lemburg

Marc-Andre Lemburg  added the comment:

On 05.01.2021 19:04, Géry wrote:
> 
> @lemburg
> 
>> I guess the SQLite driver does not start a new transaction for SELECTs, 
>> since these are usually read-only
> 
> Nor for DDL statements (CREATE, DROP).

Those are definitely changing the database and AFAIK SQLite
does support DDLs in transactions (including rolling them back
if needed).

Looking at the _sqlite code, the module does indeed only start
a transaction for INSERT, UPDATE, DELETE and REPLACE, with
"starting a transaction" meaning that it inserts a "BEGIN"
(or one of the txn isolation alternatives) before the statement:

https://github.com/python/cpython/blob/3.9/Modules/_sqlite/cursor.c#L489

This is also documented:

https://docs.python.org/3/library/sqlite3.html#controlling-transactions

I wonder why the module does not implement this properly, but I also
believe it's too late to change.

I guess what could be done is to add a connection.autocommit,
defaulting to None, meaning "use the pre-3.10 behavior".

If this is set to False, the module could then implement the
correct way of handling transactions, which means:

a) start a new transaction when the connection is opened
b) start a new transaction after .commit() and .rollback()
c) don't start new transactions anywhere else
d) run an implicit .rollback() when the connection closes

The code could even check for "BEGIN", "ROLLBACK" and "COMMIT"
text in the .execute() and issues a warning when connection.autocommit
is set to True or False.

When set to True, the module would set the SQLite autocommit
flag and also issues warnings for the txn statements. .rollback()
would issue an exception and .commit() pass silently.

>> For the same reason, removing the SELECT "optimization" may cause
>> a backwards incompatible change, which can be tricky to identify
>> and cause corruption of data (in this case, data not written to
>> the database, where it previously was written).
> 
> Since DQL statements (SELECT) are read-only, maybe we could keep the 
> optimization and start transactions implicitly only for DDL statements 
> (CREATE, DROP)?

See https://sqlite.org/c3ref/stmt_readonly.html.

SELECT are usually read-only, but not always. Since SQLite does
support UDFs (user defined functions), it is possible that a call
to such a function does change the database.

--

___
Python tracker 

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



[issue42837] Symbol table incorrectly identifies code as a generator, when 'yield' occurs in an annotation

2021-01-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Does not it change the current behavior? I do not see a difference with 
issue42725.

>>> def f():
... x: (yield)
... 
>>> f()


--

___
Python tracker 

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



[issue42837] Symbol table incorrectly identifies code as a generator, when 'yield' occurs in an annotation

2021-01-06 Thread Mark Shannon


Change by Mark Shannon :


--
keywords: +patch
pull_requests: +22967
stage: resolved -> patch review
pull_request: https://github.com/python/cpython/pull/24138

___
Python tracker 

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



[issue42725] PEP 563: Should the behavior change for yield/yield from's

2021-01-06 Thread Mark Shannon


Mark Shannon  added the comment:

I've also opened #42837 which is about fixing the symbol table, so that it is 
correct w.r.t. to current behavior.

I'd like to fix it ASAP as the compiler should be able to rely on the symbol 
table being correct.

Of course, once we have decided what the behavior should be, then it may need 
to be updated again.

I'm inclined to agree that 'yield' in an annotation should probably be a syntax 
error, but I haven't put much thought into to.

--
nosy: +Mark.Shannon

___
Python tracker 

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



  1   2   >