[issue44276] Replace if-elif-else structure with match-case (PEP634)

2021-06-01 Thread Kshitiz Arya


Kshitiz Arya  added the comment:

Pardon my ignorance here but can I start working on this issue? I am a new 
contributor therefore I am unsure about how to proceed from here

--

___
Python tracker 

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



[issue44265] Create an MSI Package

2021-06-01 Thread Steve Dower


Steve Dower  added the comment:

Thanks, Eric.

Anyone may feel free to create and release their own MSI distro of CPython. I 
don't even mind if you use the binaries from our releases, as those are signed 
and your users will be able to know that they aren't modified (it's a little 
harder to verify the stdlib against the catalog files, but possible for those 
who care).

(Also, anyone may feel free to *demand payment* for creating an MSI distro. 
Only do as much for free as you are willing, and no more!)

--
resolution:  -> rejected
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



[issue44275] Is there a mojibake problem rendering interactive help in the REPL on Windows?

2021-06-01 Thread Steve Dower


Steve Dower  added the comment:

> If changing the console input codepage to UTF-8 fixes the mojibake problem, 
> then probably you're running Python in UTF-8 mode.

I forget where I saw them, but there are some places where we incorrectly use 
stdin encoding for writing to stdout (I suppose assuming that they'll always 
match). This may be being impacted by one of those.

--
assignee: docs@python -> 
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



[issue34219] distutils: build_ext -D wrongly assume defining a symbol with no value

2021-06-01 Thread Steve Dower


Steve Dower  added the comment:

distutils is deprecated and no further bugs will be fixed (other than newly 
discovered release blockers).

You will want to report this to setuptools instead.

--
resolution:  -> out of date
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



[issue34219] distutils: build_ext -D wrongly assume defining a symbol with no value

2021-06-01 Thread Steve Dower


Change by Steve Dower :


--
nosy:  -steve.dower

___
Python tracker 

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



[issue25957] sockaddr_l2 lacks CID, address type (AF_BLUETOOTH sockets)

2021-06-01 Thread Steve Dower


Change by Steve Dower :


--
nosy:  -steve.dower

___
Python tracker 

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



[issue44276] Replace if-elif-else structure with match-case (PEP634)

2021-06-01 Thread Kshitiz Arya


Kshitiz Arya  added the comment:

This is a relatively simple example of how this will improve readability of the 
code.
(This example is form Lib/json/encoder.py)

Original

-
if isinstance(value, str):
yield _encoder(value)
elif value is None:
yield 'null'
elif value is True:
yield 'true'
elif value is False:
yield 'false'
elif isinstance(value, int):
yield _intstr(value)
elif isinstance(value, float):
yield _floatstr(value)
else:
if isinstance(value, (list, tuple)):
chunks = _iterencode_list(value, _current_indent_level)
elif isinstance(value, dict):
chunks = _iterencode_dict(value, _current_indent_level)
else:
chunks = _iterencode(value, _current_indent_level)
yield from chunks 
--

Suggested

--
match value:
case str():
yield _encoder(value)
case None:
yield 'null'
case True:
yield 'true'
case False:
yield 'false'
case int():
# see comment for int/float in _make_iterencode
yield _intstr(value)
case float():
# see comment for int/float in _make_iterencode
yield _floatstr(value)
case _:
match value:
case list()|tuple():
chunks = _iterencode_list(value, _current_indent_level)
case dict():
chunks = _iterencode_dict(value, _current_indent_level)
case _:
chunks = _iterencode(value, _current_indent_level)
yield from chunks


--

___
Python tracker 

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



[issue44079] [sqlite3] remove superfluous statement weak ref list from connection object

2021-06-01 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

Also, note that if identical SQL statements are created in multiple cursors 
belonging to the same connection, they will currently _not_ be added to the 
connection weak ref list. See the if (self->statement->in_use) in the middle of 
_pysqlite_query_execute(). Thus, the current code actually fails to register 
_all_ statements in the "all statements" weak ref list. IMO, this is yet 
another argument to abandon that list.

Side note: This branch is not exercised in the unit test suite. Adding the 
following test will cover this branch:

diff --git a/Lib/sqlite3/test/dbapi.py b/Lib/sqlite3/test/dbapi.py
index c17f911fa1..8e53c657a6 100644
--- a/Lib/sqlite3/test/dbapi.py
+++ b/Lib/sqlite3/test/dbapi.py
@@ -526,6 +526,10 @@ def test_last_row_id_insert_o_r(self):
 ]
 self.assertEqual(results, expected)
 
+def test_same_query_in_multiple_cursors(self):
+cursors = [self.cx.execute("select 1") for _ in range(3)]
+for cu in cursors:
+self.assertEqual(cu.fetchall(), [(1,)])
 
 class ThreadTests(unittest.TestCase):
 def setUp(self):


See bpo-43553 for sqlite3 coverage improvements.

--

___
Python tracker 

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



[issue44278] Improve syntax error message for assigning to "..."

2021-06-01 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

Some users can be confused by syntax error message for assigning to ellipsis 
[1]:

>>> ... = 1
  File "", line 1
... = 1
^^^
SyntaxError: cannot assign to Ellipsis here. Maybe you meant '==' instead of 
'='?

because Ellipsis is a name of a builtin variable Ellipsis, and it is possible 
to assign to variable named Ellipsis.

