[issue43143] Allow multiple assignment (i.e. tuple on LHS) in walrus operator

2021-02-06 Thread Paul Sokolovsky


New submission from Paul Sokolovsky :

Currently (CPython 3.10.0a4) having a tuple on left-hand side of assignment 
expression/operator (aka walrus operator) is not allowed:

>>> ((a, b) := (1, 2))
  File "", line 1
((a, b) := (1, 2))
 ^
SyntaxError: cannot use assignment expressions with tuple

As far as can tell, there's no explicit consideration of this case in the 
PEP572. There closest it has is under the 
https://www.python.org/dev/peps/pep-0572/#differences-between-assignment-expressions-and-assignment-statements
 section, "Iterable packing and unpacking (both regular or extended forms) are 
not supported".

But note that the usecase presented above is better seen as "parallel 
assignment", not as "iterable unpacking".

Next issue: PEP572 puts heavy emphasis on the "named expression" usecase. I 
would like to emphasize, that "naming an expression" seems like *just one of 
usecases* for assignment operator. First and foremost assignment operator is, 
well, assignment.

With that in mind, ((a, b) := (1, 2)) is compatible with "naming expressions" 
idea, it "gives names" to multiple expressions at once.

There's a temptation to suggest that the above could be rewritten as:

((a := 1), (b := 2))

, and for the "naming" usecase, that would be true.  But as noted above, 
"naming" is just *one* of the usecases. Following can't be "sequentialized" 
like that:

((b, a) := (a, b))

And for as long as someone considers the following acceptable:

func(a := val)

There's little point to prohibit the following:

min((b, a) := (a, b))


And that's the main argument - consistency between assignment statement and 
assignment operator. For as long as this is allowed:

a, b = b, c

it makes sense to allow:

((a, b) := (b,c))

(Extra parens account for different in grammar and precedence for the operator).


This issue is posted to capture discussion initially posted to 
python-ideas/python-dev:

https://mail.python.org/archives/list/python-id...@python.org/thread/6IFDG7PAFPHVPGULANOQDAHP2X743HCE/
https://mail.python.org/archives/list/python-id...@python.org/thread/X3LNCCO6PHTLAQXHEAP6T3FFW5ZW5GR5/
https://mail.python.org/archives/list/python-...@python.org/thread/6IFDG7PAFPHVPGULANOQDAHP2X743HCE/

, to serve as a reference to whoever may be searching the bugtracker for this 
case.

--
components: Interpreter Core
messages: 386551
nosy: pfalcon
priority: normal
severity: normal
status: open
title: Allow multiple assignment (i.e. tuple on LHS) in walrus operator

___
Python tracker 

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



[issue43071] IDLE: Windows 7 - Trackpad two-finger vertical scrolling is not recognized

2021-02-06 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Python has nothing to do with interpreting finger movements.

--
resolution:  -> third party
stage:  -> resolved
status: open -> closed
versions:  -Python 3.7

___
Python tracker 

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



[issue43111] webbrowser.py triggers unwanted XQuartz startup

2021-02-06 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

3.7 is a few years old and only gets security fixes.  Can you either test on 
current releases or whether code is still same?

--
nosy: +terry.reedy

___
Python tracker 

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



[issue43127] Unable to install Python 3.9.1 - Windows 10

2021-02-06 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
components: +Installation, Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware

___
Python tracker 

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



[issue43144] test_unicodedata: test_normalization uses network but doesn't depend on network resource

2021-02-06 Thread Arkadiusz Miśkiewicz

New submission from Arkadiusz Miśkiewicz :

Hello.

test_normalization uses network but doesn't depend on network resource,
so it tries to run even when network is disabled when running tests (-u-network)

FAIL: test_normalization (test.test_unicodedata.NormalizationTest)
socket.gaierror: [Errno -3] Temporary failure in name resolution
urllib.error.URLError: 
AssertionError: Could not retrieve 
http://www.pythontest.net/unicode/13.0.0/NormalizationTest.txt

--
components: Tests
messages: 386554
nosy: arekm
priority: normal
severity: normal
status: open
title: test_unicodedata: test_normalization uses network but doesn't depend on 
network resource
type: compile error
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



