[issue45826] unittest.assertRaisesRegex is broken in Python 3.11 and leading to crashing if tested regex does not match name.

2021-11-16 Thread Dennis Sweeney


Change by Dennis Sweeney :


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

___
Python tracker 

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



[issue45429] [Windows] time.sleep() should use CREATE_WAITABLE_TIMER_HIGH_RESOLUTION

2021-11-16 Thread Dong-hee Na


Change by Dong-hee Na :


--
pull_requests: +27832
pull_request: https://github.com/python/cpython/pull/29589

___
Python tracker 

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



[issue45827] Unittest - commenting passing tests cause previous failing tests to pass

2021-11-16 Thread Guido van Rossum


Change by Guido van Rossum :


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



[issue45826] unittest.assertRaisesRegex is broken in Python 3.11 and leading to crashing if tested regex does not match name.

2021-11-16 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

Even shorter reproducer:

-
try:
aab
except BaseException as E:
E.with_traceback(None)
raise ZeroDivisionError()
-


Bisection points to the initial implementation of suggestions.c:

5bf8bf2267cd109970b2d946d43b2e9f71379ba2 is the first bad commit
commit 5bf8bf2267cd109970b2d946d43b2e9f71379ba2
Author: Pablo Galindo 
Date:   Wed Apr 14 15:10:33 2021 +0100

bpo-38530: Offer suggestions on NameError (GH-25397)

When printing NameError raised by the interpreter, PyErr_Display
will offer suggestions of simmilar variable names in the function that the 
exception
was raised from:

>>> schwarzschild_black_hole = None
>>> schwarschild_black_hole
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'schwarschild_black_hole' is not defined. Did you mean: 
schwarzschild_black_hole?

--

___
Python tracker 

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



[issue38625] SpooledTemporaryFile does not seek correctly after being rolled over

2021-11-16 Thread Inada Naoki


Inada Naoki  added the comment:

The another error I found is already reported as #42868.

--

___
Python tracker 

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



[issue45826] unittest.assertRaisesRegex is broken in Python 3.11 and leading to crashing if tested regex does not match name.

2021-11-16 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

Here's shorter reproducer not involving unittest:


import sys

try:
aab
except:
exc_type, exc_value, tb = sys.exc_info()
exc_value.with_traceback(None)
raise ZeroDivisionError()

--

___
Python tracker 

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



[issue45827] Unittest - commenting passing tests cause previous failing tests to pass

2021-11-16 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

At a quick glance, I am 95% sure the problem lies in these two snippets of your 
code, not unittest:

class My_Time:
months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]


if is_leapyr(year):
my_time.months[1] = 29


The first snippet makes months, a mutable list, a class attribute, which means 
it is shared by all instances of the class. The second snippet mutates that 
list, which means every single instance will see the same value.

So commenting out some tests will change whether or not the shared list gets 
mutated, which will change whether or not other tests pass or fail.

I think the smallest change you need make to fix your code is to put the 
initialisation of My_Time into an `__init__` method, so that the attributes 
(including the list) are no longer shared between all instances.

class My_Time:
def __init__(self):
...

--
nosy: +steven.daprano

___
Python tracker 

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



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

2021-11-16 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

This seems to be similar to https://bugs.python.org/issue41768 .

--
nosy: +xtreak

___
Python tracker 

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



[issue45826] unittest.assertRaisesRegex is broken in Python 3.11 and leading to crashing if tested regex does not match name.

2021-11-16 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

I got a segfault in a similar location:

static PyObject *
offer_suggestions_for_name_error(PyNameErrorObject *exc)
{
PyObject *name = exc->name; // borrowed reference
PyTracebackObject *traceback = (PyTracebackObject *) exc->traceback; // 
borrowed reference
// Abort if we don't have a variable name or we have an invalid one
// or if we don't have a traceback to work with
if (name == NULL || traceback == NULL || !PyUnicode_CheckExact(name)) {
return NULL;
}

// Move to the traceback of the exception
while (traceback->tb_next != NULL) {  <<< segfault: traceback 
is junk (but not null) pointer
traceback = traceback->tb_next;
}
...


Adding ```assert(Py_TYPE(exc) == PyExc_NameError);``` fails, so somehow 
something is getting cast to ```PyNameErrorObject *``` when it shouldn't be.

Here is some debugging code I used that also causes the crash:


--
from unittest import TestCase
from unittest.case import _AssertRaisesContext
import sys
import traceback

manager = _AssertRaisesContext(Exception, TestCase(), 'aaa')

# inline this:
# with manager:
#  aab

try:
aab
except:

# inline __exit__
exc_type, exc_value, tb = sys.exc_info()
traceback.clear_frames(tb)
manager.exception = exc_value.with_traceback(None)
output = '"{}" does not match "{}"'.format(
 manager.expected_regex.pattern, str(exc_value))

# inline manager._raiseFailure(output)
msg = manager.test_case._formatMessage(manager.msg, output)
print("A:", f"{msg=!r}")
e = manager.test_case.failureException(msg)
print("B:", f"{e=!r}")
raise e

# Output:
# A: msg='"aaa" does not match "name \'aab\' is not defined"'
# B: e=AssertionError('"aaa" does not match "name \'aab\' is not defined"')
---

--
nosy: +Dennis Sweeney

___
Python tracker 

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



[issue45826] unittest.assertRaisesRegex is broken in Python 3.11 and leading to crashing if tested regex does not match name.

2021-11-16 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Running it in debug build mode

./python -X dev ../bpo45826.py
python: Python/suggestions.c:215: offer_suggestions_for_name_error: Assertion 
`frame != NULL' failed.
Fatal Python error: Aborted

Current thread 0x7f4c717f3280 (most recent call first):
  
[1]15180 abort (core dumped)  ./python -X dev ../bpo45826.py

--
nosy: +pablogsal, xtreak

___
Python tracker 

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



[issue45827] Unittest - commenting passing tests cause previous failing tests to pass

2021-11-16 Thread Jamie Chaisson


New submission from Jamie Chaisson :

Ubuntu Release 20.04.3 LTS (Focal Fossa) 64-bit
Using unittest, testing with assertEqual on int values and known good output. 
Unittest produces one-off error on handful of edge-case tests causing assert to 
fail. Commenting out passing assertEquals tests to isolate failing tests causes 
previous failing tests to pass (reproducible). All input values produce output 
values when testing by hand, only different when using unittest.

Pardon the homework. Removing the class and moving member variables into 
my_datetime function resolves the issue; however, the behavior as written 
should not be happening.

--
components: Tests
files: tests.py
messages: 406449
nosy: nuse
priority: normal
severity: normal
status: open
title: Unittest - commenting passing tests cause previous failing tests to pass
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file50446/tests.py

___
Python tracker 

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



[issue38625] SpooledTemporaryFile does not seek correctly after being rolled over

2021-11-16 Thread Inada Naoki


Change by Inada Naoki :


--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed
versions: +Python 3.8, Python 3.9

___
Python tracker 

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



[issue38625] SpooledTemporaryFile does not seek correctly after being rolled over

2021-11-16 Thread Inada Naoki


Inada Naoki  added the comment:

I confirmed that this bug is fixed, but I found another error.

--

___
Python tracker 

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



[issue41735] Thread locks in zlib module may go wrong in rare case

2021-11-16 Thread Ma Lin


Ma Lin  added the comment:

Sorry, I found an omission.

The previous PRs fixed the bug in these methods:

zlib.Compress.compress()
zlib.Decompress.decompress()

This method also has this bug, fix in PR29587 (main/3.10) and PR29588 (3.9-):

zlib.Decompress.flush()

Attached file `test_flush.py` can reliably reproduce the bug.

This time I carefully checked bz2/lzma/zlib modules, it should be no problem 
anymore.

Gregory P. Smith should understand these codes, add him to nosy list.

--
nosy: +gregory.p.smith
resolution: fixed -> later
status: closed -> open
Added file: https://bugs.python.org/file50445/test_flush.py

___
Python tracker 

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



[issue38625] SpooledTemporaryFile does not seek correctly after being rolled over

2021-11-16 Thread Inada Naoki


Inada Naoki  added the comment:

Is this bug fixed by #26730?

--

___
Python tracker 

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



[issue41735] Thread locks in zlib module may go wrong in rare case

2021-11-16 Thread Ma Lin


Change by Ma Lin :


--
pull_requests: +27831
pull_request: https://github.com/python/cpython/pull/29588

___
Python tracker 

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



[issue41735] Thread locks in zlib module may go wrong in rare case

2021-11-16 Thread Ma Lin


Change by Ma Lin :


--
pull_requests: +27830
pull_request: https://github.com/python/cpython/pull/29587

___
Python tracker 

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



[issue45826] unittest.assertRaisesRegex is broken in Python 3.11 and leading to crashing if tested regex does not match name.

2021-11-16 Thread Xinmeng Xia


New submission from Xinmeng Xia :

In Python 3.11, unittest.assertRaisesRegex is broken and leading to crashing if 
tested regex does not match name. See the following example:

test.py
=
import unittest

class uTest(unittest.TestCase):
pass

uTest = uTest()

with uTest.assertRaisesRegex(Exception, 'aaa'):
 aab
=


Output in Python3.9.2, 3.10:
--
NameError: name 'aab' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xxm/Desktop/test.py", line 29, in 
aab
  File "/usr/local/python310/lib/python3.10/unittest/case.py", line 239, in 
__exit__
self._raiseFailure('"{}" does not match "{}"'.format(
  File "/usr/local/python310/lib/python3.10/unittest/case.py", line 163, in 
_raiseFailure
raise self.test_case.failureException(msg)
AssertionError: "aaa" does not match "name 'aab' is not defined
--

Actual output in Python3.11.0a1,Python3.11.0a2:
Segmentation fault (core dumped)

System: Ubuntu 16.04

--
components: Library (Lib)
messages: 406445
nosy: xxm
priority: normal
severity: normal
status: open
title: unittest.assertRaisesRegex is broken in Python 3.11 and leading to 
crashing if tested regex does not match name.
type: crash
versions: Python 3.11

___
Python tracker 

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



[issue45760] Remove "PyNumber_InMatrixMultiply"

2021-11-16 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Alternatively, fix the misspelling in the macro and delete the redundant 
expanded code below.

--
nosy: +rhettinger

___
Python tracker 

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



[issue45825] Heap Segmentation Fault

2021-11-16 Thread Bill Borskey


New submission from Bill Borskey :

Dereferencing a python object that does not exist through ctypes caused a 
segfault in pymalloc_alloc. 

rdi: 0x0006  rsi: 0x0006 

0   org.python.python   0x0001081ee277 pymalloc_alloc + 74
1   org.python.python   0x0001081ed3dc _PyObject_Malloc + 17
2   org.python.python   0x000108296a94 normalizestring + 55
3   org.python.python   0x000108296540 _PyCodec_Lookup + 76

Looks like six was passed to the allocator, not sure exactly what was written 
to it, or if I can control that. But I guess it was more than six bytes. I 
don't have the id I used with the debug info above, but: I had a smallish list 
of characters, overwrote it with zeros, called del on it. I checked the value a 
couple times with ctypes. What I think happened is the garbage collector 
finally reclaimed the memory and crashed when I dereferenced again with the bad 
value.

I checked it out using 0xCC to get an idea of where the value was landing, and 
I'm overwriting rbx directly. But it doesn't get as far as above and segfaults 
at O_get rather than the allocator. 

I looked and I see this function:

static PyObject *
O_get(void *ptr, Py_ssize_t size)
{
PyObject *ob = *(PyObject **)ptr;
if (ob == NULL) {
if (!PyErr_Occurred())
/* Set an error if not yet set */
PyErr_SetString(PyExc_ValueError,
"PyObject is NULL");
return NULL;
}
Py_INCREF(ob);
return ob;
}

Seems like the code is increasing the reference count on the non-existing 
python object at 0x and writing out of bounds. 

$ python3 -X dev
Python 3.9.2 (default, Mar 26 2021, 23:27:12) 
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.cast(0x, ctypes.py_object).value
Fatal Python error: Segmentation fault

(below does not have the heap debugger on it seemed to mess with results)

Current thread 0x000104b83dc0 (most recent call first):
  File "", line 1 in 
Segmentation fault: 11

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x00010e1be8c0  rbx: 0x  rcx: 0x00010e2775c9  
rdx: 0x00010e283890
  rdi: 0x00010e1be8c0  rsi: 0x0008  rbp: 0x7ffee20f24e0  
rsp: 0x7ffee20f24d0
   r8: 0x0004   r9: 0x6a2bff3e46d2619c  r10: 0x00010e1d4b80  
r11: 0x00010e1d4bb8
  r12: 0x00010defc5e0  r13: 0x7f94edc5c390  r14: 0x00010e1e1b90  
r15: 0x
  rip: 0x00010e2775d7  rfl: 0x00010286  cr2: 0x00010e2730f3

--
components: ctypes
files: debug.txt
messages: 406443
nosy: thewb
priority: normal
severity: normal
status: open
title: Heap Segmentation Fault
type: crash
versions: Python 3.9
Added file: https://bugs.python.org/file50444/debug.txt

___
Python tracker 

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



Re: Advantages of Default Factory in Dataclasses

2021-11-16 Thread Alan Bawden
David Lowry-Duda  writes:

   ...

   For the same reason that the following code doesn't do what some people 
   might expect it to:

   ```python
   def add_to(elem, inlist=[]):
   inlist.append(elem)
   return inlist

   list1 = add_to(1)
   list2 = add_to(2)
   print(list1)  # prints [1]
   print(list2)  # prints [1, 2], potentially confusing
   ```

Not only does it not print what "most people" expect.  It also doesn't
print what _you_ expect!  (But you made your point.)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Alternatives to Jupyter Notebook

2021-11-16 Thread Martin Schöön
Den 2021-11-15 skrev Loris Bennett :
> Martin Schöön  writes:
>
>> Den 2021-10-20 skrev Shaozhong SHI :
>>>
>>> My Jupyter notebook becomes unresponsive in browsers.
>>>
>> Odd, I never had any problems like that. I use Firefox on Linux.
>>
>>> Are there alternatives to read, edit and run Jupyter Notebook?
>>>
>> I know some people use emacs orgmode. I have never tried it
>> myself and do not know how well it works.
>
> I don't know Jupyter well enough to know whether Org mode is a real
> alternative.  However, with Org mode you can combine text and code in
> multiple languages, run the code within Emacs and then export the
> results in various formats such as PDF and HTML.
>
I realise I was not making myself clear. Orgmode is great. Full stop.

What I don't have experience of is combining orgmode with Jupyter.

/Martin
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: One line sort

2021-11-16 Thread Christian Gollwitzer

Am 15.11.21 um 14:10 schrieb ast:

A curiosity:

q = lambda x: x and q([i for i in x[1:] if i < x[0]]) + [x[0]] + q([i 
for i in x[1:] if i >= x[0]])


 >>> q([7, 5, 9, 0])
[0, 5, 7, 9]


That seems to be a translation of the classic Haskell quicksort example:

qsort [] = []
qsort (x:xs) = qsort [a | a <- xs, a < x]
  ++ [x] ++
   qsort [b | b <- xs, b >= x]


The Haskell version is a bit clearer IMHO due to the pattern matching, 
but that results in a 2 liner :)


Christian
--
https://mail.python.org/mailman/listinfo/python-list


Re: Advantages of Default Factory in Dataclasses

2021-11-16 Thread David Lowry-Duda
On Tue, Nov 16, 2021 at 05:04:05PM +0400, Abdur-Rahmaan Janhangeer wrote:
> A simple question: why do we need field(default_factory ) in 
> dataclasses?

For the same reason that the following code doesn't do what some people 
might expect it to:

```python
def add_to(elem, inlist=[]):
inlist.append(elem)
return inlist

list1 = add_to(1)
list2 = add_to(2)
print(list1)  # prints [1]
print(list2)  # prints [1, 2], potentially confusing
```

Mutable attributes are created once, upon definition. Reusing the same 
function (or instantiating objects of the same class) and modifying this 
attribute can lead to possibly unexpected side effects as above.

- DLD
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue45796] Using tab to cycle through tkinter widgets breaks foreground styling

2021-11-16 Thread Chris Eykamp


Chris Eykamp  added the comment:

Thanks for the clarification.  I don't want to belabor the point, but if you 
observe what happens as you hit tab and cycle through the widgets, the way the 
color changes cannot be intended behavior, and makes no sense from any rational 
UI perspective.  

I do accept that it may not be a Python bug (though I don't really know); I do 
not understand the relationship between Python and Tcl in terms of who is 
responsible for what.  But regardless, I filed a bug report at the URL you 
provided.  I don't know if they accept documentation of problems written in 
Python, and I cannot write the code in Tcl, but we'll find out in a day or two 
(I hope).

Thanks again!

On Tue, Nov 16, 2021, at 13:35, E. Paine wrote:
> E. Paine  added the comment:
>
>> please don't declare this "not a bug" until you've tested it on Windows
>
> Sorry, I didn't explain my reasoning for that resolution. I did test it 
> on Windows, but my trail of though went something like: "unexpected 
> behaviour doesn't necessarily mean it's a bug". You are right, though, 
> and a resolution of "third party" would be more suitable.
>
> --
>
> ___
> Python tracker 
> 
> ___

--

___
Python tracker 

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



[issue45824] CSV module document does not include how to append files

2021-11-16 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

I don't think that is the job of CSV docs.  Appending is a general skill and 
not specific to that module.

Likewise, the CSV module docs don't cover other general file manipulation 
skills like closing, using seek() to rewind, manipulating filenames and paths, 
setting permissions, etc.

The csv.writer docs seem reasonable to me:

"""Return a writer object responsible for converting the user’s data into 
delimited strings on the given file-like object. csvfile can be any object with 
a write() method."""

--
nosy: +rhettinger

___
Python tracker 

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



[issue45824] CSV module document does not include how to append files

2021-11-16 Thread Wesley Altham


Wesley Altham  added the comment:

I now see other things on it but I think the doc should have it as well

--

___
Python tracker 

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



[issue45822] Py_CompileString does not respect the coding cookie with the new parser if flags are empty

2021-11-16 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +27829
pull_request: https://github.com/python/cpython/pull/29586

___
Python tracker 

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



[issue45822] Py_CompileString does not respect the coding cookie with the new parser if flags are empty

2021-11-16 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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



[issue45822] Py_CompileString does not respect the coding cookie with the new parser if flags are empty

2021-11-16 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +27828
pull_request: https://github.com/python/cpython/pull/29585

___
Python tracker 

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



[issue45716] Confusing parsing error message when trying to use True as keyword argument

2021-11-16 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 5618c81e139419b4665dc1f1e8a468738546f542 by Pablo Galindo Salgado 
in branch '3.10':
[3.10] bpo-45716: Improve the error message when using True/False/None as 
keywords in a call (GH-29413). (GH-29428)
https://github.com/python/cpython/commit/5618c81e139419b4665dc1f1e8a468738546f542


--

___
Python tracker 

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



[issue45824] CSV module document does not include how to append files

2021-11-16 Thread Wesley Altham


New submission from Wesley Altham :

easy- The CSV module does not include how to append a file which is using 'a' 
and not 'w' or 'r'. There might be more to appending but it is not documented 
for me to know, I saw a stackoverflow post about it when I looked and I tried 
it and worked. I hope whoever knows the CSV module could document append at all.

--
messages: 406438
nosy: wesrl
priority: normal
severity: normal
status: open
title: CSV module document does not include how to append files
type: enhancement
versions: Python 3.10

___
Python tracker 

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



[issue45789] Python execution broken after update via Windows Store

2021-11-16 Thread firewave


firewave  added the comment:

Today 3.9.2544.0 was automatically installed on my system. Interestingly it did 
not update the broken "python3.9.exe" appexec links. The timestamp is still 
from the last update and the links still point to 3.9.2032.0. All other links 
were updated.

--

___
Python tracker 

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



[issue45819] Avoid releasing the GIL in nonblocking socket operations

2021-11-16 Thread Christian Heimes


Christian Heimes  added the comment:

Do POSIX and Windows APIs guarantee that operations on a nonblocking socket can 
never ever block?

We cannot safely keep the GIL unless you can turn "nonblocking socket 
operations by definition shouldn't block" into "standard guarantees that 
nonblocking socket operations never block".

--
nosy: +christian.heimes

___
Python tracker 

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



[issue45796] Using tab to cycle through tkinter widgets breaks foreground styling

2021-11-16 Thread E. Paine


E. Paine  added the comment:

> please don't declare this "not a bug" until you've tested it on Windows

Sorry, I didn't explain my reasoning for that resolution. I did test it on 
Windows, but my trail of though went something like: "unexpected behaviour 
doesn't necessarily mean it's a bug". You are right, though, and a resolution 
of "third party" would be more suitable.

--

___
Python tracker 

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



[issue28533] Remove asyncore, asynchat and smtpd modules

2021-11-16 Thread STINNER Victor


STINNER Victor  added the comment:

About the PEP 387 process, Brett wrote on python-dev that "the modules got 
yanked prematurely", so I formally requested a SC exception:
https://github.com/python/steering-council/issues/86

--

___
Python tracker 

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



[issue45822] Py_CompileString does not respect the coding cookie with the new parser if flags are empty

2021-11-16 Thread miss-islington


miss-islington  added the comment:


New changeset da20d7401de97b425897d3069f71f77b039eb16f by Pablo Galindo Salgado 
in branch 'main':
bpo-45822: Respect PEP 263's coding cookies in the parser even if flags are not 
provided (GH-29582)
https://github.com/python/cpython/commit/da20d7401de97b425897d3069f71f77b039eb16f


--
nosy: +miss-islington

___
Python tracker 

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



[issue45823] phyton stopped working

2021-11-16 Thread Roxana 7


Roxana 7  added the comment:

i'm using a low end laptop with windows 86x

--

___
Python tracker 

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



[issue45819] Avoid releasing the GIL in nonblocking socket operations

2021-11-16 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

+1 There is almost no upside for the current behavior.

--
nosy: +rhettinger

___
Python tracker 

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



[issue37800] Clean up the documentation on module attributes

2021-11-16 Thread miss-islington

New submission from miss-islington :


New changeset d7e210070f915d8df5fa863ecba8628304ee1ded by Géry Ogam in branch 
'main':
bpo-37800: Clean up importlib documentation for some module attributes 
(GH-10016)
https://github.com/python/cpython/commit/d7e210070f915d8df5fa863ecba8628304ee1ded


--
nosy: +miss-islington

___
Python tracker 

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



[issue45823] phyton stopped working

2021-11-16 Thread Steve Dower


Steve Dower  added the comment:

It's impossible for us to tell what's causing this without much more 
information, but could you first try switching to Python 3.10? Even if we 
figured it out, we wouldn't be fixing 3.7 at this stage.

If 3.10 still crashes, information about your OS, IDE, any packages you've 
installed, and any details you can find in Event Viewer (check the Application 
log) will be needed to track this down.

--

___
Python tracker 

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



[issue45820] Parser can segfault if an error happens before reading any input

2021-11-16 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue45820] Parser can segfault if an error happens before reading any input

2021-11-16 Thread miss-islington


Change by miss-islington :


--
pull_requests: +27827
pull_request: https://github.com/python/cpython/pull/29584

___
Python tracker 

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



Re: Advantages of Default Factory in Dataclasses

2021-11-16 Thread dn via Python-list
On 17/11/2021 02.04, Abdur-Rahmaan Janhangeer wrote:
> A simple question: why do we need field(default_factory ) in dataclasses?
> 
> Why not make that field as an attribute return a function?
> 
> Useful implementation examples / use cases appreciated.


It's an interesting question: We could define a list (or whatever)
within __post_init__()!

Greater minds than mine may care to comment on the theory that something
defined as a dataclasses.field will be allocated as part of the class
constructor, ie lower-cost. Whereas, something defined post-init will
require extra process-time and storage-allocation. (?)

Doesn't it already return a (evaluated) function? Remember: one is not
limited to Python built-in or PSL types. Thus:

def countdown():
return [ 10, 9, 8, 7, ..., "blast-off" ]

...
launch_commentary:list = field( default_factory=countdown )


The use of default-values for mutables is something of a Python
'gotcha'. My use-case is that some wise-soul's decision to do things
this way prevents me from falling into that debugging "slough of despond".
(does such qualify as a "use case"?)
-- 
Regards,
=dn
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue45820] Parser can segfault if an error happens before reading any input

2021-11-16 Thread Pablo Galindo Salgado


New submission from Pablo Galindo Salgado :


New changeset df4ae55e66e34ea8de6a34f0b104871ddaf35d53 by Pablo Galindo Salgado 
in branch 'main':
bpo-45820: Fix a segfault when the parser fails without reading any input 
(GH-29580)
https://github.com/python/cpython/commit/df4ae55e66e34ea8de6a34f0b104871ddaf35d53


--

___
Python tracker 

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



[issue45819] Avoid releasing the GIL in nonblocking socket operations

2021-11-16 Thread Jim Crist-Harif


Change by Jim Crist-Harif :


--
components: +asyncio -C API
nosy: +asvetlov, yselivanov

___
Python tracker 

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



[issue45822] Py_CompileString does not respect the coding cookie with the new parser if flags are empty

2021-11-16 Thread Thomas Wouters

Thomas Wouters  added the comment:

Py_CompileString() in Python 3.9 and later, using the PEG parser, appears to no 
longer honours source encoding cookies. A reduced test case:

#include "Python.h"
#include 

const char *src = (
"# -*- coding: Latin-1 -*-\n"
"'''\xc3'''\n");

int main(int argc, char **argv)
{
Py_Initialize();
PyObject *res = Py_CompileString(src, "some_path", Py_file_input);
if (res) {
fprintf(stderr, "Compile succeeded.\n");
return 0;
} else {
fprintf(stderr, "Compile failed.\n");
PyErr_Print();
return 1;
}
}

Compiling and running the resulting binary with Python 3.8 (or earlier):

% ./encoding_bug
Compile succeeded.

With 3.9 and PYTHONOLDPARSER=1:

% PYTHONOLDPARSER=1 ./encoding_bug
Compile succeeded.

With 3.9 (without the env var) or 3.10:
% ./encoding_bug
Compile failed.
  File "some_path", line 2
'''�'''
 ^
SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xc3 in 
position 0: unexpected end of data

Writing the same bytes to a file and making python3.9 or python3.10 import them 
works fine, as does passing the bytes to compile():

Python 3.10.0+ (heads/3.10-dirty:7bac598819, Nov 16 2021, 20:35:12) [GCC 
8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> b = open('encoding_bug.py', 'rb').read()
>>> b
b"# -*- coding: Latin-1 -*-\n'''\xc3'''\n"
>>> import encoding_bug
>>> encoding_bug.__doc__
'Ã'
>>> co = compile(b, 'some_path', 'exec')
>>> co
 at 0x7f447e1b0c90, file "some_path", line 1>
>>> co.co_consts[0]
'Ã'


It's just Py_CompileString() that fails. I don't understand why, and I do 
believe it's a regression.

--
nosy: +gregory.p.smith

___
Python tracker 

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



[issue45822] Py_CompileString does not respect the coding cookie with the new parser if flags are empty

2021-11-16 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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

___
Python tracker 

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



[issue45823] phyton stopped working

2021-11-16 Thread Roxana 7


New submission from Roxana 7 :

Hello everyone, I try to program a simple calculator for a university project 
but the sotfware always get an error window "phyton stopped working" when i add 
it on a IDE.
I have reinstalled it so many times and it's always the same

--
components: Windows
messages: 406426
nosy: paul.moore, steve.dower, tim.golden, vicentpaul869, zach.ware
priority: normal
severity: normal
status: open
title: phyton stopped working
type: crash
versions: Python 3.7

___
Python tracker 

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



[issue45822] Py_CompileString does not respect the coding cookie with the new parser if flags are empty

2021-11-16 Thread Pablo Galindo Salgado


New submission from Pablo Galindo Salgado :

When executing Py_CompileString with a source string that has a coding cookie, 
this is not respected as with the old parser.

--
components: Parser
messages: 406425
nosy: lys.nikolaou, pablogsal, twouters
priority: normal
severity: normal
status: open
title: Py_CompileString does not respect the coding cookie with the new parser 
if flags are empty
versions: Python 3.10, Python 3.11, Python 3.9

___
Python tracker 

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



[issue45292] Implement PEP 654: Exception Groups

2021-11-16 Thread Irit Katriel


Change by Irit Katriel :


--
pull_requests: +27824
pull_request: https://github.com/python/cpython/pull/29581

___
Python tracker 

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



[issue41260] datetime, date and time: strftime method takes different keyword argument: fmt (pure) or format (C)

2021-11-16 Thread Alex Waygood


Alex Waygood  added the comment:

In addition to `date.strftime` and `time.strftime`, there is also a discrepancy 
in `datetime.fromtimestamp`. In the C implementation, the first parameter is 
called "timestamp"; in the pure-Python implementation, the first parameter is 
called "t".

--

___
Python tracker 

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



[issue45821] Many method parameters in the datetime module are positional-only in the C implementation but positional-or-keyword in the Python implementation

2021-11-16 Thread Alex Waygood


New submission from Alex Waygood :

The following methods have parameters that are positional-only in the C 
implementation of the `datetime` module, but positional-or-keyword in the 
pure-Python implementation:

* tzinfo.tzname
* tzinfo.utcoffset
* tzinfo.dst
* tzinfo.fromutc
* date.fromordinal
* date.fromisoformat
* date.__format__
* date.__le__
* date.__lt__
* date.__ge__
* date.__gt__
* date.__add__
* date.__radd__
* date.__sub__
* date.__reduce_ex__
* time.__le__
* time.__lt__
* time.__ge__
* time.__gt__
* time.fromisoformat
* time.__format__
* timedelta.__add__
* timedelta.__radd__
* timedelta.__sub__
* timedelta.__rsub__
* timedelta.__mul__
* timedelta.__rmul__
* timedelta.__floordiv__
* timedelta.__truediv__
* timedelta.__mod__
* timedelta.__divmod__
* timedelta.__le__
* timedelta.__lt__
* timedelta.__ge__
* timedelta.__gt__
* datetime.utcfromtimestamp
* datetime.fromisoformat
* datetime.strptime
* datetime.__le__
* datetime.__lt__
* datetime.__ge__
* datetime.__gt__

These inconsistencies make it extremely difficult to provide an accurate stub 
for these methods in typeshed.

--
components: Extension Modules, Library (Lib)
messages: 406423
nosy: AlexWaygood, belopolsky, p-ganssle
priority: normal
severity: normal
status: open
title: Many method parameters in the datetime module are positional-only in the 
C implementation but positional-or-keyword in the Python implementation
type: behavior
versions: Python 3.10, Python 3.11, Python 3.9

___
Python tracker 

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



[issue45820] Parser can segfault if an error happens before reading any input

2021-11-16 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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

___
Python tracker 

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



[issue45819] Avoid releasing the GIL in nonblocking socket operations

2021-11-16 Thread Jim Crist-Harif


Change by Jim Crist-Harif :


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

___
Python tracker 

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



[issue45820] Parser can segfault if an error happens before reading any input

2021-11-16 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
components: +Parser
nosy: +lys.nikolaou
versions: +Python 3.10, Python 3.11, Python 3.9

___
Python tracker 

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



[issue45820] Parser can segfault if an error happens before reading any input

2021-11-16 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
nosy: pablogsal
priority: normal
severity: normal
status: open
title: Parser can segfault if an error happens before reading any input

___
Python tracker 

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



[issue45819] Avoid releasing the GIL in nonblocking socket operations

2021-11-16 Thread Jim Crist-Harif


New submission from Jim Crist-Harif :

In https://bugs.python.org/issue7946 an issue with how the current GIL 
interacts with mixing IO and CPU bound work. Quoting this issue:

> when an I/O bound thread executes an I/O call,
> it always releases the GIL.  Since the GIL is released, a CPU bound
> thread is now free to acquire the GIL and run.  However, if the I/O
> call completes immediately (which is common), the I/O bound thread
> immediately stalls upon return from the system call.  To get the GIL
> back, it now has to go through the timeout process to force the
> CPU-bound thread to release the GIL again.

This issue can come up in any application where IO and CPU bound work are mixed 
(we've found it to be a cause of performance issues in https://dask.org for 
example). Fixing the general problem is tricky and likely requires changes to 
the GIL's internals, but in the specific case of mixing asyncio running in one 
thread and CPU work happening in background threads, there may be a simpler fix 
- don't release the GIL if we don't have to.

Asyncio relies on nonblocking socket operations, which by definition shouldn't 
block. As such, releasing the GIL shouldn't be needed for many operations 
(`send`, `recv`, ...) on `socket.socket` objects provided they're in 
nonblocking mode (as suggested in https://bugs.python.org/issue7946#msg99477). 
Likewise, dropping the GIL can be avoided when calling `select` on 
`selectors.BaseSelector` objects with a timeout of 0 (making it a non-blocking 
call).

I've made a patch 
(https://github.com/jcrist/cpython/tree/keep-gil-for-fast-syscalls) with these 
two changes, and run a benchmark (attached) to evaluate the effect of 
background threads with/without the patch. The benchmark starts an asyncio 
server in one process, and a number of clients in a separate process. A number 
of background threads that just spin are started in the server process 
(configurable by the `-t` flag, defaults to 0), then the server is loaded to 
measure the RPS.

Here are the results:

```
# Main branch
$ python bench.py -c1 -t0
Benchmark: clients = 1, msg-size = 100, background-threads = 0
16324.2 RPS
$ python bench.py -c1 -t1
Benchmark: clients = 1, msg-size = 100, background-threads = 1
Spinner spun 1.52e+07 cycles/second
97.6 RPS
$ python bench.py -c2 -t0
Benchmark: clients = 2, msg-size = 100, background-threads = 0
31308.0 RPS
$ python bench.py -c2 -t1
Benchmark: clients = 2, msg-size = 100, background-threads = 1
Spinner spun 1.52e+07 cycles/second
96.2 RPS
$ python bench.py -c10 -t0
Benchmark: clients = 10, msg-size = 100, background-threads = 0
47169.6 RPS
$ python bench.py -c10 -t1
Benchmark: clients = 10, msg-size = 100, background-threads = 1
Spinner spun 1.54e+07 cycles/second
95.4 RPS

# With this patch
$ ./python bench.py -c1 -t0
Benchmark: clients = 1, msg-size = 100, background-threads = 0
18201.8 RPS
$ ./python bench.py -c1 -t1
Benchmark: clients = 1, msg-size = 100, background-threads = 1
Spinner spun 9.03e+06 cycles/second
194.6 RPS
$ ./python bench.py -c2 -t0
Benchmark: clients = 2, msg-size = 100, background-threads = 0
34151.8 RPS
$ ./python bench.py -c2 -t1
Benchmark: clients = 2, msg-size = 100, background-threads = 1
Spinner spun 8.72e+06 cycles/second
729.6 RPS
$ ./python bench.py -c10 -t0
Benchmark: clients = 10, msg-size = 100, background-threads = 0
53666.6 RPS
$ ./python bench.py -c10 -t1
Benchmark: clients = 10, msg-size = 100, background-threads = 1
Spinner spun 5e+06 cycles/second
21838.2 RPS
```

A few comments on the results:

- On the main branch, any GIL contention sharply decreases the number of RPS an 
asyncio server can handle, regardless of the number of clients. This makes 
sense - any socket operation will release the GIL, and the server thread will 
have to wait to reacquire it (up to the switch interval), rinse and repeat. So 
if every request requires 1 recv and 1 send, a server with background GIL 
contention is stuck at a max of `1 / (2 * switchinterval)` or 200 RPS with 
default configuration. This effectively prioritizes the background thread over 
the IO thread, since the IO thread releases the GIL very frequently and the 
background thread never does.

- With the patch, we still see a performance degradation, but the degradation 
is less severe and improves with the number of clients. This is because with 
these changes the asyncio thread only releases the GIL when doing a blocking 
poll for new IO events (or when the switch interval is hit). With low load (1 
client), the IO thread becomes idle more frequently and releases the GIL. Under 
higher load though the event loop frequently still has work to do at the end of 
a cycle and issues a `selector.select` call with a 0 timeout (nonblocking), 
avoiding releasing the GIL at all during that loop (note the nonlinear effect 
of adding more clients). Since the IO thread still releases the GIL sometimes, 
the background thread still holds the GIL a larger percentage of the time than 
the 

[issue41260] datetime, date and time: strftime method takes different keyword argument: fmt (pure) or format (C)

2021-11-16 Thread Alex Waygood


Change by Alex Waygood :


--
nosy: +AlexWaygood

___
Python tracker 

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



[issue41260] datetime, date and time: strftime method takes different keyword argument: fmt (pure) or format (C)

2021-11-16 Thread Sebastian Rittau


Sebastian Rittau  added the comment:

Ref https://github.com/python/typeshed/pull/6317 for a discussion about this in 
typeshed.

--
nosy: +srittau

___
Python tracker 

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



[issue41260] datetime, date and time: strftime method takes different keyword argument: fmt (pure) or format (C)

2021-11-16 Thread Alex Waygood


Change by Alex Waygood :


--
versions: +Python 3.11, Python 3.9

___
Python tracker 

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



[issue26175] Fully implement IOBase abstract on SpooledTemporaryFile

2021-11-16 Thread Adrian Garcia Badaracco


Change by Adrian Garcia Badaracco :


--
nosy: +adriangb

___
Python tracker 

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



[issue45796] Using tab to cycle through tkinter widgets breaks foreground styling

2021-11-16 Thread Chris Eykamp


Chris Eykamp  added the comment:

The behavior I described is definitely a bug, though it may be (and I suspect 
is) Windows specific.  You may also be right that the problem is upstream, but 
please don't declare this "not a bug" until you've tested it on Windows.

--
nosy: +watusimoto2

___
Python tracker 

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



[issue45126] [sqlite3] cleanup and harden Connection and Cursor __init__

2021-11-16 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

The remaining PR (GH 28234) deprecates reinitialisation. I'm not sure it is a 
good idea to pursue this, so I'm leaning towards closing this as fixed, and 
also closing GH 28234.

--

___
Python tracker 

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



[issue42376] Add helpers to populate modules in C

2021-11-16 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
nosy: +erlendaasland

___
Python tracker 

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



[issue41260] datetime, date and time: strftime method takes different keyword argument: fmt (pure) or format (C)

2021-11-16 Thread Paul Ganssle


Paul Ganssle  added the comment:

Updating this issue to cover the problem in date, time and datetime.

--
title: datetime: strftime method takes different keyword argument: fmt (pure) 
or format (C) -> datetime, date and time: strftime method takes different 
keyword argument: fmt (pure) or format (C)

___
Python tracker 

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



[issue45814] datetime.time.strftime: use the same function signature for C and Python implementations

2021-11-16 Thread Paul Ganssle


Paul Ganssle  added the comment:

I think this is mostly a duplicate of bpo-41260, which has an open PR on it. I 
think that got lost in the shuffle, I'm sad we didn't fix it in Python 3.10. I 
think we should migrate all of these signatures that differ to whichever one 
the C implementation is using (I believe that's 3.11).

I'm going to close that one and edit the other one to cover `time` and `date` 
as well. Thanks for the report Yevhenii!

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> datetime: strftime method takes different keyword argument: fmt 
(pure) or format (C)

___
Python tracker 

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



[issue45116] Performance regression 3.10b1: inlining issue in the big _PyEval_EvalFrameDefault() function with Visual Studio (MSC)

2021-11-16 Thread Guido van Rossum


Guido van Rossum  added the comment:

I'd like to know how to reproduce this. @neonene can you write down the
steps I should do to get the results you get? I have VS 2019, if I need VS
2022 I can install that.

--

___
Python tracker 

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



[issue45103] IDLE: make configdialog font page survive font failures

2021-11-16 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

This has been (supposedly) fixed in tcl/tk 8.6.12, included with all our 
Windows installers starting with 3.9.9.

Thank you for investigating reporting to tcl/tk.  Bugfix list at
https://github.com/tcltk/tk/blob/8baf7d337ca0aab7fafb0e670927ab2c0200e80a/changes#L7869
credits you along with 'vogel': "2021-09-21 (bug)[033886] Win: hang in font 
loading (e-paine,vogel)"
https://sourceforge.net/p/tcl/mailman/message/37380142/
specifically says fixes include "" - Windows loading of the Phaistos font.".

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



[issue45732] Make python.org Windows and macOS installers use Tk 8.6.12

2021-11-16 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Steve, thank you for patching all current versions.  Previous policy has been 
to freeze tcl/tk x.y.z in python x.y because tk x.y.z may include a few 
enhancements among the bug fixes and hence indirectly add new features to 
tkinter in python x.y.z.  However ...

E.Paine's report for this bugfix
"2021-09-21 (bug)[033886] Win: hang in font loading (e-paine,vogel)"
was the result of #45103, based on an IDLE user's SO question about IDLE's 
config dialog hanging.  It turned out that adding a particular font (Phaistos) 
to Windows was the cause, and the fix was to remove it. Ned's link specifically 
 says they fixed " - Windows loading of the Phaistos font.", so I can now close 
our #45103.

Fine with me if we continue to update tcl/tk 8.6.z as possible on Windows as 
well as Mac.  Switching to 8.7, when released, would likely have to wait for 
discussion and a new Python version, which now is never too far away.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue45818] socketserver.BaseRequestHandler inherited class

2021-11-16 Thread Sergey M.


New submission from Sergey M. :

Due to 
```python
try:
self.handle()
finally:
self.finish()
```
construct in `socketserver.BaseRequestHandler.__init__()` method inherited 
classes with `overrided __init__()` method may suffer from incomplete 
initialization.
For example, in the following snippet
```python
def __init__(self, request, client_address, server):
super().__init__(request, client_address, server)
self.foo = 1
```
in some cases all the code after `super()` call will not be executed.

This is a MWE of the server with partially initialized Handler class
```python
from socketserver import UnixStreamServer, StreamRequestHandler, ForkingMixIn


class Handler(StreamRequestHandler):
def __init__(self, request, client_address, server):
super().__init__(request, client_address, server)
self.foo = 1

def handle(self):
print(self.foo)


class ThreadedUnixStreamServer(ForkingMixIn, UnixStreamServer):
pass


with ThreadedUnixStreamServer("/tmp/test.socket", Handler) as server:
server.serve_forever()
```

--
components: Library (Lib)
messages: 406413
nosy: matsievskiysv
priority: normal
severity: normal
status: open
title: socketserver.BaseRequestHandler inherited class
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



[issue45817] Build Windows and macOS installers with Tcl/Tk 8.6.12

2021-11-16 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Thank you for the link.  E.Paine's report for this
2021-09-21 (bug)[033886] Win: hang in font loading (e-paine,vogel)
was the result of #45103, based on an IDLE user's SO question.

--

___
Python tracker 

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



[issue45817] Build Windows and macOS installers with Tcl/Tk 8.6.12

2021-11-16 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
assignee: terry.reedy -> 
resolution:  -> duplicate
superseder:  -> Make python.org Windows and macOS installers use Tk 8.6.12

___
Python tracker 

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



[issue45816] Python does not support standalone MSVC v143 (VS 2022) Build Tools

2021-11-16 Thread theeshallnotknowethme


theeshallnotknowethme  added the comment:

Rephrasing: Python does not support building with standalone MSVC v143 Build 
Tools, which is the version of MS Build Tools under Visual Studio 2022 (version 
17.0). Visual Studio 2022 is the latest stable release of Visual Studio [1].

[1] 
https://devblogs.microsoft.com/visualstudio/visual-studio-2022-now-available/

--
components: +Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware
title: Python does not support building with Visual Studio 2022 -> Python does 
not support standalone MSVC v143 (VS 2022) Build Tools

___
Python tracker 

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



[issue45732] Make python.org Windows and macOS installers use Tk 8.6.12

2021-11-16 Thread Aivar Annamaa


Change by Aivar Annamaa :


--
nosy: +aivarannamaa

___
Python tracker 

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



[issue45817] Build Windows and macOS installers with Tcl/Tk 8.6.12

2021-11-16 Thread Aivar Annamaa


Aivar Annamaa  added the comment:

Sorry, duplicate of #45732

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



[issue45817] Build Windows and macOS installers with Tcl/Tk 8.6.12

2021-11-16 Thread Aivar Annamaa


Change by Aivar Annamaa :


--
type:  -> enhancement

___
Python tracker 

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



[issue45817] Build Windows and macOS installers with Tcl/Tk 8.6.12

2021-11-16 Thread Aivar Annamaa


New submission from Aivar Annamaa :

New version contains several bugfixes: 
https://github.com/tcltk/tk/blob/8baf7d337ca0aab7fafb0e670927ab2c0200e80a/changes#L7869

--
assignee: terry.reedy
components: IDLE, Tkinter, Windows, macOS
messages: 406409
nosy: aivarannamaa, ned.deily, paul.moore, ronaldoussoren, steve.dower, 
terry.reedy, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Build Windows and macOS installers with Tcl/Tk 8.6.12
versions: Python 3.10, Python 3.11

___
Python tracker 

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



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

2021-11-16 Thread Petr Viktorin

Petr Viktorin  added the comment:

Back to this issue -- do we have any use case other than setting the internal 
Py_TPFLAGS_DISALLOW_INSTANTIATION flag?

If not, I'd like to close this (with apologies for not doing my research and 
letting Hai Shi do unmerged work).
If a use case is found, I suspect it'll need a different solution – perhaps 
allowing PyType_Slot·s.

--

___
Python tracker 

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



Re: Advantages of Default Factory in Dataclasses

2021-11-16 Thread Paul Bryan
On Tue, 2021-11-16 at 17:04 +0400, Abdur-Rahmaan Janhangeer wrote:

> A simple question: why do we need field(default_factory ) in
> dataclasses?

To initialize a default value when a new instance of the dataclass is
created. For example, if you want a field to default to a dict. A new
dict is created for each instance of the dataclass created.

> Why not make that field as an attribute return a function?

I do not understand the question.

> Useful implementation examples / use cases appreciated.

Any case where a you want a dataclass field to default to a mutable
value. Examples: dicts, lists, other dataclasses.

Paul

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue45116] Performance regression 3.10b1: inlining issue in the big _PyEval_EvalFrameDefault() function with Visual Studio (MSC)

2021-11-16 Thread Brandt Bucher


Brandt Bucher  added the comment:

Hm. If removing 26 opcodes didn't fix this, then maybe the size of 
_PyEval_EvalFrameDefault isn't really the issue?

--

___
Python tracker 

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



[issue45126] [sqlite3] cleanup and harden Connection and Cursor __init__

2021-11-16 Thread Petr Viktorin


Petr Viktorin  added the comment:


New changeset 9d6215a54c177a5e359c37ecd1c50b594b194f41 by Erlend Egeberg 
Aasland in branch 'main':
bpo-45126: Harden `sqlite3` connection initialisation (GH-28227)
https://github.com/python/cpython/commit/9d6215a54c177a5e359c37ecd1c50b594b194f41


--

___
Python tracker 

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



[issue45816] Python does not support building with Visual Studio 2022

2021-11-16 Thread theeshallnotknowethme


Change by theeshallnotknowethme :


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

___
Python tracker 

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



[issue45816] Python does not support building with Visual Studio 2022

2021-11-16 Thread theeshallnotknowethme


New submission from theeshallnotknowethme :

Python does not support building with Visual Studio 2022, which is the latest 
officially released stable version [1].

[1] 
https://devblogs.microsoft.com/visualstudio/visual-studio-2022-now-available/

--
components: Build
messages: 406405
nosy: February291948
priority: normal
severity: normal
status: open
title: Python does not support building with Visual Studio 2022
versions: Python 3.11

___
Python tracker 

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



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

2021-11-16 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

> Do we need Lib/test/test_sqlite3/__init__.py? Would not tests in package be 
> loaded automatically?

If I remove it, the test suite is not run. Maybe another change is needed for 
autodetection to work better.

--

___
Python tracker 

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



[issue45636] Merge BINARY_*/INPLACE_* into BINARY_OP

2021-11-16 Thread Brandt Bucher


Brandt Bucher  added the comment:


New changeset 6a84d61c55f2e543cf5fa84522d8781a795bba33 by Brandt Bucher in 
branch 'main':
bpo-45636: Simplify BINARY_OP (GH-29565)
https://github.com/python/cpython/commit/6a84d61c55f2e543cf5fa84522d8781a795bba33


--

___
Python tracker 

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



[issue45429] [Windows] time.sleep() should use CREATE_WAITABLE_TIMER_HIGH_RESOLUTION

2021-11-16 Thread Dong-hee Na


Dong-hee Na  added the comment:


New changeset 55868f1a335cd3853938082a5b25cfba66563135 by Dong-hee Na in branch 
'main':
bpo-45429: Support CREATE_WAITABLE_TIMER_HIGH_RESOLUTION if possible (GH-29203)
https://github.com/python/cpython/commit/55868f1a335cd3853938082a5b25cfba66563135


--

___
Python tracker 

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



Advantages of Default Factory in Dataclasses

2021-11-16 Thread Abdur-Rahmaan Janhangeer
Greetings list,

A simple question: why do we need field(default_factory ) in dataclasses?

Why not make that field as an attribute return a function?

Useful implementation examples / use cases appreciated.

Kind Regards,

Abdur-Rahmaan Janhangeer
about  | blog

github 
Mauritius
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue45814] datetime.time.strftime: use the same function signature for C and Python implementations

2021-11-16 Thread Alex Waygood


Change by Alex Waygood :


--
title: Use the same function signature for datetime.time.strftime -> 
datetime.time.strftime: use the same function signature for C and Python 
implementations

___
Python tracker 

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



[issue45792] contextvars.Token has wrong module name in Sphinx's objects.inv

2021-11-16 Thread Andrew Svetlov


Change by Andrew Svetlov :


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



[issue45814] Use the same function signature for datetime.time.strftime

2021-11-16 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +belopolsky, p-ganssle, xtreak

___
Python tracker 

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



[issue45725] test_freeze doesn't clean up after itself

2021-11-16 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

https://github.com/python/cpython/pull/29527 uses a temporary directory for the 
test instead that should help with the cleanup.

--
nosy: +xtreak

___
Python tracker 

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



[issue45512] [sqlite3] simplify "isolation level"

2021-11-16 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
pull_requests: +27820
pull_request: https://github.com/python/cpython/pull/29576

___
Python tracker 

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



[issue45292] Implement PEP 654: Exception Groups

2021-11-16 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:


New changeset 8b06d01507fd708468570eaa43a349828784489a by Irit Katriel in 
branch 'main':
bpo-45292: Use raw strings for regex in tests (GH-29545)
https://github.com/python/cpython/commit/8b06d01507fd708468570eaa43a349828784489a


--

___
Python tracker 

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



[issue45725] test_freeze doesn't clean up after itself

2021-11-16 Thread Mark Shannon


Mark Shannon  added the comment:

test_tools also seems to fail a lot unless `make clean` is run first.
Possibly related?

--

___
Python tracker 

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



[issue45753] Further speed up Python-to-Python calls.

2021-11-16 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +27819
pull_request: https://github.com/python/cpython/pull/29575

___
Python tracker 

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



[issue45812] SystemError when using code.interact

2021-11-16 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

In that case don't worry. I prefer that you report potential bugs without 
waiting if that's ok with you, my comment was just in case you are familiar 
with compiling from the CPython repo.

Thanks for all the help!

--

___
Python tracker 

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



[issue45753] Further speed up Python-to-Python calls.

2021-11-16 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset b9310773756f40f77e075f221a90dd41e6964efc by Mark Shannon in 
branch 'main':
bpo-45753: Make recursion checks more efficient. (GH-29524)
https://github.com/python/cpython/commit/b9310773756f40f77e075f221a90dd41e6964efc


--

___
Python tracker 

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



[issue45815] Document exceptions raised by fnmtach

2021-11-16 Thread Dimitri Papadopoulos Orfanos


New submission from Dimitri Papadopoulos Orfanos :

The fnmatch documentation should explicitly mention the type of exceptions 
raised by fnmatch.fnmatch():
https://docs.python.org/3/library/fnmatch.html

In my case it raised sre_constants.error, and it took some time to understand 
that the proper way to catch this type of exceptions is to catch the re.error 
superclass, by reading https://bugs.python.org/issue795379.

Actually that would be the case for any module using the re module under the 
hood, possibly passing an ill-formed regex to a re function.

--
assignee: docs@python
components: Documentation, Library (Lib), Regular Expressions
files: sre_constants.error_stderr.txt
messages: 406396
nosy: DimitriPapadopoulosOrfanos, docs@python, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: Document exceptions raised by fnmtach
versions: Python 3.11
Added file: https://bugs.python.org/file50442/sre_constants.error_stderr.txt

___
Python tracker 

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



[issue45814] Use the same function signature for datetime.time.strftime

2021-11-16 Thread Yevhenii Hyzyla


Change by Yevhenii Hyzyla :


--
title: Use same function signature for datetime.time.strftime -> Use the same 
function signature for datetime.time.strftime

___
Python tracker 

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



  1   2   >