>>> Ellipsis = 1
>>> Ellipsis
1

I think that using lowercase spelling of "ellipsis" will eliminate confusion.

[1] 
https://mail.python.org/archives/list/python-id...@python.org/thread/KDQ3OHALLXVZJIGPC4BMPVS2XH3VFPJV/

--
components: Interpreter Core
messages: 394849
nosy: pablogsal, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Improve syntax error message for assigning to "..."
type: enhancement
versions: Python 3.11

___
Python tracker 

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



[issue44276] Replace if-elif-else structure with match-case (PEP634)

2021-06-01 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

match-case has not even reached a stable version of Python yet, it is only 
available in Python 3.10 which is still in beta. Are we sure that it is faster 
in all cases and how do you know it is more intuitive when the vast majority of 
Python users have likely not even heard of match-case yet?

Personally, I am looking forward to using match-case, but I can see myself 
having to write lots of comments explaining what the code is doing for many 
years to come.

--
nosy: +steven.daprano

___
Python tracker 

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



[issue44278] Improve syntax error message for assigning to "..."

2021-06-01 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

I think this is a duplicate of issue 44273.

--
nosy: +BTaskaya

___
Python tracker 

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



[issue44278] Improve syntax error message for assigning to "..."

2021-06-01 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue44278] Improve syntax error message for assigning to "..."

2021-06-01 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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



[issue44278] Improve syntax error message for assigning to "..."

2021-06-01 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> duplicate
stage: patch review -> resolved
status: open -> closed
superseder:  -> Assigning to Ellipsis should be the same as assigning to 
__debug__

___
Python tracker 

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



[issue44273] Assigning to Ellipsis should be the same as assigning to __debug__

2021-06-01 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
nosy: +serhiy.storchaka
nosy_count: 2.0 -> 3.0
pull_requests: +25072
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/26477

___
Python tracker 

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



[issue42972] [C API] Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-06-01 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset fffa0f92adaaed0bcb3907d982506f78925e9052 by Erlend Egeberg 
Aasland in branch 'main':
bpo-42972: Track sqlite3 statement objects (GH-26475)
https://github.com/python/cpython/commit/fffa0f92adaaed0bcb3907d982506f78925e9052


--

___
Python tracker 

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



[issue44273] Assigning to Ellipsis should be the same as assigning to __debug__

2021-06-01 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 39dd141a4ba68bbb38fd00a65cdcff711acdafb5 by Serhiy Storchaka in 
branch 'main':
bpo-44273: Improve syntax error message for assigning to "..." (GH-26477)
https://github.com/python/cpython/commit/39dd141a4ba68bbb38fd00a65cdcff711acdafb5


--

___
Python tracker 

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



[issue44273] Assigning to Ellipsis should be the same as assigning to __debug__

2021-06-01 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +25073
pull_request: https://github.com/python/cpython/pull/26478

___
Python tracker 

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



[issue44273] Assigning to Ellipsis should be the same as assigning to __debug__

2021-06-01 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



[issue40395] Scripts folder is Empty in python 3.8.2 for Windows 7.

2021-06-01 Thread Pooja Warhekar


Pooja Warhekar  added the comment:

Similar issue on windows 8.1 with Python 3.9.5. Repairing also did not work.

--
nosy: +poojawarhekar2012

___
Python tracker 

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



[issue44276] Replace if-elif-else structure with match-case (PEP634)

2021-06-01 Thread Kshitiz Arya


Kshitiz Arya  added the comment:

I guess we will have to wait until Python 3.10 is released and we have more 
conclusive data about speed and readability of match-case before we can go 
ahead with this issue.

--

___
Python tracker 

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



[issue40395] Scripts folder is Empty in python 3.8.2 for Windows 7.

2021-06-01 Thread Steve Dower


Steve Dower  added the comment:

Pooja, could you share your install logs? Details are in my post directly above 
yours.

--

___
Python tracker 

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



[issue43795] Implement PEP 652 -- Maintaining the Stable ABI

2021-06-01 Thread Petr Viktorin


Change by Petr Viktorin :


--
pull_requests: +25074
pull_request: https://github.com/python/cpython/pull/26479

___
Python tracker 

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



[issue44277] cpython forks are spammed with dependabot PRs

2021-06-01 Thread Zachary Ware


Zachary Ware  added the comment:

This seems like a Dependabot bug; is there anything we can even do about it?

--
nosy: +zach.ware

___
Python tracker 

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



[issue44275] Is there a mojibake problem rendering interactive help in the REPL on Windows?

2021-06-01 Thread Jesse Silverman

Jesse Silverman  added the comment:

Thank you so much Inada and Eryk and Steve!

I was one of the people who mistakenly thought that Python 3 operating in the 
new Windows Terminal was going to magically leave us sitting happily in 
completely UTF-8 compatible territory on Windows, not realizing the complex 
long-term dependencies and regressions that still remain problematic.

I had spent a lot of time paying attention to the Python 2 vs. 3 debates with 
people shouting "I don't care about Unicode!" and mistook dedication to 
preventing regressions and breakages for a lesser appreciation of the value of 
UTF-8 support.  I have been schooled.  We all want the same thing, but getting 
there on Windows from where we are at the moment remains non-trivial.

Heartfelt appreciation to all on the front lines of dealing with this complex 
and sticky situation. ❤️❤️❤️