[issue43144] test_unicodedata: test_normalization uses network but doesn't depend on network resource

2021-02-06 Thread Arkadiusz Miśkiewicz

Change by Arkadiusz Miśkiewicz :


--
keywords: +patch
Added file: https://bugs.python.org/file49792/unicodedata-no-network.patch

___
Python tracker 

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



[issue43111] webbrowser.py triggers unwanted XQuartz startup

2021-02-06 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

The same code is present in trunk. 

I'm in favour of disabling usage of X11 browsers of macOS, that's almost 
certainly not what users want.

I no longer have XQuartz installed on my machine, but when I did I only used it 
for running X11 GUIs on remote Linux systems.

What I'm not entirely sure about: is this something we should back port or just 
apply to the trunk (3.10)? This is a behaviour change and as such I'd be 
inclined to only apply to trunk.

--
versions: +Python 3.10, Python 3.8, Python 3.9 -Python 3.7

___
Python tracker 

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



[issue43135] Can't input Japanese on idle (MacOS).

2021-02-06 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

As the issue is gone with the 3.10 universal2 installer it should also be gone 
with the 3.9.1 universal installer. I'd expect that the difference is in the 
use of a newer version of Tcl/Tk. 

We haven't used the newer versions of Tcl/Tk with the regular 3.9 installer 
because we (or rather Ned) have run into various issues when building recent 
versions of Tcl/Tk on ancient versions of macOS. The universal2 installer is 
build on macOS 11 and hence avoids those build issues.  

Testing if Tcl/Tk 8.6.11 works correctly when build on macOS 10.9 could be an 
interesting experiment if someone is up to this, but is something I don't 
intend to do.  I rarely use Tkinter myself and this requires manual testing to 
verify behaviour.

--

___
Python tracker 

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



[issue43111] webbrowser.py triggers unwanted XQuartz startup

2021-02-06 Thread hans.meine


hans.meine  added the comment:

I was trying to be very honest, because I am still running 3.7 for production. 
However, I have carefully checked and the webbrowser.py has only seen (clearly) 
unrelated changes.

--

___
Python tracker 

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



[issue43145] Leak of locks in a subprocess

2021-02-06 Thread Boris Staletic


New submission from Boris Staletic :

The following C code leaks 7 locks allocated with PyThread_allocate_lock:

#include 

int main()
{
Py_Initialize();
PyObject* multiprocessing = PyImport_ImportModule("multiprocessing");
PyObject* Process = PyObject_GetAttrString(multiprocessing, "Process");
PyObject* args = PyTuple_New(0);
PyObject* kw = PyDict_New();
PyDict_SetItemString(kw, "target", Process);

PyObject* p = PyObject_Call(Process, args, kw);
PyObject* start = PyObject_GetAttrString(p, "start");
PyObject* join = PyObject_GetAttrString(p, "join");

PyObject_CallNoArgs(start);
PyObject_CallNoArgs(join);

Py_DECREF(join);
Py_DECREF(start);
Py_DECREF(p);
Py_DECREF(kw);
Py_DECREF(args);
Py_DECREF(Process);
Py_DECREF(multiprocessing);
Py_Finalize();
}



The following locks are leaked:

1. 
https://github.com/python/cpython/blob/196d4deaf4810a0bba75ba537dd40f2d71a5a634/Python/pystate.c#L78
2. 
https://github.com/python/cpython/blob/196d4deaf4810a0bba75ba537dd40f2d71a5a634/Python/pystate.c#L84
3. 
https://github.com/python/cpython/blob/196d4deaf4810a0bba75ba537dd40f2d71a5a634/Python/pystate.c#L90
4. https://github.com/python/cpython/blob/master/Python/ceval.c#L810
5. https://github.com/python/cpython/blob/master/Python/import.c#L126
6. and 7. 
https://github.com/python/cpython/blob/master/Modules/_threadmodule.c#L597

In the attachment is valgrind's output.

--
components: C API
files: log
messages: 386558
nosy: bstaletic
priority: normal
severity: normal
status: open
title: Leak of locks in a subprocess
type: resource usage
versions: Python 3.10, Python 3.9
Added file: https://bugs.python.org/file49793/log

