[issue41114] "TypeError: unhashable type" could often be more clear

2020-09-27 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> I've noticed that Python beginners tend to find this really confusing.

No minor tweak to the exception message will make this go away.  For 
understanding to occur, the only way to forward is to learn a bit about 
hashability.  That is a step that every beginner must take.

Fortunately, the term "hashable" is listed in the glossary.  Also the error 
message itself is easily Googled:

   https://docs.python.org/3/glossary.html#term-hashable

   
https://www.google.com/search?q=TypeError%3A+unhashable+type%3A+%27dict%27=TypeError%3A+unhashable+type%3A+%27dict%27

I suggest that you take this to the python-ideas list.  While there is a valid 
concern that a new user may not understand the error message (this is 
unfortunately true for many our error messages), the proposals don't actually 
improve the situation.

The first proposal adds hard-to-implement context information that still 
doesn't tell a user what the issue is.  The second proposal repeats information 
that is already being shown.  Neither proposal explains what is meant by 
unhashable type, why it matters, what would be an allowable hashable type, or 
how to fix the problem (which is what the user really wants to know).

After a discussion on python-ideas, if a better proposal is found, feel free to 
reopen this issue.

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



[issue24427] subclass of multiprocessing Connection segfault upon attribute acces

2020-09-27 Thread William Pickard


William Pickard  added the comment:

You did just necro a 5 year old bug report...

--
nosy: +WildCard65

___
Python tracker 

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



[issue24427] subclass of multiprocessing Connection segfault upon attribute acces

2020-09-27 Thread William Pickard


Change by William Pickard :


--
nosy:  -WildCard65

___
Python tracker 

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



[issue41114] "TypeError: unhashable type" could often be more clear

2020-09-27 Thread Samuel Freilich


Samuel Freilich  added the comment:

> The user already knows

The example I link to in the initial description appears to be one case where 
the user does not in fact know.

I do think context that this restriction applies to dict key in particular is 
very relevant. The line could use the same type for both the key and the value 
in a dict assignment, for example.

> TypeError: unhashable type: 'dict'.  Consider using an int, str, tuple, or 
> frozenset.

That seems like a pretty reasonable wording, though I think mentioning 
"dictionary key" or "set item" specifically still helps.

It could also link to the documentation directly:
https://docs.python.org/3/glossary.html#term-hashable

Though other error messages don't generally follow that pattern.

> Saying it twice doesn't help.

As the comment you were responding to noted, putting it in the type implies 
there might be additional information in documentation (or at least provides a 
place in documentation to put that information). TypeError is too general to 
say something about that specifically:
https://docs.python.org/3/library/exceptions.html#TypeError

--

___
Python tracker 

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



[issue41756] Do not always use exceptions to return result from coroutine

2020-09-27 Thread Vladimir Matveev


Vladimir Matveev  added the comment:

Serhiy, AFAIR PyIter_Send in my PR appear only as a rename from placeholder 
`Name_TBD` and it still was specific to PyGenObjects. Do you mean something 
that was listed in https://bugs.python.org/msg377007 ?

--

___
Python tracker 

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



[issue41872] get_type_hints fails to resolve forward references in nested function

2020-09-27 Thread Guido van Rossum


Guido van Rossum  added the comment:

I've only seen it in test cases too -- that's one of the very few
situations where it makes sense to define a class inside a function.
(Creating a class is an expensive operation, so any function that expects
to be called more than once is better off moving the class out of the
function.)

--

___
Python tracker 

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



[issue30953] Fatal python error when jumping into except clause

2020-09-27 Thread ppperry


Change by ppperry :


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



[issue41872] get_type_hints fails to resolve forward references in nested function

2020-09-27 Thread Chris Withers


Chris Withers  added the comment:

The tough one is that no-one wants an ugly sys._getframe() call, but by 
avoiding it in the standard library, we force each library that needs this to 
have the ugly sys._getframe() call rather than it being an unpleasant 
implementation detail of get_type_hints that users of the function don't have 
to know about.

That said, I've only hit this so far when writing a unit test, but will update 
this issue if I see real-world cases of this.

--

___
Python tracker 

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



[issue14243] tempfile.NamedTemporaryFile not particularly useful on Windows

2020-09-27 Thread Evgeny


Evgeny  added the comment:

Hello, this is to let you know, that I have created a pull request for this 
issue

https://github.com/python/cpython/pull/22431

I am not really an experienced programmer, but I will give it a try

--
nosy: +ev2geny

___
Python tracker 

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



[issue41872] get_type_hints fails to resolve forward references in nested function

2020-09-27 Thread Guido van Rossum


Guido van Rossum  added the comment:

This cannot be helped (unless we were to add an ugly sys._getframe() call to 
get_type_hints(), which I don't want to do). The solution is to pass 
`localns=locals()`, e.g.

get_type_hints(foo, None, locals())

or

get_type_hints(foo, localns=locals())

--
keywords: +3.6regression
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



[issue41865] doc search for super().__init__() returns no useful results

2020-09-27 Thread Raymond Hettinger


Change by Raymond Hettinger :


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



[issue41861] Convert sqlite3 to PEP 384

2020-09-27 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
pull_requests: +21462
pull_request: https://github.com/python/cpython/pull/22428

___
Python tracker 

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



[issue23706] pathlib.Path.write_text should include a newline argument

2020-09-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It should work exactly as the newline argument of open(). Anything else would 
be surprising.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue41114] "TypeError: unhashable type" could often be more clear

2020-09-27 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> Do you think it would help if the exception was of type UnhashableType

That would not add more information. The message already says "unhashable 
type".  Saying it twice doesn't help.

--

___
Python tracker 

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



[issue23706] pathlib.Path.write_text should include a newline argument

2020-09-27 Thread Maxim Burov


Maxim Burov  added the comment:

For the newline parameter, what is the expected behaviour? To work as newline 
from io.open() which supports only so called "legal" newlines which are: None, 
'', '\n', '\r', and '\r\n', or to allow users use any sequence as newline hence 
do replacing before passing text to io.open()?

--

___
Python tracker 

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



[issue24427] subclass of multiprocessing Connection segfault upon attribute acces

2020-09-27 Thread Irit Katriel


Irit Katriel  added the comment:

I think this issue is out of date. 

1. I replaced the import statement in the script by "from 
multiprocessing.connection import Connection" and it gave "AttributeError: 
'Crash' object has no attribute 'bar'" rather than a segfault. 

2.  I can't find "ConnectionObject" in the current codebase.

--
components: +Interpreter Core
nosy: +iritkatriel
type:  -> crash

___
Python tracker 

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



[issue41871] Add PyList_Remove() in listobject.c

2020-09-27 Thread hai shi


hai shi  added the comment:

> You always can use PyObject_CallMethod(). It is not a method called in tight 
> loop for which the overhead of calling method is significant.
Thanks, serhiy. You are right.
To PR19069, it's fine to use `PyList_SetSlice` or `PyObject_CallMethod`.
We don't have the enough reason to add `PyList_Remove()`,so I decided close 
this bpo now.

PS: I attach a PR which have add `PyList_Remove` in here in case we will meet 
another appropriate user case somedays: 
https://github.com/python/cpython/compare/master...shihai1991:add_PyList_Remove?expand=1

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



[issue41872] get_type_hints fails to resolve forward references in nested function

2020-09-27 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +gvanrossum, levkivskyi

___
Python tracker 

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



[issue41842] Add codecs.unregister() to unregister a codec search function

2020-09-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

If add a function for unregistering a codec search function, it would be worth 
to add also a function for unregistering an error handler.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue13790] In str.format an incorrect error message for list, tuple, dict, set

2020-09-27 Thread Eric V. Smith


Change by Eric V. Smith :


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



[issue17490] Improve ast.literal_eval test suite coverage

2020-09-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

literal_eval() is not purposed to evaluate arbitrary arithmetic expressions. It 
is only purposed to handle strings produced by repr() of some simple builtin 
objects. repr(6j+3) is '(3+6j)', not '(6j+3)' and not '(6j--3)', so it accepts 
the former form and not the latters.

If Nick no longer works on this I propose to close this issue. literal_eval() 
supports now more types of expressions, but it is more strict in other cases. I 
have doubts that any test changes are applicable to the current code.

--

___
Python tracker 

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



[issue13790] In str.format an incorrect error message for list, tuple, dict, set

2020-09-27 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41872] get_type_hints fails to resolve forward references in nested function

2020-09-27 Thread Chris Withers


New submission from Chris Withers :

Reproducer:

def test_forward_type_references(self):
def foo(a: 'Foo') -> 'Bar': pass

class Foo: pass
class Bar: pass

get_type_hints(foo)


The above gives the following exception, rather than resolving the type:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/typing.py:1001: 
in get_type_hints
value = _eval_type(value, globalns, localns)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/typing.py:260: 
in _eval_type
return t._evaluate(globalns, localns)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/typing.py:464: 
in _evaluate
eval(self.__forward_code__, globalns, localns),
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   NameError: name 'Foo' is not defined

--
components: Library (Lib)
messages: 377569
nosy: cjw296
priority: normal
severity: normal
status: open
title: get_type_hints fails to resolve forward references in nested function
type: behavior
versions: Python 3.10, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue41871] Add PyList_Remove() in listobject.c

2020-09-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

You always can use PyObject_CallMethod(). It is not a method called in tight 
loop for which the overhead of calling method is significant.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue40471] Grammar typo in issubclass docstring

2020-09-27 Thread Irit Katriel


Irit Katriel  added the comment:

Should this PR be backported? Otherwise this issue can be closed.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41871] Add PyList_Remove() in listobject.c

2020-09-27 Thread hai shi


New submission from hai shi :