Also, much love to those who had put in the work to have much more help than I 
realized existed even when one finds oneself isolated on a single disconnected 
machine with only the standard docs as a guide🧭 -- I didn't realize the pages I 
found mojibake on even existed until this weekend.

--

___
Python tracker 

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



[issue23903] Generate PC/python3.def by scraping headers

2021-06-01 Thread Petr Viktorin


Petr Viktorin  added the comment:

PEP 652 (bpo-43795) is now in; I'm closing this issue.

A cross-platform C parser/checker would still be an improvement, but the 
constraints (no external dependencies in CPython) and benefits (not many 
compared to the goal of strict separation of internal/public/stable headers) 
aren't really aligned in its favor.

--
resolution:  -> rejected
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



[issue29086] Document C API that is not part of the limited API

2021-06-01 Thread Petr Viktorin


Petr Viktorin  added the comment:

PEP 652 is now in, and with it a list of everything that *is* in the stable 
ABI: https://docs.python.org/3.10/c-api/stable.html#contents-of-limited-api

I'm closing the issue.

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



[issue40395] Scripts folder is Empty in python 3.8.2 for Windows 7.

2021-06-01 Thread Pooja Warhekar


Pooja Warhekar  added the comment:

Please find the attached log files.

--
Added file: https://bugs.python.org/file50079/Python log files.zip

___
Python tracker 

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



[issue37766] IDLE autocomplete: revise fetch_completions, add htest

2021-06-01 Thread E. Paine


Change by E. Paine :


--
nosy: +epaine
versions: +Python 3.10, Python 3.11 -Python 3.7, Python 3.8

___
Python tracker 

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



[issue44275] Is there a mojibake problem rendering interactive help in the REPL on Windows?

2021-06-01 Thread Eryk Sun


Eryk Sun  added the comment:

> I was one of the people who mistakenly thought that Python 3 operating 
> in the new Windows Terminal was going to magically leave us sitting 
> happily in completely UTF-8 compatible territory on Windows, not 
> realizing the complex long-term dependencies and regressions that 
> still remain problematic.

Windows Terminal provides a tab-based UI that supports font fallback and 
complex scripts, which is a significant improvement over the builtin terminal 
that conhost.exe provides. Each tab is a headless (conpty) console session 
that's hosted by an instance of OpenConsole.exe. The latter is based on the 
same source tree as the system conhost.exe, but typically it's a more recent 
build. The console host is what implements most of the API for client 
applications. That the host is in headless mode and connected to an alternate 
terminal doesn't matter from the perspective of client applications.

The console has been Unicode (UCS-2) back to its initial release in 1993. 
Taking advantage of this requires reading and writing wide-character strings 
via ReadConsoleW and WriteConsoleW, as Python's does in 3.6+ (except not for 
os.read and os.write). Many console applications instead use encoded byte 
strings with ReadFile / ReadConsoleA and WriteFile / WriteConsoleA. Updating 
the console host to support UTF-8 for this has been a drawn-out process. It 
finally has full support for writing UTF-8 in Windows 10, including splitting a 
sequence across multiple writes. But reading non-ASCII UTF-8 is still broken.

"more.com" uses the console input codepage to decode the file, so a workaround 
is to run `chcp.com 65001` and run Python in UTF-8 mode, e.g. `py -X utf8=1`. 
Since reading non-ASCII UTF-8 is broken, you'll have to switch back to the old 
input codepage if you need to enter non-ASCII characters in an app that reads 
from the console via ReadFile or ReadConsoleA.

--

___
Python tracker 

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



[issue44279] doc: contextlib.suppress documentation is imprecise

2021-06-01 Thread Irit Katriel


New submission from Irit Katriel :

"suppresses any of the specified exceptions if they occur in the body of a with 
statement"

Should be:

"suppresses any of the specified exceptions if they are raised in the body of a 
with statement"

--
assignee: docs@python
components: Documentation, Library (Lib)
messages: 394863
nosy: docs@python, iritkatriel
priority: normal
severity: normal
status: open
title: doc: contextlib.suppress documentation is imprecise
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



[issue44279] doc: contextlib.suppress documentation is imprecise

2021-06-01 Thread MapleCCC


Change by MapleCCC :


--
keywords: +patch
nosy: +MapleCCC
nosy_count: 2.0 -> 3.0
pull_requests: +25075
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/26428

___
Python tracker 

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



[issue44262] tarfile: some content different output

2021-06-01 Thread Filipe Laíns

Change by Filipe Laíns :


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



[issue40395] Scripts folder is Empty in python 3.8.2 for Windows 7.

2021-06-01 Thread Steve Dower


Steve Dower  added the comment:

It still seems like pyexpat is not installing properly.

My best guess is that some virus scanner is silently blocking that file from 
being installed.

Do you know what scanner you have enabled? If you can disable it, can you try 
doing an uninstall/reinstall with it disabled?

--

___
Python tracker 

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



[issue44280] unittest filters out too many assertion stack frames from context/cause chains

2021-06-01 Thread Peter Hawkins


New submission from Peter Hawkins :

Example repro:
```
import unittest


def d():
  assert 2 == 3

def c():
  d()

def b():
  c()

def a():
  try:
b()
  except Exception as e:
assert 1 == 2


class MyTest(unittest.TestCase):

  def testException(self):
a()


if __name__ == '__main__':
  unittest.main()
```