___
Python tracker 

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



[issue43145] Leak of locks in a subprocess

2021-02-06 Thread Boris Staletic


Boris Staletic  added the comment:

Slightly simpler C example:

#include 

int main()
{
Py_Initialize();
PyObject* multiprocessing = PyImport_ImportModule("multiprocessing");
PyObject* Process = PyObject_GetAttrString(multiprocessing, "Process");

PyObject* p = PyObject_CallNoArgs(Process);
PyObject* start = PyObject_GetAttrString(p, "start");
PyObject* join = PyObject_GetAttrString(p, "join");

Py_DECREF(PyObject_CallNoArgs(start));
Py_DECREF(PyObject_CallNoArgs(join));

Py_DECREF(join);
Py_DECREF(start);
Py_DECREF(p);
Py_DECREF(Process);
Py_DECREF(multiprocessing);
Py_Finalize();
}

--

___
Python tracker 

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



[issue41552] uuid.uuid1() on certain Macs does not generate unique IDs

2021-02-06 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

@terrygreeniaus: Are you running macOS 11 on your MacBook Pro?

If so, could you verify the hardware address of the iBridge interface? 

I've checked to libc sources on opensource.apple.com and those don't seem to 
contain code to treat the iBridge interface specially. 

I've also attached a small program that dumps the Mac addresses of interfaces 
using the same mechanism as used by the UUID code in libc. If the Mac address 
is unchanged they may have done something that affects that code.

--
Added file: https://bugs.python.org/file49794/dumpaddr.c

___
Python tracker 

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



[issue43071] IDLE: Windows 7 - Trackpad two-finger vertical scrolling is not recognized

2021-02-06 Thread Greg


Greg  added the comment:

That wasn't the case with https://bugs.python.org/issue34047

Was it not clear that I'm having this issue in (and only in) IDLE? Given that 
it's the interpreter bundled with python, it seems like it has *something* to 
do with it.

--

___
Python tracker 

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



[issue43146] 3.10a5 regression: AttributeError: 'NoneType' object has no attribute '__suppress_context__' in traceback.py

2021-02-06 Thread Florian Bruhin


New submission from Florian Bruhin :

After upgrading to 3.10a5, calling logging.exception("test") results in:

--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.10/logging/__init__.py", line 1094, in emit
msg = self.format(record)
  File "/usr/lib/python3.10/logging/__init__.py", line 938, in format
return fmt.format(record)
  File "/usr/lib/python3.10/logging/__init__.py", line 682, in format
record.exc_text = self.formatException(record.exc_info)
  File "/usr/lib/python3.10/logging/__init__.py", line 632, in 
formatException
traceback.print_exception(ei[0], ei[1], tb, None, sio)
  File "/usr/lib/python3.10/traceback.py", line 113, in print_exception
te = TracebackException(type(value), value, tb, limit=limit, 
compact=True)
  File "/usr/lib/python3.10/traceback.py", line 531, in __init__
need_context = cause is None and not e.__suppress_context__
AttributeError: 'NoneType' object has no attribute '__suppress_context__'

That method is documented as "This function should only be called from an 
exception handler.", but the same also happens when e.g. calling 
traceback.print_exc() (without a current exception) or 
traceback.print_exception(None, None, None). Both worked fine before 3.10 Alpha 
5, the code seems to do None-checks in other places, and typeshed also marks 
those arguments as Optional.

This seems to have been introduced in 
https://github.com/python/cpython/pull/24179 for bpo-42877.

--
components: Library (Lib)
messages: 386562
nosy: The Compiler, iritkatriel, vinay.sajip
priority: normal
severity: normal
status: open
title: 3.10a5 regression: AttributeError: 'NoneType' object has no attribute 
'__suppress_context__' in traceback.py
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



[issue43146] 3.10a5 regression: AttributeError: 'NoneType' object has no attribute '__suppress_context__' in traceback.py

2021-02-06 Thread Irit Katriel

Irit Katriel  added the comment:

Thanks, I’ll add the None check.

--

___
Python tracker 

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



