[issue41748] HTMLParser: parsing error

2021-01-03 Thread karl

karl  added the comment:

Ezio,

TL,DR: Testing in browsers and adding two tests for this issue. 
   Should I create a PR just for the tests?

https://github.com/python/cpython/blame/63298930fb531ba2bb4f23bc3b915dbf1e17e9e1/Lib/test/test_htmlparser.py#L479-L485


A: comma without spaces
---


Tests for browsers:
data:text/html,text

Serializations:
* Firefox, Gecko (86.0a1 (2020-12-28) (64-bit)) 
* Edge, Blink (Version 89.0.752.0 (Version officielle) Canary (64 bits))
* Safari, WebKit (Release 117 (Safari 14.1, WebKit 16611.1.7.2))

Same serialization in these 3 rendering engines
text


Adding:

def test_comma_between_unquoted_attributes(self):
# bpo 41748
self._run_check('',
[('starttag', 'div', [('class', 'bar,baz=asd')])])


❯ ./python.exe -m test -v test_htmlparser

…
test_comma_between_unquoted_attributes 
(test.test_htmlparser.HTMLParserTestCase) ... ok
…

Ran 47 tests in 0.168s

OK

== Tests result: SUCCESS ==

1 test OK.

Total duration: 369 ms
Tests result: SUCCESS


So this is working as expected for the first test.


B: comma with spaces


Tests for browsers:
data:text/html,text

Serializations:
* Firefox, Gecko (86.0a1 (2020-12-28) (64-bit)) 
* Edge, Blink (Version 89.0.752.0 (Version officielle) Canary (64 bits))
* Safari, WebKit (Release 117 (Safari 14.1, WebKit 16611.1.7.2))

Same serialization in these 3 rendering engines
text


Adding
def test_comma_with_space_between_unquoted_attributes(self):
# bpo 41748
self._run_check('',
[('starttag', 'div', [
('class', 'bar'),
(',baz', 'asd')])])


❯ ./python.exe -m test -v test_htmlparser


This is failing.

==
FAIL: test_comma_with_space_between_unquoted_attributes 
(test.test_htmlparser.HTMLParserTestCase)
--
Traceback (most recent call last):
  File "/Users/karl/code/cpython/Lib/test/test_htmlparser.py", line 493, in 