Example output from Python 3.9.0:
```
$ python atest.py
F
==
FAIL: testException (__main__.MyTest)
--
Traceback (most recent call last):
  File "/private/tmp/atest.py", line 15, in a
b()
  File "/private/tmp/atest.py", line 11, in b
c()
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/private/tmp/atest.py", line 23, in testException
a()
  File "/private/tmp/atest.py", line 17, in a
assert 1 == 2
AssertionError

--
Ran 1 test in 0.000s

FAILED (failures=1)
```

Too many frames have been filtered out of the `__context__` exception, 
including a number of relevant frames for `c` and `d`. I believe this happens 
because unittest sets a `limit` here based on the contents of the main 
traceback:
https://github.com/python/cpython/blob/39dd141a4ba68bbb38fd00a65cdcff711acdafb5/Lib/unittest/result.py#L182

but that limit applies recursively to the `__context__` and `__cause__` chains, 
when the intent of the limit was presumably only to filter the main exception.

--
messages: 394865
nosy: peter.hawkins
priority: normal
severity: normal
status: open
title: unittest filters out too many assertion stack frames from context/cause 
chains
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



[issue44280] unittest filters out too many assertion stack frames from context/cause chains

2021-06-01 Thread Peter Hawkins


Change by Peter Hawkins :


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

___
Python tracker 

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



[issue44279] doc: contextlib.suppress documentation is imprecise

2021-06-01 Thread Irit Katriel


Irit Katriel  added the comment:


New changeset 87272b70f157af76cb14ff90d73dfc5d9bfb945a by MapleCCC in branch 
'main':
bpo-44279: [doc] reword contextlib.suppress documentation (GH-26428)
https://github.com/python/cpython/commit/87272b70f157af76cb14ff90d73dfc5d9bfb945a


--

___
Python tracker 

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



[issue44281] Links on top of collections doc not in the order of sections

2021-06-01 Thread Andrei Kulakov


New submission from Andrei Kulakov :

https://docs.python.org/3.11/library/collections.html

Links are not in the same order as the sections below. It creates some 
dissonance for the reader to first read the section names above and then 
continue reading expecting them to be in the same order through the page.

Seems like would be an easy fix to reorder them.

--
assignee: docs@python
components: Documentation
messages: 394867
nosy: andrei.avk, docs@python
priority: normal
severity: normal
status: open
title: Links on top of collections doc not in the order of sections
type: enhancement
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



[issue44238] Unable to install Python 3.9.5 - Windows Server

2021-06-01 Thread Steve Dower


Steve Dower  added the comment:

Unfortunately, I've got no idea whether it's failing to uninstall the MSI or if 
it's specific to removing the PATH environment variable. If you've still got 
the rest (no more than 2-3 I'd expect) of the uninstall log files in your 
%TEMP% directory that may show something.

Have you successfully installed/uninstalled other versions of Python before on 
this machine/OS?

--

___
Python tracker 

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



[issue44275] Is there a mojibake problem rendering interactive help in the REPL on Windows?

2021-06-01 Thread Jesse Silverman


Jesse Silverman  added the comment:

"more.com" uses the console input codepage to decode the file, so a workaround 
is to run `chcp.com 65001` and run Python in UTF-8 mode, e.g. `py -X utf8=1`. 
Since reading non-ASCII UTF-8 is broken, you'll have to switch back to the old 
input codepage if you need to enter non-ASCII characters in an app that reads 
from the console via ReadFile or ReadConsoleA.

Confirmed that this workaround done in Windows Terminal causes all mojibake to 
immediately evaporate, leaving me with the most readable and enjoyable 
more/console experience I have ever had since first hitting a spacebar on 
MS-DOS.
(Windows Terminal and the open-sourcing of the CONSOLE code is in a three-way 
tie with open-sourcing of .Net Core and the C++ STL for changing how I feel 
about Windows.  I keep finding new reasons to love it, except for reading 
non-ASCII UTF-8 being broken which I just learned about today.)

--

___
Python tracker 

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



[issue44282] IDLE: ColorDelegatorTest test_incremental_editing failures

2021-06-01 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Followup to PR-26404, which added the tests.

--

___
Python tracker 

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



[issue44282] IDLE: ColorDelegatorTest test_incremental_editing failures

2021-06-01 Thread Tal Einat


Change by Tal Einat :


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

___
Python tracker 

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



[issue44282] IDLE: ColorDelegatorTest test_incremental_editing failures

2021-06-01 Thread Terry J. Reedy


New submission from Terry J. Reedy :

idlelib.idle_test.test_colordelagator.ColorDelegatorTest.test_incremental_editing
 has failed on at least on the following machines.  

Pip32  CI Pipelines Win32
Gen3x  https://buildbot.python.org/all/#/builders/464  x86 Gentoo Installed 
with X 3.x
GenPR  https://buildbot.python.org/all/#/builders/465  x86 Gentoo Installed 
with X PR

Failures seen.  Since tests are sequential without subtesting, failure means 
successors are not tested.

line  keyword start   wantgot  
569   ('BUILTIN', '1.0'), ('1.0', '1.3')  ()  Gen3x, x3; GenPR
573   ('BUILTIN', '1.0'), ('1.0', '1.3')  ()  Gen3x, x5
586   ('BUILTIN', '1.0'), ('1.0', '1.3')  ()  GenPR
597   ('KEYWORD', '1.0'), ()  ('1.0', '1.1')  Pip32, x2

As far as I can tell, looking at Windows buildbots, the 1 failure on Win32 has 
not been repeated.  If there have been any on CI machines, I have not been 
informed.

A few years ago, I believe Gentoo was the only *nix buildbot running tkinter 
and IDLE tests. It has a problem with a builtin at the beginning of the line 
about 10-20% of test runs.  This are the majority of its failures in the last 
week.  Perhaps there is a timing issue we can fix.

--
assignee: terry.reedy
components: IDLE, Tests
messages: 394870
nosy: taleinat, terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: IDLE: ColorDelegatorTest test_incremental_editing failures
type: behavior
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



[issue44279] doc: contextlib.suppress documentation is imprecise

2021-06-01 Thread Irit Katriel


Change by Irit Katriel :


--
pull_requests: +25077
pull_request: https://github.com/python/cpython/pull/26480

___
Python tracker 

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



[issue44263] Better explain the GC contract for PyType_FromSpecWithBases

2021-06-01 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset ee7637596d8de25f54261bbeabc602d31e74f482 by Victor Stinner in 
branch 'main':
bpo-44263: Py_TPFLAGS_HAVE_GC requires tp_traverse (GH-26463)
https://github.com/python/cpython/commit/ee7637596d8de25f54261bbeabc602d31e74f482


--

___
Python tracker 

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



[issue44279] doc: contextlib.suppress documentation is imprecise

2021-06-01 Thread Irit Katriel


Change by Irit Katriel :


--
pull_requests: +25078
pull_request: https://github.com/python/cpython/pull/26481

___
Python tracker 

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



[issue44263] Better explain the GC contract for PyType_FromSpecWithBases

2021-06-01 Thread STINNER Victor


STINNER Victor  added the comment:

I made sure that it's no longer possible to create a type with 
Py_TPFLAGS_HAVE_GC flag set but with no traverse function (tp_traverse=NULL). I 
close again the issue.

--
components: +C API, Interpreter Core
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
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



[issue44283] Add jump table for certain safe match-case statements

2021-06-01 Thread Dennis Sweeney


New submission from Dennis Sweeney :

Anecdotally, a few people I've talked to have expected that match-case 
statements would improve performance in the same way that switch-cases 
sometimes do in C-like languages. While this is impossible in general without 
changing semantics (since, for example, __eq__ can have side effects), it would 
be nice if a jump table was implemented in certain safe cases.

My idea was to implement this whenever the list of cases begins with 2 or more 
of the following in a row:

(1) ints
(2) strings
(3) None
(4) OR (`|`) patterns of any of the above
(5?) potentially later add support for tuples

Example:

match x:
case 10: # safe
print("A")
case 20: # safe
print("B")
case 30 | 31:# safe
print("C")
case 40: # safe
print("D")
case MyClass(10, 20): # unsafe
print("E")
case []:  # unsafe
print("F")
case whatever:# unsafe
print("G")


This would compile to something like

LOAD_FAST (x)
LOAD_CONST 16({10: 16, 20: 38, 30: 80, 31: 80, 40: 102})
ATTEMPT_SAFE_MATCH 110

... all the rest of the code is the same ...

Where the new opcode would be would be something like

case TARGET(ATTEMPT_SAFE_MATCH): {
PyObject *jump_dict = POP();
PyObject *x = TOP();

if (PyLong_CheckExact(x) ||
PyUnicode_CheckExact(x) ||
Py_Is(x, Py_None))
{
PyObject *boxed = PyDict_GetItemWithError(jump_dict, x);
Py_DECREF(jump_dict);
if (res == NULL) {
if (PyErr_Occurred()) {
goto error;
}
else {
JUMPBY(oparg);
}
}
assert(PyLong_CheckExact(boxed));
int target = (int)PyLong_AsLong(boxed);
JUMPBY(target);
}
else {
// fall back to general matching code
Py_DECREF(jump_dict);
DISPATCH();
}
}

I can work on an implementation in the next couple of weeks.

--
components: Interpreter Core
messages: 394874
nosy: Dennis Sweeney
priority: normal
severity: normal
status: open
title: Add jump table for certain safe match-case statements
type: performance
versions: Python 3.11

___
Python tracker 

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



[issue44279] doc: contextlib.suppress documentation is imprecise

2021-06-01 Thread Irit Katriel


Irit Katriel  added the comment:


New changeset 6563ea5c60be2e4896df52eff777aa93743f1551 by Irit Katriel in 
branch '3.10':
[3.10] bpo-44279: [doc] reword contextlib.suppress documentation (GH-26428) 
(GH-26480)
https://github.com/python/cpython/commit/6563ea5c60be2e4896df52eff777aa93743f1551


--

___
Python tracker 

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



[issue44279] doc: contextlib.suppress documentation is imprecise

2021-06-01 Thread Irit Katriel


Irit Katriel  added the comment:


New changeset 9a688624973a2b753b84f892b65268543c7ff67d by Irit Katriel in 
branch '3.9':
[3.9] bpo-44279: [doc] reword contextlib.suppress documentation (GH-26428) 
(GH-26481)
https://github.com/python/cpython/commit/9a688624973a2b753b84f892b65268543c7ff67d


--

___
Python tracker 

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



[issue44279] doc: contextlib.suppress documentation is imprecise

2021-06-01 Thread Irit Katriel


Change by Irit Katriel :


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



[issue44275] Is there a mojibake problem rendering interactive help in the REPL on Windows?

2021-06-01 Thread Inada Naoki


Inada Naoki  added the comment:

>> PS > $OutputEncoding =  [System.Text.Encoding]::GetEncoding("UTF-8")

> FYI, $OutputEncoding in PowerShell has nothing to do with the python.exe and 
> more.com processes, nor the console session to which they're attached.

>> PS > [System.Console]::OutputEncoding = $OutputEncoding

> The console output code page is irrelevant since more.com writes 
> wide-character text via WriteConsoleW() and decodes the file using the 
> console input code page, GetConsoleCP(). The console output codepage from 
> GetConsoleOutputCP() isn't used for anything here.

Yes, both are unrelated to this specific issue. But both are highly recommended 
for using Python with UTF-8 mode.

Now many people want to use Python with UTF-8 mode in PowerShell in Windows 
Terminal. And they don't want to care about legacy encoding at all.

--

___
Python tracker 

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



[issue44283] Add jump table for certain safe match-case statements

2021-06-01 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Big +1 from me.  This would make use of match-case more compelling.

--
nosy: +rhettinger

___
Python tracker 

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



[issue44281] Links on top of collections doc not in the order of sections

2021-06-01 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
priority: normal -> low

___
Python tracker 

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



[issue44281] Links on top of collections doc not in the order of sections

2021-06-01 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
assignee: docs@python -> rhettinger
nosy: +rhettinger
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



[issue44276] Replace if-elif-else structure with match-case (PEP634)

2021-06-01 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

If the json.encoder code does get updated, it doesn't need two levels of 
matching.  It can be flattened by eliminating the *chunks* variable.

match value:
case str():
yield _encoder(value)
case None:
yield 'null'
case True:
yield 'true'
case False:
yield 'false'
case int():
yield _intstr(value)
case float():
yield _floatstr(value)
case list() | tuple():
yield from _iterencode_list(value, _current_indent_level)
case dict():
yield from _iterencode_dict(value, _current_indent_level)
case _:
yield from _iterencode(value, _current_indent_level)

--
nosy: +rhettinger

___
Python tracker 

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



[issue44281] Links on top of collections doc not in the order of sections

2021-06-01 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

ISTM that the table order doesn't need to match because the links take you 
directly to the section of interest.  They make it so that you don't need to 
know the order of sections below.  Currently, they have a "logical" grouping 
with the two sequence-like objects side-by-side, the four dict or dict-like 
subclasses side-by-side, and the other "User" classes side-by-side.

The order of the sections below is in alpha order (with the minor exception of 
deque and defaultdict being swapped).  This is also reasonable because a person 
would likely be scanning the Table of Contents looking for the class or 
function by its name.

This is really no different than a lending library having a title catalog and a 
subject catalog with the same information arranged in two different ways.  Both 
ways have value.

Thank you for the suggestion, but the existing ordering was intentional and is 
useful.  Possibly, we could swap the *deque* and *defaultdict* sections, but 
the benefit is very minor and likely isn't worth the churn.

--
resolution:  -> rejected
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



[issue44276] Replace if-elif-else structure with match-case (PEP634)

2021-06-01 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

In difflib, there's an example where it would be easy to run performance tests.

match tag:
case 'replace':
g = self._fancy_replace(a, alo, ahi, b, blo, bhi)
case 'delete':
g = self._dump('-', a, alo, ahi)
case 'insert':
g = self._dump('+', b, blo, bhi)
case 'equal':
g = self._dump(' ', a, alo, ahi)
case _:
raise ValueError('unknown tag %r' % (tag,))

--

___
Python tracker 

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



[issue44283] Add jump table for certain safe match-case statements

2021-06-01 Thread Brandt Bucher


Change by Brandt Bucher :


--
nosy: +brandtbucher

___
Python tracker 

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



[issue43882] [security] urllib.parse should sanitize urls containing ASCII newline and tabs.

2021-06-01 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
resolution:  -> fixed
stage: patch review -> commit review
status: open -> closed

___
Python tracker 

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



[issue44283] Add jump table for certain safe match-case statements

2021-06-01 Thread Brandt Bucher


Brandt Bucher  added the comment:

Seems like a good idea as long as we're careful about the implementation. I've 
just jotted down a few notes here:

- We should probably break the table upon encountering a guard.

- We probably can't get away with storing a dictionary in the code object's 
constants, since the entire code object needs to be hashable. We could store a 
tuple of key-value pairs and either (a) build the dictionary each time we enter 
the block, or (b) stash it somewhere. If we stash it:
  - Should we defer building it until the first time we hit the block, or 
earlier than that?
  - Where would we stash it?

- We should probably have some heuristic perhaps more restrictive than "two or 
more of the following in a row". I'm not entirely sure that loading/building a 
dictionary, hashing an integer/string/None, looking it up in a dictionary, and 
then either (a) recovering from the error, or (b) converting the Python integer 
value into a C long and jumping on it is faster than the current implementation 
for the first two cases. I know it's really fast, but I'm not *sure* it will be 
an obvious win yet. Ideally, the best-case scenario (match on first case) would 
be just as fast as it is currently. I'm probably willing to speed up the 
average case at the expense of the best case, though.

- I'm not sure we need to limit this to leading cases. What's stopping us from 
having one of these jump tables in the middle of a match block (or even having 
more than one scattered throughout)? Unless I'm missing something, this should 
work anytime we observe contiguous "simple" cases.

--

___
Python tracker 

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



[issue43654] IDLE: Fix tab completion after settings and some keys

2021-06-01 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Currently, the keys that define certain pseudoevents and invoke the associated 
event handlers are fixed: tab, '.', and within strings, '/' and '\' for 
completions, '(' and ')' for calltip open and close, and ')', ']', and '}' for 
opener matching.  Note that quote matching is indicated by coloring completed 
strings.

PR-26421 proposes to augment this list with tab for smart indent, backspace for 
smart backspace, and newline for completing a line and maybe smart indenting. 
In other words, remove the following 3 lines

  '<>': [''],
  '<>': ['', ''],
  '<>': [''],

from config-keys.def and the Settings Keys tab and add them as fixed binding to 
EditorWindow.__init__ just above the existing fixed pseudoevent -- keys 
bindings.

Only fixing smart-indent and tab (or unfixing name-completion and tab) is 
needed to keep name completion working after re-doing setting.  So why all 
three?  1. These three pairs go together; I don't see anything else that should 
be fixed.  2. By the standard used to fix some pairs already, these three 
should be also.  I think it an accident of IDLE's history that they aren't*.  
3. It might be that changing either of the other two binding could disable 
something, or might in the future.  In other words, I consider having this 
bindings be mutable to be a bit buggy, with this issue being evidence.

* Multiple coders, coding convenience, shift of focus from 'consenting adults 
to 'beginners'?

The unknown is whether anyone has changed these pseudoevent bindings and if so, 
how much do we care?  

Guido, do you have any comment on this proposal from a change policy 
perspective?

--
nosy: +gvanrossum
title: IDLE: Applying settings disables tab completion -> IDLE: Fix tab 
completion after settings and some keys

___
Python tracker 

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



[issue44283] Add jump table for certain safe match-case statements

2021-06-01 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

At first I thought of matches with only the int/str/None cases and then I saw 
the easy generalization, but yeah, each contiguous block seems better.

One solution to the code hashability/lookup speed apparent dilemma: writing the 
equivalent of this in C:

class HashableDict(dict):
def __new__(cls, pairs):
return dict.__new__(cls, pairs)
def __eq__(self, other):
return tuple(self.mapping.items()) == tuple(other.sequence.items())
def __hash__(self):
return CONSTANT ^ hash(tuple(self.items()))
def __getnewargs__(self):
return tuple(self.items())

# forbid all mutating methods
__setitem__ = __delitem__ = update = __ior__ = None # etc.

(Or maybe using composition rather than inheritence)

Maybe using the HAMT in /Python/hamt.c would suffice instead.

--

___
Python tracker 

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



[issue40395] Scripts folder is Empty in python 3.8.2 for Windows 7.

2021-06-01 Thread Pooja Warhekar


Pooja Warhekar  added the comment:

I tried following things.
1. Clearing registry.
2. Web installation
3. Installation in E drive.
However problem remains same. Please find the attached log files.
Also I couldn't install Microsoft Visual C++ 2015 Redistributable. Could this 
cause any problem?

--
Added file: https://bugs.python.org/file50080/Installation log _02062021.zip

___
Python tracker 

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



[issue44279] doc: contextlib.suppress documentation is imprecise

2021-06-01 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

I think the old wording was better.  Code can explicitly raise an exception, 
but other exceptions just occur when calling builtin functions or with a 
keyboard interrupt.

--
nosy: +eric.smith, rhettinger

___
Python tracker 

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



[issue44283] Add jump table for certain safe match-case statements

2021-06-01 Thread Brandt Bucher

Brandt Bucher  added the comment:

Hm. I’m not sure if the HAMT makes much sense. We don’t really care about 
efficient mutation or copies... constant-time lookups seem to be overwhelmingly 
the most valuable factor here.

I personally think that creating some sort of hashable dict and teaching 
marshal how to serialize/deserialize it could be a promising path forward. I 
imagine its actual design could mirror dict (sort of like set/frozenset).

That might be a rather drastic step though. Perhaps it’s better to first prove 
that building a mapping at runtime is too slow.

--

___
Python tracker 

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



[issue44284] Python references wrong line but correct line number in traceback

2021-06-01 Thread helpimnotdrowning


New submission from helpimnotdrowning :

To reproduce (at least on Windows 10 w/ Python 3.9.4):

1) Make a python file:

while True:
print('hello')

2) Run the file via cmd
3) Edit the file (while it is still running):

while True:
print('goodbye')
print('hello')

then save it
4) ctrl+c in the cmd window to exit the script
5) The traceback will look something like this:

Traceback (most recent call last):
  File "dfb.py", line 2, in 
print('goodbye')
KeyboardInterrupt

The traceback mentions the print('goodbye') even though it wasnt in the file 
when it was run. It still calls it line 2, which is the line the print('hello') 
was before adding the print('goodbye')

--
messages: 394888
nosy: helpimnotdrowning
priority: normal
severity: normal
status: open
title: Python references wrong line but correct line number in traceback
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



[issue44283] Add jump table for certain safe match-case statements

2021-06-01 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

I agree that we should benchmark for what the value of "two" should be ;) . 
Maybe only match statements with >=20 consecutive simple cases end up being 
worth it. I would assume that if "case 1, case 2, ..., case 20" are all in a 
row then "case 1" wouldn't be *that* much more likely than "case 20", so a 
slowdown on case 1 wouldn't matter too much if the average gets better.

I'm under the impression that match-case statements would frequently be used 
only once per function call. If I understand your proposal, that would mean 
that calling a function with a N-case constant-pattern match would require N 
hashes and N insertions into a dict (including memory allocation), followed by 
O(1) lookup. Wouldn't that eliminate any hope of making such a function O(1)? 
Unless there's a way to cache the populated dict somewhere else?