[issue43143] Allow multiple assignment (i.e. tuple on LHS) in walrus operator

2021-02-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

+0 I think this is with worth considering.  Whenever the use case arises, the 
workaround is awkward.  Code would be clearer if assignment expressions were 
liberalized to allow unpacking.

The PEP aspired to avoid complex lvalues that might be hard to read or that had 
tricky semantics.  Unpacking is one the simpler cases and would be mostly 
harmless and sometimes beneficial (and not just for the uncommon case of 
wanting simultaneous assignment).

--
nosy: +emilyemorehouse, gvanrossum, rhettinger, tim.peters
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



[issue43071] IDLE: Windows 7 - Trackpad two-finger vertical scrolling is not recognized

2021-02-06 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

This issue appears to be quite different from #34047.  The latter partly 
involved two then recent tcl/tk versions known to still be buggy on Mac.  It 
then determined to be directly a matter of how IDLE was interpreting the delta 
attribute of tk mousewheel events on Mac, where its meaning is confusingly 
different from what .delta means on Windows and Linux.  

For this issue, tk Text scrolling in IDLE is known to work on Windows when 
using a functioning mouse with functioning wheel and functioning driver.  You, 
on the otherhand, are using a 'notably bad' driver for a non-mouse device.  My 
conclusion is that tcl/tk is not sending proper mousewheel events to tkinter in 
response vertical double finger motions.  I strongly suspect that it is not 
getting proper mousewheel events from Windows.

#34047 was determined to very likely be an IDLE issue when I posted test file 
tk_scroll.py that had no IDLE code and Tal responded in msg321258 that 
scrolling worked fine when running that file.  (It should work the same whether 
run directly with Python or from an IDLE editor.)  Please run the same test on 
your system.  (The follow-up tk_scroll2.py added a bit of IDLE code to see it 
*that* were the culprit.)

--

___
Python tracker 

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



[issue43071] IDLE: Windows 7 - Trackpad two-finger vertical scrolling is not recognized

2021-02-06 Thread Greg


Greg  added the comment:

I tested out tk_scroll.py (and tk_scroll2.py, for kicks) and I couldn't get 
that to scroll either. I tried both with and without the ttk line commented.

To my shame, it looks like that means you're spot on, and that it's an issue 
between my machine and tcl/tk.

Thanks for the help, and sorry to waste your time!

--

___
Python tracker 

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



[issue43147] Remove mention of "subcontrary mean" from the docs

2021-02-06 Thread Raymond Hettinger


New submission from Raymond Hettinger :

Let's improve the readability of the docs by removing the archaic term 
"subcontrary mean".  That is a bit saying that capacitors are sometimes called 
condensers.

I checked with a stats professor and he had never heard of the term.  Likewise, 
there was no mention in any of my stats books or math references (such as the 
CRC).  The docs for scipy.stats.hmean() do not use the term.   Googling for 
"subcontrary mean" only turns up a cross-reference in Wolfram Alpha".

--
assignee: steven.daprano
components: Documentation
messages: 386567
nosy: rhettinger, steven.daprano
priority: normal
severity: normal
status: open
title: Remove mention of "subcontrary mean" from the docs
versions: Python 3.10, Python 3.9

___
Python tracker 

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



[issue43147] Remove mention of "subcontrary mean" from the docs

2021-02-06 Thread Raymond Hettinger


Change by Raymond Hettinger :


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

___
Python tracker 

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



[issue43146] 3.10a5 regression: AttributeError: 'NoneType' object has no attribute '__suppress_context__' in traceback.py

2021-02-06 Thread Irit Katriel


Irit Katriel  added the comment:

There's another such issue due to PR 22610 // issue 26389:

>>> traceback.format_exception(None)
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Users\User\src\cpython-dev\lib\traceback.py", line 128, in 
format_exception
value, tb = _parse_value_tb(exc, value, tb)
  File "C:\Users\User\src\cpython-dev\lib\traceback.py", line 94, in 
_parse_value_tb
return exc, exc.__traceback__
AttributeError: 'NoneType' object has no attribute '__traceback__'

--

___
Python tracker 

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