Do we need add PyList_Remove() in C level? same thing like list.remove().
As victor comment in: 
https://github.com/python/cpython/pull/19069#discussion_r491893466.

--
components: C API
messages: 377566
nosy: shihai1991, vstinner
priority: normal
severity: normal
status: open
title: Add PyList_Remove() in listobject.c
versions: Python 3.10

___
Python tracker 

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



[issue41870] Use PEP 590 vectorcall to speed up calls to bool()

2020-09-27 Thread Dong-hee Na


Change by Dong-hee Na :


--
components: +Interpreter Core

___
Python tracker 

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



[issue41870] Use PEP 590 vectorcall to speed up calls to bool()

2020-09-27 Thread Dong-hee Na


Change by Dong-hee Na :


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

___
Python tracker 

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



[issue41870] Use PEP 590 vectorcall to speed up calls to bool()

2020-09-27 Thread Dong-hee Na


New submission from Dong-hee Na :

bool type is well-used builtin types, I noticed that if we use vector call to 
bool type, it shows the awesome performance enhancement.

Mean +- std dev: [master] 91.4 us +- 3.3 us -> [vectorcall] 48.6 us +- 3.1 us: 
1.88x faster (-47%)

--
assignee: corona10
files: bench_bool.py
messages: 377565
nosy: corona10, vstinner
priority: normal
severity: normal
status: open
title: Use PEP 590 vectorcall to speed up calls to bool()
type: performance
versions: Python 3.10
Added file: https://bugs.python.org/file49475/bench_bool.py

___
Python tracker 

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



[issue41858] Fix incomplete line on optparse documentation

2020-09-27 Thread Emmanuel Arias


Emmanuel Arias  added the comment:

Thanks for the help and review!

--

___
Python tracker 

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



[issue39862] Why are the union relationships not implemented by default for ≤ and ≥?

2020-09-27 Thread Géry

Géry  added the comment:

Alright @rhettinger, here is the post: 
https://discuss.python.org/t/add-missing-default-implementations-of-le-and-ge/5327

--

___
Python tracker 

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



[issue17490] Improve ast.literal_eval test suite coverage

2020-09-27 Thread Irit Katriel


Irit Katriel  added the comment:

I just noticed that the patch by Serhiy has unit tests for this case, expecting 
ValueError. So this is apprently a feature and not a bug.

--

___
Python tracker 

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



[issue41861] Convert sqlite3 to PEP 384

2020-09-27 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset a937ab45d6af4f99ff16fec73d5d75d93c569456 by Erlend Egeberg 
Aasland in branch 'master':
bpo-41861: Convert _sqlite3 cache and node static types to heap types (GH-22417)
https://github.com/python/cpython/commit/a937ab45d6af4f99ff16fec73d5d75d93c569456


--
nosy: +vstinner

___
Python tracker 

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



[issue17490] Improve ast.literal_eval test suite coverage

2020-09-27 Thread Irit Katriel


Irit Katriel  added the comment:

I think this is a bug in literal_eval:

>>> 3+6j
(3+6j)
>>> 6j+3
(3+6j)
>>> ast.literal_eval('3+6j')
(3+6j)
>>> ast.literal_eval('6j+3')
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Users\User\src\cpython\lib\ast.py", line 105, in literal_eval
return _convert(node_or_string)
  File "C:\Users\User\src\cpython\lib\ast.py", line 104, in _convert
return _convert_signed_num(node)
  File "C:\Users\User\src\cpython\lib\ast.py", line 78, in _convert_signed_num
return _convert_num(node)
  File "C:\Users\User\src\cpython\lib\ast.py", line 69, in _convert_num
_raise_malformed_node(node)
  File "C:\Users\User\src\cpython\lib\ast.py", line 66, in _raise_malformed_node
raise ValueError(f'malformed node or string: {node!r}')
ValueError: malformed node or string: 


literal_eval accepts complex rhs, but not lhs: 
https://github.com/python/cpython/blame/master/Lib/ast.py#L99
if isinstance(left, (int, float)) and isinstance(right, complex):

This was introduced here, I'm not sure why:
https://github.com/python/cpython/commit/d8ac4d1d5ac256ebf3d8d38c226049abec82a2a0


In Nick's aborted patch, he removed that check.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41114] "TypeError: unhashable type" could often be more clear

2020-09-27 Thread Irit Katriel


Irit Katriel  added the comment:

Do you think it would help if the exception was of type UnhashableType 
(subclass of TypeError)? This would give the user a hint that this error is a 
thing which is worth looking for in the docs and understanding.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41858] Fix incomplete line on optparse documentation

2020-09-27 Thread Tal Einat


Tal Einat  added the comment:

Thanks for the report and the PR, Emmanuel!

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



[issue41863] IDLE shell not opening with 3.5 on Mac Mohave.

2020-09-27 Thread GJL


GJL  added the comment:

Thank you both. Decided to just download 3.8.6 instead of dealing with 3.5

IDLE shell works. Appreciate the help.

--

___
Python tracker 

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