I suggested HAMT because it's a well-tested pre-existing fast immutable mapping 
that already implements __hash__, so it would be safe to store in co_consts 
already populated. Re-implementing all of the dict logic seems like an 
unnecessary pain, which is why I was suggesting either the HAMT or a thin 
wrapper around dict, not a re-implementation of a new hash table. I was hoping 
to do the minimum amount of disruption possible to get reasonable O(1) 
performance, and then seeing where that leaves us.

--

___
Python tracker 

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



[issue44275] Is there a mojibake problem rendering interactive help in the REPL on Windows?

2021-06-01 Thread Eryk Sun

Eryk Sun  added the comment:

> Now many people want to use Python with UTF-8 mode in PowerShell 
> in Windows Terminal. And they don't want to care about legacy 
> encoding at all.

Windows Terminal isn't relevant to the encoding issue. Applications interact 
with the console session to which they're attached, e.g. python.exe <-> 
condrv.sys <-> conhost.exe (openconsole.exe). It doesn't matter whether or not 
the console session is headless (conpty) and connected to another process via 
pipes (i.e. a console session created via CreatePseudoConsole and set for a 
child process via PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE). Some settings and 
behaviors do change in conpty mode (e.g. the session has virtual-terminal mode 
enabled by default), but the way encoding and decoding are implemented for 
ReadFile/ReadConsoleA and WriteFile/WriteConsoleA doesn't change.