[issue43146] 3.10a5 regression: AttributeError: 'NoneType' object has no attribute '__suppress_context__' in traceback.py

2021-02-06 Thread Irit Katriel


Change by Irit Katriel :


--
nosy: +ZackerySpytz, pablogsal

___
Python tracker 

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



[issue43148] Call sys.unraisablehook in the REPL when sys.excepthook is broken

2021-02-06 Thread Julian Berman

New submission from Julian Berman :

At the REPL, when sys.excepthook is broken (below by setting it to a 
non-callable), one sees:

```
⊙  python3.9

julian@Airm
Python 3.9.1 (default, Feb  2 2021, 22:54:59) 
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys; sys.excepthook = object(); asdf
Error in sys.excepthook:
TypeError: 'object' object is not callable

Original exception was:
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'asdf' is not defined
```

The implementation 
(https://github.com/python/cpython/blob/5f18c223391eef8c7d01241b51a7b2429609dd84/Python/pythonrun.c#L805-L817)
 seems to do so by reimplementing something like 3.8+'s sys.unraisablehook 
(well, technically it predates sys.unraisablehook by quite a while).

Seems like now that it exists, that code should now call sys.unraisablehook.

--
messages: 386569
nosy: Julian, vstinner
priority: normal
severity: normal
status: open
title: Call sys.unraisablehook in the REPL when sys.excepthook is broken
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



[issue43148] Call sys.unraisablehook in the REPL when sys.excepthook is broken

2021-02-06 Thread Carl Friedrich Bolz-Tereick


Change by Carl Friedrich Bolz-Tereick :


--
nosy: +Carl.Friedrich.Bolz

___
Python tracker 

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



[issue43146] 3.10a5 regression: AttributeError: 'NoneType' object has no attribute '__suppress_context__' in traceback.py

2021-02-06 Thread Irit Katriel


Change by Irit Katriel :


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

___
Python tracker 

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



[issue43149] Misleading error message for except with missing parens (3.10.a5)

2021-02-06 Thread Andre Roberge


New submission from Andre Roberge :

The following:

try:
pass
except ValueError, NameError as err:
pass

results in:

except ValueError, NameError as err:
 ^
SyntaxError: expected ':'

However, what is missing here are some parentheses surrounding the exception 
types.

--
messages: 386570
nosy: aroberge
priority: normal
severity: normal
status: open
title: Misleading error message for except with missing parens (3.10.a5)
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



[issue43145] Leak of locks in a subprocess

2021-02-06 Thread Yannick Jadoul


Change by Yannick Jadoul :


--
nosy: +YannickJadoul

___
Python tracker 

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



[issue43149] Misleading error message for except with missing parens (3.10.a5)

2021-02-06 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +lys.nikolaou, pablogsal

___
Python tracker 

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



[issue43150] Last empty string not removed in a list

2021-02-06 Thread Kumar Makala


New submission from Kumar Makala :

# Last empty string not removed from the list


str_list = ["Emma", "Jon", "", "Kelly","Eric", "", "","KXN",""]
for item in str_list:
if len(item) == 0:
str_list.remove(item)
print(len(str_list[-1]))

#Output
['Emma', 'Jon', 'Kelly', 'Eric', 'KXN', '']

--
messages: 386571
nosy: kumarmakala
priority: normal
severity: normal
status: open
title: Last empty string not removed in a list
type: behavior
versions: Python 3.8

___
Python tracker 

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



[issue43150] Last empty string not removed in a list

2021-02-06 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

This is not a language bug, it is a bug in your code: you are modifying the 
list as you iterate over it.

There are lots of ways to do that task correctly, perhaps the easiest is with a 
filter:

str_list = list(filter(bool, str_list))

or a list comprehension:

str_list = [s for s in str_list if s]

or by iterating over a copy of the list:

for item in str_list[:]:  # use slice syntax to make a copy
...

--
nosy: +steven.daprano
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue43150] Last empty string not removed in a list

2021-02-06 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

The problem here is that you are shortening the list as you walk along it, 
which means you skip items. You expected to visit:

"Emma", "Jon", "", "Kelly","Eric", "", "", "KXN", ""