test_comma_with_space_between_unquoted_attributes
self._run_check('',
  File "/Users/karl/code/cpython/Lib/test/test_htmlparser.py", line 95, in 
_run_check
self.fail("received events did not match expected events" +
AssertionError: received events did not match expected events
Source:
''
Expected:
[('starttag', 'div', [('class', 'bar'), (',baz', 'asd')])]
Received:
[('data', '')]

--


I started to look into the code of parser.py which I'm not familiar (yet) with.

https://github.com/python/cpython/blob/63298930fb531ba2bb4f23bc3b915dbf1e17e9e1/Lib/html/parser.py#L42-L52

Do you have a suggestion to fix it?

--
nosy: +karlcow

___
Python tracker 

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



[issue41748] HTMLParser: comma in attribute values with/without space

2021-01-03 Thread karl


Change by karl :


--
title: HTMLParser: parsing error -> HTMLParser: comma in attribute values 
with/without space

___
Python tracker 

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



[issue42813] Extra spaces cause unexpected EOF error in "compile" function with mode "single"

2021-01-03 Thread Xinmeng Xia


New submission from Xinmeng Xia :

Running the following program will lead to an unexpected EOF error. If we 
delete the space before  triple-quotation mark("""), the error will gone. If we 
replace the content of snippet with "a = 1", the program will work well. 
However, if we replace the content of snippet with "if a:pass" in a single 
line, the program cause an error again. This is weird. 

Spaces in the end of a statement should not affect the compilation of program 
in "single" mode. Besides, the error messages are different in Python2 and 
Python3. Indentation error are reported in Python 2 for snippet" if a:pass" 
while SyntaxError are reported in Python 3. 
  
==
import math
def check_stack_size( code):
# To assert that the alleged stack size is not O(N), we
# check that it is smaller than log(N).
if isinstance(code, str):
code = compile(code, "", "single")
max_size = math.ceil(math.log(len(code.co_code)))
# self.assertLessEqual(code.co_stacksize, max_size)

def test_if_else():
snippet ="""
if x:
a
elif y:
b
else:
c 
"""
check_stack_size(snippet)

test_if_else()
=
Behavior in Python 3.10:
Traceback (most recent call last):
  File "/home/xxm/Desktop/nameChanging/report/temp.py", line 30, in 
test_if_else()
  File "/home/xxm/Desktop/nameChanging/report/temp.py", line 20, in test_if_else
check_stack_size(snippet)
  File "/home/xxm/Desktop/nameChanging/report/temp.py", line 6, in 
check_stack_size
code = compile(code, "", "single")
  File "", line 8

SyntaxError: unexpected EOF while parsing

Behaviors in Python2: 
Traceback (most recent call last):
  File "/home/xxm/Desktop/nameChanging/report/temp.py", line 30, in 
test_if_else()
  File "/home/xxm/Desktop/nameChanging/report/temp.py", line 27, in test_if_else
check_stack_size(snippet)
  File "/home/xxm/Desktop/nameChanging/report/temp.py", line 6, in 
check_stack_size
code = compile(code, "", "single")
  File "", line 3

^
IndentationError: unexpected indent

--
components: Interpreter Core
messages: 384257
nosy: xxm
priority: normal
severity: normal
status: open
title: Extra spaces cause unexpected EOF error in "compile" function with mode 
"single"
type: compile error
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



[issue41748] HTMLParser: comma in attribute values with/without space

2021-01-03 Thread karl


karl  added the comment:

Ah!

This is fixing it

diff --git a/Lib/html/parser.py b/Lib/html/parser.py
index 6083077981..790666 100644
--- a/Lib/html/parser.py
+++ b/Lib/html/parser.py
@@ -44,7 +44,7 @@
   (?:\s*=+\s*# value indicator
 (?:'[^']*'   # LITA-enclosed value
   |"[^"]*"   # LIT-enclosed value
-  |(?!['"])[^>\s]*   # bare value
+  |(?!['"])[^>]*   # bare value
  )
  (?:\s*,)*   # possibly followed by a comma
)?(?:\s|/(?!>))*




Ran 48 tests in 0.175s

OK

== Tests result: SUCCESS ==

--

___
Python tracker 

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



[issue41748] HTMLParser: comma in attribute values with/without space

2021-01-03 Thread Ezio Melotti


Ezio Melotti  added the comment:

Writing tests that verify the expected behavior is a great first step. The 
expected output in the tests should match the behavior described by the HTML 5 
specs (which should also correspond to the browsers' behavior), and should 
initially fail. You can start creating a PR with only the tests, clarifying 
that it's a work in progress, or wait until you have the fix too.

The next step would be tweaking the regex and the code until both the new tests 
and all the other ones work (excluding the one with the commas you are fixing). 
 You can then commit the fix in the same branch and push it -- GitHub will 
automatically update the PR.


> Do you have a suggestion to fix it?

If you are familiar enough with regexes, you could try to figure out whether it 
matches the invalid attributes or not, and if not why (I took a quick look and 
I didn't see anything immediately wrong in the regexes).

Since the output of the failing test is [('data', '')], 
it's likely that the parser doesn't know how to handle it and passes it to one 
of the handle_data() in the goahead() method.  You can figure out which one is 
being called and see which are the if-conditions that are leading the 
interpreter down this path rather than the usual path where the attributes are 
parsed correctly.

If you have other questions let me know :)

--
type: crash -> behavior

___
Python tracker 

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



[issue41748] HTMLParser: comma in attribute values with/without space

2021-01-03 Thread karl


Change by karl :


--
keywords: +patch
pull_requests: +22904
stage: test needed -> patch review
pull_request: https://github.com/python/cpython/pull/24072

___
Python tracker 

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



[issue42789] Do not skip test_curses on non-tty

2021-01-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I guess I should merge a PR for issue42681 first.

--

___
Python tracker 

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



[issue42814] Undefined behavior in Objects/genericaliasobject.c

2021-01-03 Thread Zackery Spytz


New submission from Zackery Spytz :

In is_typing_name(), va_end() is not always called before the function returns. 
 It is undefined behavior to call va_start() without also calling va_end().

--
components: Interpreter Core
messages: 384261
nosy: ZackerySpytz
priority: normal
severity: normal
status: open
title: Undefined behavior in Objects/genericaliasobject.c
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



[issue42814] Undefined behavior in Objects/genericaliasobject.c

2021-01-03 Thread Zackery Spytz


Change by Zackery Spytz :


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

___
Python tracker 

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



[issue42815] new thread doesn't copy context of the parent thread

2021-01-03 Thread Yurii Karabas


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

New thread doesn't copy context of the parent thread.

The minimal example to reproduce the issue:
```
from threading import Thread
from contextvars import ContextVar

foo: ContextVar[str] = ContextVar("foo")


def temp():
print(foo.get())


foo.set("bar")

t = Thread(target=temp)
t.start()
t.join()
```

Is it expected behavior?

PEP 567 I didn't find anything regarding this case.

--
components: Library (Lib)
messages: 384262
nosy: uriyyo
priority: normal
severity: normal
status: open
title: new thread doesn't copy context of the parent thread
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



[issue42815] new thread doesn't copy context of the parent thread

2021-01-03 Thread Yurii Karabas


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


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

___
Python tracker 

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



[issue42455] Add decorator_factory function to functools module

2021-01-03 Thread Yurii Karabas


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

What we should do with this issue?

There was no much discussion at python-ideas.

I have received only one -1 opinion.

--

___
Python tracker 

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



[issue38946] IDLE on macOS 10.15 Catalina does not open double-clicked files if app already launched

2021-01-03 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

As another datapoint: This works for me on macOS 11.1 with the universal2 
installer for Python 3.9.1 (which includes Tk 8.6.10).

--

___
Python tracker 

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



[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Yurii Karabas


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

The purpose of `@overload` is quite different. I believe you thought that this 
is smth like `@override` in Java world but it different.

Basically, the correct usage of `@overaload` is:
```
@overload
def process(response: None) -> None:
...
@overload
def process(response: int) -> tuple[int, str]:
...
@overload
def process(response: bytes) -> str:
...
def process(response):

```

Please, follow this link for more information 
https://docs.python.org/3/library/typing.html#typing.overload

--
nosy: +uriyyo

___
Python tracker 

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



[issue42815] new thread doesn't copy context of the parent thread

2021-01-03 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +yselivanov

___
Python tracker 

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



[issue42814] Undefined behavior in Objects/genericaliasobject.c

2021-01-03 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 5d3553b0a8959e7505bbec4de03077dbf135ee4b by Zackery Spytz in 
branch 'master':
bpo-42814: Fix undefined behavior in Objects/genericaliasobject.c (GH-24073)
https://github.com/python/cpython/commit/5d3553b0a8959e7505bbec4de03077dbf135ee4b


--
nosy: +vstinner

___
Python tracker 

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



[issue42814] Undefined behavior in Objects/genericaliasobject.c

2021-01-03 Thread STINNER Victor


STINNER Victor  added the comment:

Thanks for the fix!

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



[issue38308] Add optional weighting to statistics.harmonic_mean()

2021-01-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 66136768615472a8d1a18b5018095b9737dbab8c by Zackery Spytz in 
branch 'master':
bpo-38308: Fix the "versionchanged" for the *weights* of harmonic_mean() 
(GH-23919)
https://github.com/python/cpython/commit/66136768615472a8d1a18b5018095b9737dbab8c


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue42455] Add decorator_factory function to functools module

2021-01-03 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

I also agree with Raymond's opinion, and from the point that it didn't get much 
attention I'd assume not many people need it. So count me as -1

--
nosy: +BTaskaya

___
Python tracker 

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



[issue42816] Add str.split_iter function

2021-01-03 Thread Martin Winks


New submission from Martin Winks :

Split string by given separator and return iterator as a result.

The naive and not very efficient solution would be using current str.split:

def split_iter(self: str, sep: str) -> 'Iterator[str]':
return iter(self.split(sep))

Probably, need we'll some better solution without allocating new list.

--
components: Unicode
messages: 384270
nosy: ezio.melotti, uwinx, vstinner
priority: normal
severity: normal
status: open
title: Add str.split_iter function
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



[issue40077] Convert static types to heap types: use PyType_FromSpec()

2021-01-03 Thread Petr Viktorin


Petr Viktorin  added the comment:


New changeset b8eb3765908c0063f0739595ba4b296cc8863d19 by Erlend Egeberg 
Aasland in branch 'master':
bpo-40077: Add traverse/clear/free to arraymodule (GH-24066)
https://github.com/python/cpython/commit/b8eb3765908c0063f0739595ba4b296cc8863d19


--

___
Python tracker 

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



[issue40077] Convert static types to heap types: use PyType_FromSpec()

2021-01-03 Thread Petr Viktorin


Petr Viktorin  added the comment:

Yes, please keep _testcapimodule.c as it is. Static types are still supported 
and need to be tested.

--

___
Python tracker 

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



[issue42817] timedelta zeropadding hh

2021-01-03 Thread Kevin Rasmussen


New submission from Kevin Rasmussen :

It looks like hh should be zeropadded to 2 and isn't for timedelta.

--
messages: 384273
nosy: krasmussen
priority: normal
severity: normal
status: open
title: timedelta zeropadding hh
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



[issue42817] timedelta zeropadding hh

2021-01-03 Thread Kevin Rasmussen


Change by Kevin Rasmussen :


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

___
Python tracker 

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



[issue42816] Add str.split_iter function

2021-01-03 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

I am pretty sure this has been discussed and rejected on the Python-Ideas 
mailing list before.

If not rejected, the idea didn't go very far. You may wish to search the 
mailing list archives for previous discussions.

Either way, I think this should be discussed on Python-Ideas, to see if there 
is a consensus on this, and whether or not this is a large enough change that 
it needs a PEP.

--
nosy: +steven.daprano

___
Python tracker 

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



[issue42816] Add str.split_iter function

2021-01-03 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

See also discussion here: #17343

--

___
Python tracker 

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



[issue42816] Add str.split_iter function

2021-01-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Issue17343 mentions also a separate method str.itersplit, so I close this issue 
as a duplicate.

--
nosy: +serhiy.storchaka
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Add a version of str.split which returns an iterator

___
Python tracker 

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



[issue42817] timedelta zeropadding hh

2021-01-03 Thread Kevin Rasmussen


Kevin Rasmussen  added the comment:

Current behaviour:

```
# python
Python 3.9.1 (default, Dec 18 2020, 05:16:04) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> td = datetime.timedelta(hours=3)
>>> str(td)
'3:00:00'
>>> dt = datetime.datetime.strptime(str(td), "%H:%M:%S")
>>> dt.strftime("%H:%M:%S")
'03:00:00'
>>> 
```

Expected behaviour:

```
# python
Python 3.9.1 (default, Dec 18 2020, 05:16:04) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> td = datetime.timedelta(hours=3)
>>> str(td)
'03:00:00'
>>> dt = datetime.datetime.strptime(str(td), "%H:%M:%S")
>>> dt.strftime("%H:%M:%S")
'03:00:00'
>>> 
```

--

___
Python tracker 

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



[issue42817] timedelta zeropadding hh

2021-01-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Why should it be zeropadded to 2?

It is likely this option was considered when that code was added, and rejected.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue42818] AttributeError: 'zipimporter' object has no attribute 'find_spec'

2021-01-03 Thread Klaus Ethgen


New submission from Klaus Ethgen :

I encountered the bug when installing a package with `python3 setup.py install 
--user`. After that, a second installation failed with this stack trace:
```
Traceback (most recent call last):  
  
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2191, 
in _handle_ns   
loader = importer.find_spec(packageName).loader 
  
AttributeError: 'zipimporter' object has no attribute 'find_spec'   
  

During handling of the above exception, another exception occurred: 
  

Traceback (most recent call last):  
  
  File "/home/klaus/devel/upstream/pass-git-helper/setup.py", line 1, in 

 
from setuptools import setup
  
  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 16, in 

  
import setuptools.version   
  
  File "/usr/lib/python3/dist-packages/setuptools/version.py", line 1, in 


import pkg_resources
  
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3239, 
in  
def _initialize_master_working_set():   
  
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3222, 
in _call_aside  
f(*args, **kwargs)  
  
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3264, 
in _initialize_master_working_set   
tuple(  

  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3265, 
in 
dist.activate(replace=False)
  
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2780, 
in activate 
declare_namespace(pkg)  
  
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2279, 
in declare_namespace
_handle_ns(packageName, path_item)  
  
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2196, 
in _handle_ns   
loader = importer.find_spec(packageName)
  
AttributeError: 'zipimporter' object has no attribute 'find_spec'
```

This error happens now also with different tools.

Solution is to `rm -fr ~/.local/lib`. But the next installation triggers the 
bug again.

The only solution is to install via `python3 setup.py install --user 
--old-and-unmanageable`.

When I look into the code of zipimport(er), I do not see any find_spec only the 
old find_loader.

Despite it is a core library, this must be fixed! And with that the name should 
match the name of the py file to make it able to find the relevant file.

--
components: Library (Lib)
messages: 384279
nosy: mowgli
priority: normal
severity: normal
status: open
title: Att

[issue42789] Do not skip test_curses on non-tty

2021-01-03 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +22910
pull_request: https://github.com/python/cpython/pull/24076

___
Python tracker 

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



[issue17343] Add a version of str.split which returns an iterator

2021-01-03 Thread Martin Winks


Martin Winks  added the comment:

> Perhaps the use case is already served by re.finditer()

def split_whitespace_ascii(s: str):
return (pt.group(0) for pt in re.finditer(r"[A-Za-z']+", s))

solution above does not cover all possible data and is incorrect for bytes-like 
objects.

writing regular expressions for different separators/data would be a quite 
overheadish, so the idea of one-case solution doesn't seem to go very far and 
requires a bigger change in code for different separators.

let's try to revive this one :)

--
nosy: +uwinx

___
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-03 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 7c83eaa536d2f436ae46211ca48692f576c732f0 by Hai Shi in branch 
'master':
bpo-41798: pyexpat: Allocate the expat_CAPI on the heap memory (GH-24061)
https://github.com/python/cpython/commit/7c83eaa536d2f436ae46211ca48692f576c732f0


--

___
Python tracker 

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



[issue42817] timedelta zeropadding hh

2021-01-03 Thread Kevin Rasmussen


Kevin Rasmussen  added the comment:

Question:
Why should it be zeropadded to 2?

Answer:
Why wouldn't it be zeropadded to match the rest of the library?

Honestly it just seemed like an inconsistency with the rest of the datetime 
module.

It caught me off guard when I went I tried to pull __str__ of a timedelta and 
the padding was different than what I saw elsewhere.

I figured it could potentially be a quick fix if the current behaviour is not 
desired.

I'm curious why that would have been rejected if it was even considered/noticed 
before.

Do you know of any good way to figure out if this was discussed before? So far 
all I have done for searching was a search of issues that were already brought 
up and I didn't find anything at first glance.

--

___
Python tracker 

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



[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Chaim Gewirtz


Chaim Gewirtz  added the comment:

"The purpose of `@overload` is quite different." So, this would overload the 
@overload decorator. Hmmm...

Is there a better way to accomplish this goal? What would you suggest, a new 
decorator?

--

___
Python tracker 

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



[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Chaim Gewirtz


Chaim Gewirtz  added the comment:

To clarify, this is how it's being done now a dozen times in actual production 
code:

class Child(Parent):
@overload foo(a, b): ...
def overload(**kwargs):
return super().foo(**kwargs)

The goal of this proposed enhancement is to remove two extra lines of code per 
Child class.

--

___
Python tracker 

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



[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Yurii Karabas


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

`mypy` will produce an error on such code:

```
class Parent:
def foo(self, **kwargs):
"""Argument names of foo vary depending on the child class."""


class Child(Parent):
@overload
def foo(self, a, b):
pass

def foo(self, **kwargs):
return super().foo(**kwargs)
```

Result
```
temp.py:10: error: Single overload definition, multiple required
temp.py:10: error: Signature of "foo" incompatible with supertype "Parent"
Found 2 errors in 1 file (checked 1 source file)
```

In case if you want to add an overload for method I would recommend to use such 
pattern:
```
class Parent:
def foo(self, **kwargs):
"""Argument names of foo vary depending on the child class."""


class Child(Parent):
@overload
def foo(self, a, b):
pass

@overload
def foo(self, **kwargs):
pass

def foo(self, **kwargs):
return super().foo(**kwargs)
```

So signature of `foo` will still match to parent class signature, but it will 
also have an overloaded variant.

--

___
Python tracker 

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



[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Chaim Gewirtz


Chaim Gewirtz  added the comment:

Interesting. PyCharm has no problem with this code. It also autocompletes the 
argument names for me, which is very useful, especially since there a dozen 
different Child classes.

Isn't "Simple is better than complex", and doesn't "...practicality beat 
purity"?

--

___
Python tracker 

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



[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Yurii Karabas


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

I think the simplest solution in your case is not to use `@overload`, as far as 
I understand you want to override the signature of base method.

This code won't produce any error when used with `mypy`:
```
class Parent:
def foo(**kwargs):
"""Argument names of foo vary depending on the child class."""

class Child(Parent):
def foo(self, a, b):
pass
``

--

___
Python tracker 

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



[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Chaim Gewirtz


Chaim Gewirtz  added the comment:

What is better?

A. Keeping Python as is, with four separate signature declarations (1x Parent, 
2x @overload Child, and 1x actual signature in Child), and a second method call 
overhead at runtime (to satisfy mypy as it exists now).

--or--

B. Simplify Python to allow just two signature declarations and no extra 
overhead? 

--or--

C. Something else? Please specify.

--

___
Python tracker 

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



[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Chaim Gewirtz


Chaim Gewirtz  added the comment:

In your example, does Child foo call Parent foo? Because the intent is to use 
the parent's foo method.

--

___
Python tracker 

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



[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Yurii Karabas


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

> What is better?

Sorry, I can't answer this question.

I am a regular python user and I just tried to help with your issue.

I believe we should wait for someone from core team to answer this question.


> In your example, does Child foo call Parent foo? Because the intent is to use 
> the parent's foo method.

Sorry, I made a mistake, it definitely should call a parent method. A correct 
example will look like this:
```
class Parent:
def foo(self, **kwargs):
"""Argument names of foo vary depending on the child class."""


class Child(Parent):
def foo(self, a, b):
super().foo(a=a, b=b)
```

But, the example above require more code to write, so a better option will be:
```
class Parent:
def foo(self, **kwargs):
"""Argument names of foo vary depending on the child class."""


class Child(Parent):
@overload
def foo(self, a, b):
pass

@overload
def foo(self, **kwargs):
pass

def foo(self, **kwargs):
return super().foo(**kwargs)
```

I am not sure is it the perfect solution to solve your issue.

Let's wait for someone from core team, so we can hear their opinion.

--

___
Python tracker 

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



[issue42817] timedelta zeropadding hh

2021-01-03 Thread Eric V. Smith


Eric V. Smith  added the comment:

I don't think zero padding makes sense. For example:

>>> td = datetime.timedelta(hours=100)
>>> str(td)
'4 days, 4:00:00'

I think '4 days, 04:00:00' would not be very user friendly.

In any event, backward compatibility would prevent us from changing this.

--
nosy: +eric.smith

___
Python tracker 

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



[issue42812] @overload-ing method of parent class without actual implementation

2021-01-03 Thread Chaim Gewirtz


Chaim Gewirtz  added the comment:

Thanks for your perspective.

To summarize here is how my proposed enhancement might look in practice:

class Parent:
def foo(self, **kwargs):
"""Argument names of foo vary depending on the child class."""


class Child(Parent):
@overload
def foo(self, a, b):
pass

--

___
Python tracker 

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



[issue40077] Convert static types to heap types: use PyType_FromSpec()

2021-01-03 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Ok, perhaps we should leave a comment about that? It already has a comment 
about multi-phase init.

What about Modules/_testbuffer.c and the xx-modules?

$ grep -E 'static PyTypeObject .* =' $(find . -name "*.c"|grep -vE 
'(Doc/|Modules/_testcapimodule)') | wc -l
94

$ grep -E 'PyType_Spec .* =' $(find . -name "*.c")|wc -l

(master)cpython.git
95

We're almost halfway there.

--

___
Python tracker 

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



[issue41463] Avoid duplicating jump information from opcode.py in compile.c

2021-01-03 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete, unless you still want to backport?

--
nosy: +iritkatriel
resolution:  -> fixed
status: open -> pending

___
Python tracker 

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



[issue42817] timedelta zeropadding hh

2021-01-03 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

In a date, hours are zero-padded probably because that's a common standard for 
military time dates. But there is no such standard for time periods, therefore 
timedelta don't have to match date display in respect to zero-padding, in my 
opinion.

--
nosy: +andrei.avk

___
Python tracker 

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



[issue42681] mistake in curses documentation

2021-01-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 1470edd6131c29b8a09ce012cdfee3afa269d553 by Serhiy Storchaka in 
branch 'master':
bpo-42681: Fix range checks for color and pair numbers in curses (GH-23874)
https://github.com/python/cpython/commit/1470edd6131c29b8a09ce012cdfee3afa269d553


--

___
Python tracker 

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



[issue42819] readline 8.1 bracketed paste

2021-01-03 Thread Dustin Rodrigues


New submission from Dustin Rodrigues :

Readline 8.1 enables bracketed paste by default. Package managers like Homebrew 
for macOS and distributions like Arch Linux which use the latest version of 
readline (released December 2020) now have new behavior when pasting multiline 
strings into the python REPL. Disabling bracketed paste on 8.1 reverts to the 
expected behavior, and enabling bracketed paste on 8.0 also reproduces the 
behavior. Further information in 
https://github.com/Homebrew/homebrew-core/issues/68193

Example with bracketed paste on:
$ cat in
1+2
3+4
5+6

$ pbcopy < in
$ /usr/local/Cellar/python\@3.9/3.9.1_3/bin/python3
Python 3.9.1 (default, Dec 28 2020, 11:22:14) 
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1+2
3+4
5+6

  File "", line 1
1+2
3+4
5+6


   ^
SyntaxError: multiple statements found while compiling a single statement
>>> 



Example with it off:
$ /usr/local/bin/python3
Python 3.9.1 (v3.9.1:1e5d33e9b9, Dec  7 2020, 12:10:52) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1+2
3
>>> 3+4
7
>>> 5+6
11
>>>

--
messages: 384297
nosy: dtrodrigues
priority: normal
severity: normal
status: open
title: readline 8.1 bracketed paste
type: behavior

___
Python tracker 

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



[issue42789] Do not skip test_curses on non-tty

2021-01-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 0303008ebceb6ac6035cd9722d1393267304171d by Serhiy Storchaka in 
branch '3.9':
[3.9] bpo-42789: Don't skip curses tests on non-tty. (GH-24009) (GH-24076)
https://github.com/python/cpython/commit/0303008ebceb6ac6035cd9722d1393267304171d


--

___
Python tracker 

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



[issue42681] mistake in curses documentation

2021-01-03 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +22911
pull_request: https://github.com/python/cpython/pull/24077

___
Python tracker 

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



[issue42789] Do not skip test_curses on non-tty

2021-01-03 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +22912
pull_request: https://github.com/python/cpython/pull/24078

___
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-03 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
title: mistake in curses documentation -> Incorrect range checks/documentation 
in curses

___
Python tracker 

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



[issue42817] timedelta zeropadding hh

2021-01-03 Thread Kevin Rasmussen


Kevin Rasmussen  added the comment:

Eric makes a pretty good point about how that ends up looking with days 
included and backward compatibility.

Thanks everyone for humouring me and talking me through this one I'm going to 
close the issue as "not a bug".

--
resolution:  -> not a bug
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



[issue42789] Do not skip test_curses on non-tty

2021-01-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 645174abe0d13cce2cb339cc80b095ad484428ea by Serhiy Storchaka in 
branch '3.8':
[3.8] [3.9] bpo-42789: Don't skip curses tests on non-tty. (GH-24009) 
(GH-24076) (GH-24078)
https://github.com/python/cpython/commit/645174abe0d13cce2cb339cc80b095ad484428ea


--

___
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-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset b0ee2b492dbf550fbd2a63b82de0a4dc9d67f32e by Serhiy Storchaka in 
branch '3.9':
[3.9] bpo-42681: Fix range checks for color and pair numbers in curses 
(GH-23874). (GH-24077)
https://github.com/python/cpython/commit/b0ee2b492dbf550fbd2a63b82de0a4dc9d67f32e


--

___
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-03 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +22913
pull_request: https://github.com/python/cpython/pull/24079

___
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-03 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

This change seems to broke some buildbots. For instance:

https://buildbot.python.org/all/#/builders/119/builds/153


==
ERROR: test_colors_funcs (test.test_curses.TestCurses)
--
Traceback (most recent call last):
  File 
"/home/dje/cpython-buildarea/3.8.edelsohn-rhel8-z/build/Lib/test/test_curses.py",
 line 310, in test_colors_funcs
curses.pair_content(min(curses.COLOR_PAIRS - 1, 0x7fff))
_curses.error: Argument 1 was out of range. (1..COLOR_PAIRS-1)
--
Ran 28 tests in 0.337s
FAILED (errors=1)
1 test failed again:
test_curses
== Tests result: FAILURE then FAILURE ==

--
nosy: +pablogsal

___
Python tracker 

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



[issue42789] Do not skip test_curses on non-tty

2021-01-03 Thread STINNER Victor


STINNER Victor  added the comment:

> Buildbot failure: ARM Raspbian 3.x: (...)

As expected, the 3.8 and 3.9 change also broke 11 buildbots (3.8 and 3.8) ;-) I 
understand that bpo-42681 will fix buildbots.

--

___
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-03 Thread STINNER Victor


STINNER Victor  added the comment:

> This change seems to broke some buildbots.

Yep, see also bpo-42789.

--
nosy: +vstinner

___
Python tracker 

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



[issue42820] Sphinx conf.py needs_version entry is outdated

2021-01-03 Thread Tim Hoffmann


New submission from Tim Hoffmann :

The sphinx conf.py entry `needs_version=1.8` 
(https://github.com/python/cpython/blob/1470edd6131c29b8a09ce012cdfee3afa269d553/Doc/conf.py#L48)

is not in sync with the doc build requirements 
(https://github.com/python/cpython/blob/1470edd6131c29b8a09ce012cdfee3afa269d553/Doc/requirements.txt#L6)

Possible solutions:
a) Drop the `needs_version` config value. It's optional.
b) Make sure to update both places.
c) Or at minimum add a comment that `needs_version` is only a safeguard against 
very old sphinx versions but is not necessarily sufficient to build.

--
assignee: docs@python
components: Documentation
messages: 384305
nosy: docs@python, timhoffm
priority: normal
severity: normal
status: open
title: Sphinx conf.py needs_version entry is outdated

___
Python tracker 

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



[issue28937] str.split(): allow removing empty strings (when sep is not None)

2021-01-03 Thread karl


Change by karl :


--
nosy: +karlcow

___
Python tracker 

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



[issue28937] str.split(): allow removing empty strings (when sep is not None)

2021-01-03 Thread Guido van Rossum

Guido van Rossum  added the comment:

This issue probably needs a new champion. There is broad agreement but some
bike shedding, so a PEP isn’t needed.--
--Guido (mobile)

--

___
Python tracker 

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



[issue28937] str.split(): allow removing empty strings (when sep is not None)

2021-01-03 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
nosy:  -rhettinger

___
Python tracker 

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



[issue42584] Upgrade macOS and Windows installers to use SQLite 3.34.0

2021-01-03 Thread Ned Deily


Ned Deily  added the comment:


New changeset c94ee13ad596d26d1859078bc09806aa59bb by Erlend Egeberg 
Aasland in branch 'master':
bpo-42584: Update macOS installer to use SQLite 3.34.0 (GH-23674)
https://github.com/python/cpython/commit/c94ee13ad596d26d1859078bc09806aa59bb


--

___
Python tracker 

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