There are still a lot of programs that read and write from the console as a 
regular file via ReadFile and WriteFile, so the fact that ReadFile is broken 
when the input code page is set to UTF-8 is relevant to most people. However, 
people who run `chcp 65001` in Western locales usually only care about being 
able to write non-ASCII UTF-8 via WriteFile. Reading non-ASCII UTF-8 from 
console input via ReadFile doesn't come up as a common problem, but it 
definitely is a problem. For example:

>>> s = os.read(0, 12)
Привет мир
>>> s
b'\x00\x00\x00\x00\x00\x00 \x00\x00\x00\r\n'

Thus I don't like 'solving' this mojibake issue by simply recommending that 
users set the console input codepage to UTF-8. I previously proposed two 
solutions. (1) a radical change to get full Unicode support: modify pydoc to 
temporarily change the console input codepage to UTF-8 and write the temp file 
as UTF-8. (2) a conservative change just to avoid mojibake: modify pydoc to 
query the console input codepage and write the file using that encoding, as 
always with the backslashreplace error handler.

--

___
Python tracker 

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



[issue44283] Add jump table for certain safe match-case statements

2021-06-01 Thread Brandt Bucher


Brandt Bucher  added the comment:

> If I understand your proposal, that would mean that calling a function with a 
> N-case constant-pattern match would require N hashes and N insertions into a 
> dict (including memory allocation), followed by O(1) lookup. Wouldn't that 
> eliminate any hope of making such a function O(1)? Unless there's a way to 
> cache the populated dict somewhere else?

Yeah, that was the idea sketched out above. Basically, if we go with a vanilla 
dictionary here, we're going to need to build it at runtime. It only really 
makes sense to do that once, the first time we need it. Then we stash it 
away... uh... somewhere. As you note, it doesn't make much sense to spend 
linear time building a constant-time jump table if it's only going to be used 
once. :)

Maybe somebody familiar with the constantly-evolving opcaches could chime in if 
this is the sort of thing that could benefit from that infrastructure. 
Basically, we would need a separate cache per bytecode offset, per code object. 
My understanding is that we don't have anything like that yet.

(A quick-and-dirty prototype could probably store them at "hidden" local names 
like ".table0", ".table1", ".table2", etc. I know comprehensions do something 
like that.)

> Re-implementing all of the dict logic seems like an unnecessary pain, which 
> is why I was suggesting either the HAMT or a thin wrapper around dict, not a 
> re-implementation of a new hash table.

Well, I don't think we'd need to do any of that. I believe set and frozenset 
share the same core design and routines, but differ only in the interfaces 
provided by the objects themselves. I imagine we could do something similar 
with a hypothetical _PyFrozenDict_Type... copy most of the type definition, 
dropping all of the methods except mp_subcript, tp_hash, and a few other 
members. That would probably be all we needed to get this design up and running 
for a proof-of-concept.

A lot of work goes into making dicts fast (especially for things like strings), 
so it would be nice for a new type to be able to benefit from those incremental 
improvements.

> I was hoping to do the minimum amount of disruption possible to get 
> reasonable O(1) performance, and then seeing where that leaves us.

Agreed, but the HAMT mapping has logarithmic time complexity for lookups, 
right? Maybe for realistic cases the coefficients make it basically equivalent, 
but on the surface it seems more promising to try reusing the dict guts instead.

--

___
Python tracker 

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