in that order, but after visiting Emma, Jon and the first empty string, you 
delete the first empty string, which pushes every item down one position:

"Emma", "Jon", "Kelly","Eric", "", "", "KXN", ""

The next item is now Eric, not Kelly, because Kelly is in the position already 
visited. So the *string* Kelly gets skipped. After visiting Eric and the next 
empty string, everything gets pushed down another spot:

"Emma", "Jon", "Kelly","Eric", "", "KXN", ""

which moves the second empty string into the position that was already visited. 
The next item is now KXN, then the final empty string, which then deletes the 
*first remaining* empty string:

"Emma", "Jon", "Kelly","Eric", "KXN", ""

and now you have reached the end of the string and there is nothing more to do.

You can see for yourself the items which are visited:


>>> for item in str_list:
... print('item =', repr(item))
... if len(item) == 0:
... str_list.remove(item)
... 
item = 'Emma'
item = 'Jon'
item = ''
item = 'Eric'
item = ''
item = 'KXN'
item = ''


Here is perhaps a more clear way to see what you are doing wrong:

>>> str_list = ['a', 'x', 'b', 'x', 'c', 'x', 'd', 'x', 'e', 'f']
>>> for item in str_list:
... print(item, ''.join(str_list))
... if item == 'x':
... str_list.remove(item)
... 
a axbxcxdxef
x axbxcxdxef
x abxcxdxef
x abcxdxef
x abcdxef
f abcdef


Every time you delete an item, the list shrinks, everything moves down one 
position, and the next item gets skipped because it has been moved into the 
slot already looked at.

--

___
Python tracker 

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



[issue43149] Misleading error message for except with missing parens (3.10.a5)

2021-02-06 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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

___
Python tracker 

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



[issue43150] Last empty string not removed in a list

2021-02-06 Thread Kumar Makala


Kumar Makala  added the comment:

Thanks Steven!

--

___
Python tracker 

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



[issue16781] execfile/exec execution in other than global scope uses locals(), leading to undefined behavior

2021-02-06 Thread Terry J. Reedy


Change by Terry J. Reedy :


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

___
Python tracker 

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



[issue43151] is with literals in 3.8 release

2021-02-06 Thread Gary Litvin


New submission from Gary Litvin :

>>> x = 'a'
>>> x is 'a'
True
>>> if x is 'a':
print(x)

SyntaxError: "is" with a literal. Did you mean "=="?

How come?

--
messages: 386575
nosy: garylitvin
priority: normal
severity: normal
status: open
title: is with literals in 3.8 release
versions: Python 3.8, Python 3.9

___
Python tracker 

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



[issue16781] execfile/exec execution in other than global scope uses locals(), leading to undefined behavior

2021-02-06 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset 0ec57e25c918b859b9f8d464e34e0ac859c2f8b3 by Terry Jan Reedy in 
branch 'master':
bpo-16781: In 'exec' doc, add 'nonlocal' to 'yield' and 'return' (GH-2446)
https://github.com/python/cpython/commit/0ec57e25c918b859b9f8d464e34e0ac859c2f8b3


--

___
Python tracker 

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



[issue16781] execfile/exec execution in other than global scope uses locals(), leading to undefined behavior

2021-02-06 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 6.0 -> 7.0
pull_requests: +23264
pull_request: https://github.com/python/cpython/pull/24470

___
Python tracker 

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



[issue16781] execfile/exec execution in other than global scope uses locals(), leading to undefined behavior

2021-02-06 Thread miss-islington


Change by miss-islington :


--
pull_requests: +23265
pull_request: https://github.com/python/cpython/pull/24471

___
Python tracker 

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



[issue16781] execfile/exec execution in other than global scope uses locals(), leading to undefined behavior

2021-02-06 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

PR is based on 'Note:...' directly above.  I am still thinking about a patch 
for the namespace paragraph.

--
nosy:  -miss-islington
stage: patch review -> needs patch

___
Python tracker 

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



[issue16781] execfile/exec execution in other than global scope uses locals(), leading to undefined behavior

2021-02-06 Thread miss-islington


miss-islington  added the comment:


New changeset 920bf6a3a656e329c2bcbb761eb8c13c46c8cd05 by Miss Islington (bot) 
in branch '3.8':
bpo-16781: In 'exec' doc, add 'nonlocal' to 'yield' and 'return' (GH-2446)
https://github.com/python/cpython/commit/920bf6a3a656e329c2bcbb761eb8c13c46c8cd05


--
nosy: +miss-islington

___
Python tracker 

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



[issue43151] is with literals in 3.8 release

2021-02-06 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

This was a very intentional change from the commit 
3bcbedc9f1471d957a30a90f9d1251516b422416

It's not safe to check `x is y` when x and y are strings.
You should always use `x == y` for strings instead.
In CPython, if the names x and y both refer to the same underlying object, then 
`x is y` will return True.
In CPython, if the names x and y refer to two distinct string objects with 
equal values, then `x is y` will return False.
Which case happens is an implementation detail, and alternate Python 
implementations like PyPy could behave unexpectedly with such code.
As such, to prevent more incorrect code, this was changed to emit a 
SyntaxWarning in Python 3.8.

This is documented here:
https://docs.python.org/3/whatsnew/3.8.html#changes-in-python-behavior

In a python REPL, I believe SyntaxWarnings are by default promoted to 
SyntaxErrors. But when running a file with `python -Wa`, you just get the 
warning:

$ python -Wa ./a.py
.../a.py:2: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if x is 'a':
a

--
nosy: +Dennis Sweeney

___
Python tracker 

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



[issue43151] is with literals in 3.8 release

2021-02-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

As Dennis says, this is an intentional behavior and will help you avoid bugs.

--
nosy: +rhettinger
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue43151] is with literals in 3.8 release

2021-02-06 Thread Gary Litvin


Gary Litvin  added the comment:

Thank you for your responses. I understand the difference between == 
and "is" and the intentional change in 3.8. My question is about what 
seems to be inconsistent treatment in x is 'a' and if a is 'a': ...

At 12:49 AM 2/7/2021, Raymond Hettinger wrote:

>Raymond Hettinger  added the comment:
>
>As Dennis says, this is an intentional behavior and will help you avoid bugs.
>
>--
>nosy: +rhettinger
>resolution:  -> not a bug
>stage:  -> resolved
>status: open -> closed
>
>___
>Python tracker 
>
>___

--

___
Python tracker 

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



[issue43144] test_unicodedata: test_normalization uses network but doesn't depend on network resource

2021-02-06 Thread Dong-hee Na


Dong-hee Na  added the comment:

@arekm

Would you like to submit the patch through Github?

--
nosy: +corona10

___
Python tracker 

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



[issue43144] test_unicodedata: test_normalization uses network but doesn't depend on network resource

2021-02-06 Thread Dong-hee Na


Change by Dong-hee Na :


--
versions: +Python 3.10, Python 3.8

___
Python tracker 

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



[issue43152] warning: unused variable 'code'

2021-02-06 Thread Dong-hee Na


New submission from Dong-hee Na :

Python/ceval.c:4747:19: warning: unused variable 'code' [-Wunused-variable]
PyCodeObject *code = (PyCodeObject *)_co;


Very nit compiler warning but should be fixed ;)

--
components: Interpreter Core
messages: 386583
nosy: Mark.Shannon, corona10
priority: normal
severity: normal
status: open
title: warning: unused variable 'code'
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



[issue43152] warning: unused variable 'code'

2021-02-06 Thread Dong-hee Na


Change by Dong-hee Na :


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

___
Python tracker 

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



[issue43151] is with literals in 3.8 release

2021-02-06 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Gary, I cannot replicate that inconsistency in 3.9.0.


>>> x = "abc"
>>> x is "abc"
:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
True
>>> if x is "abc": pass
... 
:1: SyntaxWarning: "is" with a literal. Did you mean "=="?


I don't believe that you should be getting a SyntaxError at all, and both cases 
should give the same warning. Can you double-check your code, and if you 
confirm that they give a different result or a SyntaxError, let us know here. 
Otherwise Raymond and Dennis are correct: this is working correctly.

--
nosy: +steven.daprano

___
Python tracker 

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