[issue47079] Integral.denominator shouldn't return an int

2022-03-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

There is no such constrain. And no default implementation in this module 
depends on the constructor. It is important, the constructor is not the part of 
interfaces.

If you want to return the same type in denominator, just override it in your 
class.

--

___
Python tracker 

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



[issue47072] Database corruption with the shelve module

2022-03-26 Thread Hubert Tournier


Hubert Tournier  added the comment:

Hello,
Same results with Python 3.10.4:

[...]
Adding 185.220.102.6
Database has 62 records for 442368 bytes. Last record was 640 bytes long
Traceback (most recent call last):
  File "./shelve-test.py", line 84, in 
_verify_whois_cache()
  File "./shelve-test.py", line 63, in _verify_whois_cache
for key in db.keys():
  File "/usr/local/lib/python3.10/_collections_abc.py", line 881, in __iter__
yield from self._mapping
  File "/usr/local/lib/python3.10/shelve.py", line 95, in __iter__
for k in self.dict.keys():
SystemError: Negative size passed to PyBytes_FromStringAndSize
# freebsd-version -uk
13.0-RELEASE-p8
13.0-RELEASE-p10
# python3.10 --version
Python 3.10.4

The point at which the database breaks depends (from 50 to 500+ records), the 
size of the database doesn't seem to be relevant (from 400K to 1800K).

The size of the record *apparently* doesn't seem to be relevant (but I'm not 
100% sure it's the right figure), though I've had other shelve module uses 
without issues with many more records but much smaller and less complex.

--
Added file: https://bugs.python.org/file50703/shelve-test-3.10.zip

___
Python tracker 

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



[issue47079] Integral.denominator shouldn't return an int

2022-03-26 Thread Sergey B Kirpichev


Sergey B Kirpichev  added the comment:

> There is no such constrain.

Why not?  Any example where it does make sense to have different types for 
numerator and denominator?

--

___
Python tracker 

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



[issue47079] Integral.denominator shouldn't return an int

2022-03-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

There is no "why". There is a fact that there is no such constrain. Adding a 
new constrain may break existing code. If you want to add a constrain, add it 
in you code.

If you are interesting "why", try to search old archives for the history of 
creating that module. Maybe you will find something. Maybe you will need to dip 
deeper, in discussions about abstract classes and protocols.

--

___
Python tracker 

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



[issue47053] Reduce de-optimization in BINARY_OP_INPLACE_ADD_UNICODE

2022-03-26 Thread Dennis Sweeney


Change by Dennis Sweeney :


--
pull_requests: +30202
pull_request: https://github.com/python/cpython/pull/32122

___
Python tracker 

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



[issue32642] add support for path-like objects in sys.path

2022-03-26 Thread Nick Coghlan


Nick Coghlan  added the comment:

The import system is already complex, so I think the hesitation about allowing 
arbitrary Path-like objects is warranted. (For example: are importlib's caching 
semantics really valid for *arbitrary* path-like objects? An object can be 
path-like without being immutable)

Coercion on input (as Noam suggests) would have a much lower risk of unwanted 
side effects, as any dynamic behaviour would be resolved at insertion time.

--

___
Python tracker 

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



[issue47079] Integral.denominator shouldn't return an int

2022-03-26 Thread Sergey B Kirpichev


Sergey B Kirpichev  added the comment:

> There is no "why".

Why not?  Apparently, this is a documentation error, at least.  (And I doubt 
there are tests for default methods.)

> If you are interesting "why", try to search old archives for the history of 
> creating that module.

Thanks.  Sorry, I'll try harder.  So far I've found nothing to explain me why 
the Integral.denominator must be an 'int'.

--

___
Python tracker 

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



[issue32642] add support for path-like objects in sys.path

2022-03-26 Thread Noam Cohen


Noam Cohen  added the comment:

So I've got in mind a PyListObject subclass with calls to PyOS_FSPath before 
insert, append, extend and __getitem__.

But I feel like this is an overkill; also, extend function might be trickier to 
implement.
Do any of you have better idea?

--

___
Python tracker 

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



[issue47126] Update to canonical PEP URLs

2022-03-26 Thread Hugo van Kemenade


New submission from Hugo van Kemenade :

With the recent implementation https://peps.python.org/pep-0676/ the canonical 
URL for PEPs has changed from, for example:

https://www.python.org/dev/peps/pep-0008/

to:

https://peps.python.org/pep-0008/

Redirects are in place so the old links still work, but let's update the docs 
and docstrings to use the new canonical form. There's also a couple of places 
in code, so a BPO number is needed.

--
assignee: hugovk
components: Documentation, Library (Lib), Parser
messages: 416051
nosy: hugovk, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: Update to canonical PEP URLs
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



[issue32642] add support for path-like objects in sys.path

2022-03-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I think you are trying to solve a wrong problem.

> This wasn't obvious because Path objects appear as strings in normal debug 
> output, etc.

How is it?

>>> pathlib.Path('/usr/lib')
PosixPath('/usr/lib')
>>> [pathlib.Path('/usr/lib')]
[PosixPath('/usr/lib')]

I think the problem is with the debug output. Always use repr() for it, 
otherwise you will trick yourself.

> but the corresponding imports weren't working as they should

It would be easier to catch if it was never working with non-string. I think we 
should deprecate any non-string elements in sys.path.

As I shown above some code only works correctly with strings anyway.

--

___
Python tracker 

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



[issue32642] add support for path-like objects in sys.path

2022-03-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

pkgutil just skips non-string elements in sys.path.

for dir in search_path:
if not isinstance(dir, str):
continue

--

___
Python tracker 

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



[issue47079] Integral.denominator shouldn't return an int

2022-03-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

The module documentation should not contain all historical reasons of every 
design decision. If you are interesting why something was done in one way or 
another, do your research.

One of reasons is that type(self) not always have a constructor with compatible 
interface. So it may work for your integer-like type, but in general case.

--

___
Python tracker 

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



[issue47126] Update to canonical PEP URLs

2022-03-26 Thread Hugo van Kemenade


Change by Hugo van Kemenade :


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

___
Python tracker 

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



[issue47126] Update to canonical PEP URLs

2022-03-26 Thread Hugo van Kemenade


Change by Hugo van Kemenade :


--
assignee: hugovk -> 

___
Python tracker 

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



[issue47126] Update to canonical PEP URLs

2022-03-26 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Sphinx also changed the URL in https://github.com/sphinx-doc/sphinx/pull/10267

--
nosy: +xtreak

___
Python tracker 

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



[issue47079] Integral.denominator shouldn't return an int

2022-03-26 Thread Sergey B Kirpichev


Sergey B Kirpichev  added the comment:

> The module documentation should not contain all historical reasons of every 
> design decision.

Sure.  But, for example, there should be an explanation of why 
foo+foo.denominator could produce an error for a valid implementation of the 
Integral abc.  Such interoperability is not assumed by the docs, according to 
provided examples 
(https://docs.python.org/3/library/numbers.html#implementing-the-arithmetic-operations).

> One of reasons is that type(self) not always have a constructor with 
> compatible interface.

I hardly can imagine a constructor for the Integral type, which doesn't accept 
a python integer as an argument.

--

___
Python tracker 

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



[issue32642] add support for path-like objects in sys.path

2022-03-26 Thread Noam Cohen


Noam Cohen  added the comment:

that's why pre-insert conversion was suggested.
path-like objects could still be added to sys.path, while converting to str 
upon insert, preserving sys.path's bytes and strings only policy.

--

___
Python tracker 

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



[issue47127] Specialize call for c functions with METH_FASTCALL|METH_KEYWORDS

2022-03-26 Thread Kumar Aditya


New submission from Kumar Aditya :

Specialize call for c functions with METH_FASTCALL|METH_KEYWORDS flags.

It is the second largest PRECALL specialization failure as per the stats.

See 
https://github.com/faster-cpython/ideas/blob/main/stats.md#specialization-attempts-10

--
components: Interpreter Core
messages: 416058
nosy: Dennis Sweeney, Mark.Shannon, kumaraditya303
priority: normal
pull_requests: 30204
severity: normal
status: open
title: Specialize call for c functions with METH_FASTCALL|METH_KEYWORDS
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



[issue47079] Integral.denominator shouldn't return an int

2022-03-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Integral.__add__ is an abstract method, so it is a problem of your 
implementation.

--

___
Python tracker 

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



[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-03-26 Thread Nick Coghlan


Nick Coghlan  added the comment:

On the historical front, wraps & update_wrapper were only designed to handle 
true wrapper functions (i.e. those that don't change the calling signature).

For anything else (including partial), I considered it unlikely that the doc 
string would still be accurate, let alone any of the other metadata, so I 
didn't worry about supporting them.

That sais, if it's practical to make the results of combining the two less 
broken then I agree it would make sense to do so.

--

___
Python tracker 

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



[issue46964] The global config should not be stored on each interpreter

2022-03-26 Thread Nick Coghlan


Nick Coghlan  added the comment:

Moving the invariant bits would certainly make sense.

As Victor notes, though, some things (like whether to install the signal 
handlers) should be different.

--

___
Python tracker 

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



[issue47128] Enhance Argument Clinic's NoneType return converter to give `void`

2022-03-26 Thread Oleg Iarygin


New submission from Oleg Iarygin :

The attached PR makes the following possible (note that the impl has a `void` 
return type):

/*[clinic input]
_io._IOBase.writelines -> NoneType
lines: object
/
[clinic start generated code]*/

static void
_io__IOBase_writelines_impl(PyObject *self, PyObject *lines)
/*[clinic end generated code: output=f3feca36db72dbd1 
input=286ba711cb7291ad]*/

Previously, the return type would be `Object *` with generated replacement of 
non-Py_None values to NULL on the other side.

So now there is no need to track whether NULL or Py_None should be returned. Or 
should it be Py_RETURN_NONE? Argument Clinic does it by itself returning NULL 
on errors and PyNone otherwise:

static PyObject *
_io__IOBase_writelines(PyObject *self, PyObject *lines)
{
PyObject *return_value = NULL;

_io__IOBase_writelines_impl(self, lines);
if (PyErr_Occurred()) {
goto exit;
}
return_value = Py_None;
Py_INCREF(Py_None);

exit:
return return_value;
}

--
components: Argument Clinic
messages: 416062
nosy: arhadthedev, larry
priority: normal
severity: normal
status: open
title: Enhance Argument Clinic's NoneType return converter to give `void`
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



[issue47128] Enhance Argument Clinic's NoneType return converter to give `void`

2022-03-26 Thread Oleg Iarygin


Change by Oleg Iarygin :


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

___
Python tracker 

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



[issue47072] Database corruption with the shelve module

2022-03-26 Thread Hubert Tournier


Hubert Tournier  added the comment:

I modified the test program to better reflect the size of the data structures 
stored in shelve (sys.getsizeof() which I used was far off the real size).

I saw that the database was corrupted with big records, though even bigger 
previous records had not corrupted it. Records larger than 1K (mentioned in one 
of the other problem report) were routinely OK. Records larger than 4K (also 
mentioned on another PR) were sometimes OK.

When I took a problematic record and used it single alone or with few other 
records, no corruption occurred.

Any idea?

--
Added file: https://bugs.python.org/file50704/shelve-test-3.10-b.zip

___
Python tracker 

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



[issue47128] Enhance Argument Clinic's NoneType return converter to give `void`

2022-03-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

The function should return different values for success and error. Functions 
which do not do this have bad design.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue32642] add support for path-like objects in sys.path

2022-03-26 Thread Marc-Andre Lemburg


Marc-Andre Lemburg  added the comment:

On 26.03.2022 08:59, Nick Coghlan wrote:
> 
> The import system is already complex, so I think the hesitation about 
> allowing arbitrary Path-like objects is warranted. (For example: are 
> importlib's caching semantics really valid for *arbitrary* path-like objects? 
> An object can be path-like without being immutable)
> 
> Coercion on input (as Noam suggests) would have a much lower risk of unwanted 
> side effects, as any dynamic behaviour would be resolved at insertion time.

This is not only about the import system. Lots of Python code out there
manipulates sys.path or reads sys.path for various reasons and does not
expect Path objects as list members, since only strings and bytes
are allowed:

https://docs.python.org/3/library/sys.html#sys.path

Conversion to strings sounds like a good way to get the best out of
both worlds.

I'm just curious on how this would work. You'd like have to create a
list subclass for use with sys.path which applies the conversion
whenever a non-string member gets added. Or perhaps add helper methods
to Path objects to safely add their value to sys.path.

--
nosy: +lemburg

___
Python tracker 

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



[issue47128] Enhance Argument Clinic's NoneType return converter to give `void`

2022-03-26 Thread Oleg Iarygin


Oleg Iarygin  added the comment:

> The function should return different values for success and error

It does, and a `void` return type enforces it. Here is the trick:

> An important convention throughout the Python interpreter is the following: 
> when a function fails, it should set an exception condition and return an 
> error value (usually -1 or a NULL pointer).
>
> - 
> https://docs.python.org/3/extending/extending.html#intermezzo-errors-and-exceptions

Previously, a function could return NULL but forget to call `PyErr_*()`.  With 
`void`, however, the function has no other choise but to properly set the error 
indicator so the Clinic's part will see it and return NULL finishing the 
convention.

--

___
Python tracker 

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



[issue47126] Update to canonical PEP URLs

2022-03-26 Thread Hugo van Kemenade


Hugo van Kemenade  added the comment:

Here's a devguide PR: https://github.com/python/devguide/pull/822

--

___
Python tracker 

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



[issue46126] Unittest output drives developers to avoid docstrings

2022-03-26 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

I've confirmed that prior to the patch in PR 30194, the location of the failure 
was indeed reported. It was just not reported on the same line:

```
cpython main $ git log -1
commit 3e93af0b06cada874c4a16868b6f863b599919f2 (HEAD -> main)
Author: Jason R. Coombs 
Date:   Sat Mar 26 10:45:58 2022 -0400

Revert "bpo-46126: Disable 'descriptions' when running tests internally. 
(GH-30194)"

This reverts commit a941e5927f7f2540946813606c61c6aea38db426.
cpython main $ git diff
diff --git a/Lib/test/test_importlib/test_metadata_api.py 
b/Lib/test/test_importlib/test_metadata_api.py
index b3627cbb75..7e3bb09cf2 100644
--- a/Lib/test/test_importlib/test_metadata_api.py
+++ b/Lib/test/test_importlib/test_metadata_api.py
@@ -90,8 +90,11 @@ def test_entry_points_distribution(self):
 self.assertEqual(ep.dist.version, "1.0.0")
 
 def test_entry_points_unique_packages(self):
-# Entry points should only be exposed for the first package
-# on sys.path with a given name.
+"""
+Entry points should only be exposed for the first package
+on sys.path with a given name.
+"""
+raise ValueError("Failing on purpose")
 alt_site_dir = self.fixtures.enter_context(fixtures.tempdir())
 self.fixtures.enter_context(self.add_sys_path(alt_site_dir))
 alt_pkg = {
cpython main $ ./python.exe -E -We -m test -v test_importlib | grep 
entry_points_unique_packages
test_entry_points_unique_packages 
(test.test_importlib.test_metadata_api.APITests)
ERROR: test_entry_points_unique_packages 
(test.test_importlib.test_metadata_api.APITests)
  File 
"/Users/jaraco/code/public/cpython/Lib/test/test_importlib/test_metadata_api.py",
 line 97, in test_entry_points_unique_packages
test test_importlib failed
```

The description is given _in addition_ to the location of the test.

That means the concern reported in #302 was actually invalid.

I also was under the false impression that the description was masking the test 
location, but instead, it's just enhancing it (while also injecting a newline).

Given this renewed understanding, I believe it's appropriate to back out the PR.

> I think the situation and the discussion should be summarized on python-dev!

Great suggestion. Will do.

--

___
Python tracker 

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



[issue47129] Improve errors messages in f-string syntax errors

2022-03-26 Thread Maciej Górski

New submission from Maciej Górski :

When an empty expression is provided in curly brackets inside an f-string we 
get Syntax Error: "f-string: empty expression not allowed".


This is correct, however error with the same message is raised in the following 
cases: f"{!foo}", f"{!}", f"{:bar}", f"{=}", etc.
For example, should someone make an error and try to negate an expression with 
'!' instead of 'not' (i.e. f"{!True}"), they would get a confusing error, 
saying that the expression is empty, when it isn't. 

I propose we raise an error with the message: "f-string: optional specifier 
'%c' must follow a non-empty expression.

--
components: Parser
messages: 416069
nosy: lys.nikolaou, macgors, pablogsal
priority: normal
severity: normal
status: open
title: Improve errors messages in f-string syntax errors

___
Python tracker 

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



[issue47129] Improve errors messages in f-string syntax errors

2022-03-26 Thread Maciej Górski

Change by Maciej Górski :


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

___
Python tracker 

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



[issue46126] Unittest output drives developers to avoid docstrings

2022-03-26 Thread Jason R. Coombs


Change by Jason R. Coombs :


--
resolution:  -> works for me

___
Python tracker 

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



[issue47129] Improve errors messages in f-string syntax errors

2022-03-26 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
nosy: +eric.smith

___
Python tracker 

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



[issue46126] Unittest output drives developers to avoid docstrings

2022-03-26 Thread Jason R. Coombs


Change by Jason R. Coombs :


--
pull_requests: +30208
pull_request: https://github.com/python/cpython/pull/32128

___
Python tracker 

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



[issue47117] repl segfaults on non utf-8 input

2022-03-26 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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

___
Python tracker 

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



[issue47117] repl segfaults on non utf-8 input

2022-03-26 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Ah yes, we have been defeated by half an emoji :)

--

___
Python tracker 

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



[issue47130] mro and super don't feel so pythonic

2022-03-26 Thread malmiteria


New submission from malmiteria :

Hi,

Before anything, i made a github repository about this topic here : 
https://github.com/malmiteria/super-alternative-to-super

The core of what i wanna discuss here is that i don't think mro and super 
(mainly because it relies on mro) are very pythonic. Mainly that some behaviors 
of the mro are too implicit, and are silencing what really should be errors.



Let me explain :
in case of multiple inheritence, resolving a child method from it's parent 
isn't an obvious task, and mro comes as a solution to that. However, i don't 
understand why we don't let the programmer solve it. I think this is similar to 
a merge conflict, and not letting the programmer resolve the conflict feels 
like silencing an error. This is especially infuriating when you realise that 
mro doesn't solve all possible scenarios, and then, simply refuses the 
opportunity to solve it to the programmer.
Then, super relying on mro gives off some weird behaviors, mainly, it's 
possible for a child definition to affect what a call to super means in it's 
parent. This feels like a side effect (which is the 'too implicit' thing i 
refer to).
I also don't understand why we can't simply pass the parent targeted as 
argument to super, instead of having no argument, or having to pass the current 
class and instances as argument :
super(child) is a proxy to parent, when super(parent) would make more sense to 
be the proxy to parent, in my mind.

I dive in more depths about those topics in the readme of the github repository 
i linked at the top of this comment.



what i propose is a solution that would follow those rules:

The mro alternative, which i called explicit method resolution aka EMR (which 
is probably not a good name since i apply it, as mro, to all class attributes), 
follow those rules :
 1) Straightforward case : the class definition has the method / attribute : 
this is the one EMR should resolve to
 2) Not found : the method / attribute can't be resolved in the class itself, 
or by any of it's parents, then it should raise an AttributeError
 3) Only on parent : the method / attribute can't be resolved in the class 
itself, and can only be resolved by one of it's parents, this is the one EMR 
should resolve to
 4) Multiple parent : the method / attribute can't be resolved in the class 
itself, and can be resolved by at least 2 of it's parents, then an 
ExplicitResolutionRequired error should be raised
 5) Transimittin errors : the method / attribute can't be resolved in the class 
itself, and one parent at least raises an ExplicitResolutionRequired error, 
then it should raise an ExplicitResolutionRequired error
 6) (optional?) Single source : when multiple parent can resolve a method from 
a single source (in case of diamond shape inheritence), the 
ExplicitResolutionRequired  is not needed

The super alternative, which i called __as_parent__ should follow those rules :
 1) reliability : the target __as_parent__ points to should not depend on 
anything other than the argument passed to it
 2) expliciteness : in case of multiple inheritence, the parent targetted 
should be passed as an argument to the __as_parent__ method.
 3) impliciteness : in case of simple inheritence, it is not needed to specify 
the parent targeted (since there can only be one, and it make it closer to the 
actual behavior of super in most cases)
 4) ancestors as targets : should be able to target ancestors, either direct or 
not (which is needed in case two grandparent define a method that a single 
parent share, there would be no other way to solve the 
ExplicitResolutionRequired otherwise)



this solution has a few advantages in my mind :
 - the current mro and super are more tightly coupled than the emr and 
__as_parent__ i propose here
 - the __as_parent__ is more reliable than super in its behavior, and should 
lead to an easier learning curve
 - the emr i propose as a replacement to mro allows for some inheritence tree 
mro doesn't allow.
 - the __as_parent__ method being able to target specific parent allows for 
different methods to visit the parents in different order easily, which today 
would be harder, since the parent visiting order is tightly coupled to the 
class definition
 - with emr, in case of problematic resolution, an error is raised to tell you 
about the problem, and ask you for explicit resolution, the current solution 
doesn't, which can lead to surprises closer to production environment.



A few possible downsides :
 - the transition would be a pain to deal with
 - the current mro allows for dependencies injection in the inheritence tree. I 
believe this feature should be untied from super and mro, but it would require 
some work.
 - the current super and mro are old enough to have been faced with issues and 
having been updated to solve those issues down the line. Any alternative would 
have to face those issues again and new ones down the line
 - any coexistence between those two solutio

[issue47117] repl segfaults on non utf-8 input

2022-03-26 Thread miss-islington


miss-islington  added the comment:


New changeset 26cca8067bf5306e372c0e90036d832c5021fd90 by Pablo Galindo Salgado 
in branch 'main':
bpo-47117: Don't crash if we fail to decode characters when the tokenizer 
buffers are uninitialized (GH-32129)
https://github.com/python/cpython/commit/26cca8067bf5306e372c0e90036d832c5021fd90


--
nosy: +miss-islington

___
Python tracker 

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



[issue47130] mro and super don't feel so pythonic

2022-03-26 Thread Ken Jin


Ken Jin  added the comment:

Hi @mamliteria, this is the bug tracker for CPython. I understand that you have 
suggestions to improve super(), but feature suggestions usually go on the 
python-ideas mailing list [1]. So you might want to post on there instead.

If you're interested, the MRO creation algorithm uses C3 linearization[2] so 
the output is predictable.

Also maybe the 2-argument form of super() will help. It should cover most cases 
that you propose with __as_parent__.

[1] https://mail.python.org/mailman3/lists/python-ideas.python.org/
[2] https://en.wikipedia.org/wiki/C3_linearization

--
nosy: +kj
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



[issue43224] Add support for PEP 646

2022-03-26 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:


New changeset e8e737bcf6d22927caebc30c5d57ac4634063219 by Matthew Rahtz in 
branch 'main':
bpo-43224: Implement PEP 646 grammar changes (GH-31018)
https://github.com/python/cpython/commit/e8e737bcf6d22927caebc30c5d57ac4634063219


--

___
Python tracker 

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



[issue47129] Improve errors messages in f-string syntax errors

2022-03-26 Thread Eric V. Smith


Eric V. Smith  added the comment:

I'm not convinced this is an improvement. I don't think someone trying '!' in 
an f-string expression happens often enough to worry about that specific error 
message.

And a generic "optional specifier" isn't great. If we're going to do this, it 
should reflect the actual thing that's present: a conversion specifier, a 
format specifier, or debug specifier. And "optional" doesn't add anything, 
since it's actually present in this string.

I'll give it some more thought. I can't come up with an error message I 
actually like. The focus still needs to be on the empty expression.

--
assignee:  -> eric.smith

___
Python tracker 

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



[issue46964] The global config should not be stored on each interpreter

2022-03-26 Thread STINNER Victor


STINNER Victor  added the comment:

> Moving the invariant bits would certainly make sense.

IMO it's convenient to have a single structure for all "configuration", even if 
a few parameters are expected to be the same in all interpreters.

Python/initconfig.c is already a long C file. It contains a lot of code to copy 
members, converts them from a dict/to a dict, check consistency, etc.

It's also a little bit annoying (for me) to have a separated PyPreConfig 
structure int Python/preconfig.c which shares some code (like the 
"_PyPreCmdline" thing to parse "common" command line options).

Well, that's the opinon of the author of PEP 587, biaised obviously ;-)

--

___
Python tracker 

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



[issue47117] repl segfaults on non utf-8 input

2022-03-26 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +30210
pull_request: https://github.com/python/cpython/pull/32130

___
Python tracker 

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



[issue47129] Improve errors messages in f-string syntax errors

2022-03-26 Thread Maciej Górski

Maciej Górski  added the comment:

Understandable. In this case I can maybe propose something along the lines of 
"f-string: empty expression not allowed (Conversion specifier '!' can only 
follow non-empty expressions)", and so on for each of the specifiers.

This way the original message is still present and we just add some more 
information. I'm open to any of your ideas.

--

___
Python tracker 

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



[issue27929] asyncio.AbstractEventLoop.sock_connect broken for AF_BLUETOOTH

2022-03-26 Thread Vincent Bernat


Change by Vincent Bernat :


--
keywords: +patch
nosy: +bernat
nosy_count: 4.0 -> 5.0
pull_requests: +30211
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/32131

___
Python tracker 

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



[issue32642] add support for path-like objects in sys.path

2022-03-26 Thread Eryk Sun


Eryk Sun  added the comment:

> I've got in mind a PyListObject subclass with calls to PyOS_FSPath 
> before insert, append, extend and __getitem__.

The sys module doesn't prevent rebinding sys.path. Most code I think is careful 
to update sys.path. But surely some code replaces it with a new list instead of 
updating via insert(), append(), extend(), or updating a slice such as 
`sys.path[:] = new_path`. For example, ModifiedInterpreter.transfer_path() in 
Lib/idlelib/pyshell.py rebinds sys.path. It doesn't have to, but it does.

--
nosy: +eryksun

___
Python tracker 

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



[issue47117] repl segfaults on non utf-8 input

2022-03-26 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 27ee43183437c473725eba00def0ea7647688926 by Pablo Galindo Salgado 
in branch '3.10':
[3.10] bpo-47117: Don't crash if we fail to decode characters when the 
tokenizer buffers are uninitialized (GH-32129) (GH-32130)
https://github.com/python/cpython/commit/27ee43183437c473725eba00def0ea7647688926


--

___
Python tracker 

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



[issue47117] repl segfaults on non utf-8 input

2022-03-26 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Thanks for the report, Jon!

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



[issue46126] Unittest output drives developers to avoid docstrings

2022-03-26 Thread Ethan Furman


Ethan Furman  added the comment:

Perhaps we could make an enhancement then?  Having the extra information on a 
separate line is, at least for me, very jarring -- as in, I hadn't figured out 
that that was the way it was done until Inadasan pointed it out.

Perhaps a command-line switch to enable having it all on one line?  That would 
also help when grepping.  (I would propose it to be the default behavior, but I 
can see that that would result in very long lines.)

--

___
Python tracker 

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



[issue47131] Speedup test_unparse

2022-03-26 Thread Jeremy Kloth


New submission from Jeremy Kloth :

The string building and comparing of ast.dump() causes significant slowdowns on 
the large ASTs produced when doing the roundtrip test on the stdlib.

This PR avoids that cost by doing a direct node traversal and comparison.  It 
results in a 33% runtime improvement on machines to which I have access.

--
components: Tests
messages: 416082
nosy: jkloth
priority: normal
severity: normal
status: open
title: Speedup test_unparse
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



[issue47132] Move tests from setobject.c to _testcapimodule

2022-03-26 Thread Oleg Iarygin


New submission from Oleg Iarygin :

Currently, tests for PySet/PyFrozenSet C API are defined in Objects/setobject.c 
and available via set.test_c_api().

Moving them to, for example, _testcapimodule gives the following advantanges:

- an internal, CPython-specific method stops being available in a public 
interface of the set class

- CPython already has tests grouped into dedicated packages

- the target package undefines NDEBUG thus making asserts available in release 
builds

- a user may choose to omit the tests from a build not carrying them around

- a file of 2.5k lines of codes becomes 152 lines smaller.

--
components: C API, Tests
messages: 416083
nosy: arhadthedev
priority: normal
severity: normal
status: open
title: Move tests from setobject.c to _testcapimodule
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



[issue47131] Speedup test_unparse

2022-03-26 Thread Jeremy Kloth


Change by Jeremy Kloth :


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

___
Python tracker 

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



[issue47131] Speedup test_unparse

2022-03-26 Thread Jeremy Kloth


Change by Jeremy Kloth :


--
nosy: +vstinner
type:  -> performance

___
Python tracker 

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



[issue47089] Avoid sporadic failure of test_compileall on Windows

2022-03-26 Thread Jeremy Kloth


Change by Jeremy Kloth :


--
nosy: +vstinner

___
Python tracker 

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



[issue47132] Move tests from setobject.c to _testcapimodule

2022-03-26 Thread Oleg Iarygin


Change by Oleg Iarygin :


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

___
Python tracker 

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



[issue47116] Use _PyLong_FromUnsignedChar in bytearrayobject.c

2022-03-26 Thread Dennis Sweeney


Dennis Sweeney  added the comment:


New changeset c23ddf5ec229b7302437a1cf32d366df5cc5b837 by Pieter Eendebak in 
branch 'main':
bpo-47116: use _PyLong_FromUnsignedChar instead of PyLong_FromLong (GH-32110)
https://github.com/python/cpython/commit/c23ddf5ec229b7302437a1cf32d366df5cc5b837


--
nosy: +Dennis Sweeney

___
Python tracker 

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



[issue47095] Prefer libb2 over vendored copy of blake2

2022-03-26 Thread Christian Heimes


Christian Heimes  added the comment:


New changeset b16b6bb8dacc41e9e569783890b0c88fcd3b24e8 by Christian Heimes in 
branch 'main':
bpo-47095: Use libb2 to provide blake2 implementation (GH-32059)
https://github.com/python/cpython/commit/b16b6bb8dacc41e9e569783890b0c88fcd3b24e8


--

___
Python tracker 

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



[issue26120] pydoc: move __future__ imports out of the DATA block

2022-03-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I am positive about this idea, but we must also think about the possible 
negative consequences. For example, the future annotations will be included in 
the star-import by default and can override some global names. The fact that 
some names not visible in the module help can override global names can be 
confusing.

I think it should be discussed with a wider auditory.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue47095] Prefer libb2 over vendored copy of blake2

2022-03-26 Thread Christian Heimes


Change by Christian Heimes :


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



[issue27929] asyncio.AbstractEventLoop.sock_connect broken for AF_BLUETOOTH

2022-03-26 Thread Ned Deily


Change by Ned Deily :


--
nosy: +asvetlov -ned.deily
versions: +Python 3.11 -Python 3.5, Python 3.6, 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



[issue47061] Deprecate modules listed in PEP 594

2022-03-26 Thread Brett Cannon


Change by Brett Cannon :


--
pull_requests: +30214
pull_request: https://github.com/python/cpython/pull/32134

___
Python tracker 

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



[issue47116] Use _PyLong_FromUnsignedChar in bytearrayobject.c

2022-03-26 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

Thanks!

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



[issue46126] Unittest output drives developers to avoid docstrings

2022-03-26 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

My goal with this issue is to simply unblock the use of docstrings in Python 
tests. I believe with the work above and the proposed published post, I've 
accomplished that goal. I've already spent more time than I'd hoped on this 
issue and would like to resolve it at its original scope.

I do see how this issue reveals some deficiencies with the current UI/UX, and 
I'd welcome a separate feature request to address those deficiencies. I'll even 
help draft the bug report on request.

--

___
Python tracker 

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



[issue47098] sha3: Replace Keccak Code Package with tiny_sha3

2022-03-26 Thread Christian Heimes


Christian Heimes  added the comment:


New changeset 5fd8c574e016aec85725ddc5ced8742267b0e1b3 by Christian Heimes in 
branch 'main':
bpo-47098: Replace Keccak Code Package with tiny_sha3 (GH-32060)
https://github.com/python/cpython/commit/5fd8c574e016aec85725ddc5ced8742267b0e1b3


--

___
Python tracker 

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



[issue47098] sha3: Replace Keccak Code Package with tiny_sha3

2022-03-26 Thread Illia Volochii


Change by Illia Volochii :


--
nosy: +illia-v
nosy_count: 2.0 -> 3.0
pull_requests: +30215
pull_request: https://github.com/python/cpython/pull/28768

___
Python tracker 

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



[issue47098] sha3: Replace Keccak Code Package with tiny_sha3

2022-03-26 Thread Illia Volochii


Change by Illia Volochii :


--
pull_requests: +30216
pull_request: https://github.com/python/cpython/pull/24601

___
Python tracker 

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



[issue47133] enhance unittest to show test name and docstring on one line

2022-03-26 Thread Ethan Furman


New submission from Ethan Furman :

When running unittest with the -v flag, if a test has errors, and has a 
docstring, the test name is shown on one line, and the docstring is shown on 
the next line -- and the ERROR word is shown with the docstring.

What this means is that:
- the test name is easily missed by anyone who isn't aware of that (I only 
recently found out when someone else pointed it out to me)
- grepping for ERROR doesn't reveal the test name, necessitating a search 
through the testing code to find the test that failed

There are two possible solutions, and the selection of which one should be 
discussed on python-dev:
- print the name and docstring, and ERROR, all on one line; or
- provide a command-line switch to select that behavior

---

For the experienced developers who see this:  please leave the issue for one of 
the new developers subscribed to core-mentorship.  Thank you.

--
components: Tests
messages: 416090
nosy: ethan.furman
priority: low
severity: normal
stage: needs patch
status: open
title: enhance unittest to show test name and docstring on one line
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



[issue46126] Unittest output drives developers to avoid docstrings

2022-03-26 Thread Ethan Furman


Ethan Furman  added the comment:

That makes sense.

issue47133 created.

--

___
Python tracker 

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



[issue47133] enhance unittest to show test name and docstring on one line

2022-03-26 Thread Ethan Furman


Change by Ethan Furman :


--
assignee:  -> ethan.furman

___
Python tracker 

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



[issue43323] UnicodeEncodeError: surrogates not allowed when parsing invalid charset

2022-03-26 Thread Martin Dengler


Change by Martin Dengler :


--
nosy: +mdengler

___
Python tracker 

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



[issue43818] Email does not apply policy to multipart messages with defects

2022-03-26 Thread Martin Dengler


Change by Martin Dengler :


--
nosy: +mdengler

___
Python tracker 

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



[issue47133] enhance unittest to show test name and docstring on one line

2022-03-26 Thread Irit Katriel


Change by Irit Katriel :


--
keywords: +easy

___
Python tracker 

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



[issue43323] UnicodeEncodeError: surrogates not allowed when parsing invalid charset

2022-03-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is interesting that you get an UnicodeEncodeError when try to decode. Could 
the charser name contain non-ascii characters?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue47134] Document the meaning of the number in OverflowError

2022-03-26 Thread Steven D'Aprano


New submission from Steven D'Aprano :

OverflowError sometimes (but not always) includes some sort of numeric code:

>>> 1e+300 ** 2
Traceback (most recent call last):
  File "", line 1, in 
OverflowError: (34, 'Numerical result out of range')

but the meaning of the 34 is not documented:

https://docs.python.org/3/library/exceptions.html#OverflowError

help(OverflowError) is no more insightful, saying only:

__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Other OverflowError exceptions do not include the numeric code:

>>> math.exp(1)
Traceback (most recent call last):
  File "", line 1, in 
OverflowError: math range error

Is it an error code from C? Something to do with the number of digits of 
precision? An easter-egg to do with The Count Of Monte Cristo?

--
assignee: docs@python
components: Documentation
messages: 416093
nosy: docs@python, steven.daprano
priority: normal
severity: normal
status: open
title: Document the meaning of the number in OverflowError
type: enhancement
versions: Python 3.10, Python 3.11, 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



[issue47133] enhance unittest to show test name and docstring on one line

2022-03-26 Thread Itay Yeshaya


Itay Yeshaya  added the comment:

I would like to work on this.

--
nosy: +itay.yeshaya

___
Python tracker 

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



[issue47129] Improve errors messages in f-string syntax errors

2022-03-26 Thread Eric V. Smith


Eric V. Smith  added the comment:

>From a suggestion by @Jelle on the python discord server: how about just 
>"f-string: expression required before '!'"?

--

___
Python tracker 

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



[issue47134] Document the meaning of the number in OverflowError

2022-03-26 Thread Eryk Sun


Eryk Sun  added the comment:

The error code for `1e+300 ** 2` is ERANGE, from calling libm pow(). Since 
pow() returns a double, there's no way to indicate an error in the return 
value. Instead, C errno is set to 0 beforehand and checked for a non-zero error 
value after the call. If the error code isn't ERANGE, then float.__pow__() 
raises ValueError instead of OverflowError. Here's the relevant snippet from 
float_pow() in Objects/floatobject.c:

/* Now iv and iw are finite, iw is nonzero, and iv is
 * positive and not equal to 1.0.  We finally allow
 * the platform pow to step in and do the rest.
 */
errno = 0;
ix = pow(iv, iw);
_Py_ADJUST_ERANGE1(ix);
if (negate_result)
ix = -ix;

if (errno != 0) {
/* We don't expect any errno value other than ERANGE, but
 * the range of libm bugs appears unbounded.
 */
PyErr_SetFromErrno(errno == ERANGE ? PyExc_OverflowError :
 PyExc_ValueError);
return NULL;
}
return PyFloat_FromDouble(ix);

Here's a direct example using ctypes:

import ctypes
import errno

libm = ctypes.CDLL('libm.so.6', use_errno=True)
libm.pow.argtypes = (ctypes.c_double, ctypes.c_double)
libm.pow.restype = ctypes.c_double

>>> errno.ERANGE
34
>>> ctypes.set_errno(0)
0
>>> libm.pow(1e300, 2)
inf
>>> ctypes.get_errno() == errno.ERANGE
True

--
nosy: +eryksun

___
Python tracker 

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



[issue47133] enhance unittest to show test name and docstring on one line

2022-03-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Issue14265, issue46126.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue14265] Fully qualified test name in failure output

2022-03-26 Thread Ethan Furman


Ethan Furman  added the comment:

Hopefully somebody on the core-mentorship list can move this forward by 
converting to a PR and reviewing.

If @palaviv is still active the review itself will still be useful.

--
assignee: michael.foord -> ethan.furman
keywords: +easy -patch
nosy: +ethan.furman
stage:  -> patch review
versions: +Python 3.11 -Python 3.6

___
Python tracker 

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



[issue47133] enhance unittest to show test name and docstring on one line

2022-03-26 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

I don't think this change of behaviour should be accepted without discussion, 
and I'm not sure why you think Python-Dev is the right place, rather than here. 

Messing around with unittest and docstrings has already caused issues in the 
past:

https://docs.python.org/3/library/unittest.html#unittest.TestCase.shortDescription

so perhaps we shouldn't break what's not broken?


And frankly, I don't see why the current behaviour is a problem, although maybe 
that's because the way I use unittest is different from the way you use it. 
Grepping the output for errors? Why run verbose mode if you aren't going to 
read the whole output? Seems very odd.

Ethan says: "the test name is easily missed by anyone who isn't aware of that"

Surely the solution to that is education, not changing unittest? Now you are 
aware of it, and the test name is no longer "easily missed".

If it ever was. To me, it is plain as day. Here is some typical output:


[steve ~]$ python3.10 -m unittest -v mathlib/testing/test_utils.py
test_broken_doc (mathlib.testing.test_utils.TestMinmax)
This is a docstring ... ERROR
test_broken_nodoc (mathlib.testing.test_utils.TestMinmax) ... ERROR
test_empty_iterable (mathlib.testing.test_utils.TestMinmax) ... ok
[additional passing tests ommitted for brevity]

==
ERROR: test_broken_doc (mathlib.testing.test_utils.TestMinmax)
This is a docstring
--
Traceback (most recent call last):
  File "/home/steve/Desktop/mathlib/testing/test_utils.py", line 20, in 
test_broken_doc
self.assertEqual(1, x)
NameError: name 'x' is not defined

==
ERROR: test_broken_nodoc (mathlib.testing.test_utils.TestMinmax)
--
Traceback (most recent call last):
  File "/home/steve/Desktop/mathlib/testing/test_utils.py", line 24, in 
test_broken_nodoc
self.assertEqual(1, x)
NameError: name 'x' is not defined

--
Ran 10 tests in 0.004s

FAILED (errors=2)


Errors are listed twice, once in the summary, and the second time in the 
details section showing the traceback. Note that if you just grep for ERROR you 
get the result you want:

[steve ~]$ python3.10 -m unittest -v mathlib/testing/test_utils.py |& grep ERROR
This is a docstring ... ERROR
test_broken_nodoc (mathlib.testing.test_utils.TestMinmax) ... ERROR
ERROR: test_broken_doc (mathlib.testing.test_utils.TestMinmax)
ERROR: test_broken_nodoc (mathlib.testing.test_utils.TestMinmax)


So I am having trouble seeing what the problem here is.

--
nosy: +steven.daprano

___
Python tracker 

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



[issue47133] enhance unittest to show test name and docstring on one line

2022-03-26 Thread Ethan Furman


Ethan Furman  added the comment:

I proposed a discussion to python-dev to increase the odds that folks with an 
interest could chime in.  Not everyone follows the new-bugs list.

I find having the output on two lines counter-intuitive -- I was expecting one 
line per test, and indeed my experience seemed to support that (out of hundreds 
of tests showing on one line, it's easy to miss that the rare verbose error is 
on two).  And I'm not the only one, since another developer also thought there 
was a problem and spent most of issue46126 "fixing" it.

Another reason for posting to python-dev is that issue 46126 had been active 
for three months and had a PR merged before another dev mentioned that verbose 
tests with docstrings just printed on two lines instead of one.

Thank you for pointing out the possible disruption caused by unittest output 
changes.

--

___
Python tracker 

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



[issue43323] UnicodeEncodeError: surrogates not allowed when parsing invalid charset

2022-03-26 Thread Anders Kaseorg

Anders Kaseorg  added the comment:

It could and does, as quoted in my original report.

Content-Type: text/plain; charset*=utf-8”''utf-8%E2%80%9D

That’s a U+201D right double quotation mark.

This is not a valid charset for the charset of course, but it seems like the 
code was intended to handle an invalid charset value without crashing, so it 
should also handle an invalid charset charset (despite the absurdity of the 
entire concept of a charset charset).

--

___
Python tracker 

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



[issue47079] Integral.denominator shouldn't return an int

2022-03-26 Thread Sergey B Kirpichev


Sergey B Kirpichev  added the comment:

> Integral.__add__ is an abstract method, so it is a problem of your 
> implementation.

But such an implementation does satisfy all assumptions of the Integral abc, 
correct?

--

___
Python tracker 

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



[issue47133] enhance unittest to show test name and docstring on one line

2022-03-26 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

I have no problem with pinging Python-Dev, or any other forum, asking 
for interested parties. I just don't think we should be intentionally 
spliting the discussion more than it's going to get split organically. 
(If this is interesting to people, they will discuss it on other forums 
no matter what we say or do.)

Aside from the conservative position "If it ain't broke, don't break 
it", also known as "Chesterton's Fence":

https://matt-rickard.com/chestertons-fence/

I'm not specifically opposed to this change. Nor am I in favour.

Why do we print the first line of the doctests in the output of failing 
tests? If we understood the rationale for why we do that, it might give 
some insight into the consequences of removing it. If we don't know why 
it was shown in the first place, maybe we shouldn't remove it until we 
have some idea.

I am -1 on another option flag unless there is no other choice. Each 
boolean flag option doubles the number of tests of unitttest itself 
needed for full coverage.

Another option might be to leave the docstring line alone, and just 
*add* the 'ERROR' to the method name line:

# current output
test_broken_doc (mathlib.testing.test_utils.TestMinmax)
This is a docstring ... ERROR

# enhancement
test_broken_doc (mathlib.testing.test_utils.TestMinmax) ERROR
This is a docstring ... ERROR

That seems to me to be less risky than trying to cram them all on one line.

test_broken_doc (mathlib.testing.test_utils.TestMinmax) This is a docstring 
... ERROR

By the way, I presume we do the same thing for FAIL lines, which have 
the same behaviour as ERROR lines:

test_fail_doc (mathlib.testing.test_utils.TestMinmax)
This is a docstring ... FAIL

test_fail_nodoc (mathlib.testing.test_utils.TestMinmax) ... FAIL

--

___
Python tracker 

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



[issue47132] Move tests from setobject.c to _testcapimodule

2022-03-26 Thread Dennis Sweeney


Change by Dennis Sweeney :


--
nosy: +rhettinger

___
Python tracker 

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



[issue47128] Enhance Argument Clinic's NoneType return converter to give `void`

2022-03-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is simpler and faster to return NULL than call PyErr_Occurred(). There is a 
special macro PY_RETURN_NONE, so there is no problem with returning None either.

I do not think it would make the code better.

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



[issue47133] enhance unittest to show test name and docstring on one line

2022-03-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

This is already the third (at least) issue asking for such feature. Many people 
have problems with the current output. I would prefer to have a full qualified 
name of the test which I can copy by a double click and insert in a command 
that reruns specified tests. And full path to the test's source which I can 
copy to run in editor. pytest output looks more user-friendly to me.

But it may break other's test output parsers so we perhaps need an option for 
this. Options for unittest and libregrtest. I am not sure that it is a task for 
an average new contributor.

--

___
Python tracker 

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



[issue47079] Integral.denominator shouldn't return an int

2022-03-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It does not satisfy your assumptions in msg416056. So you have either correct 
your assumptions, or change the implementation of __add__, or change the 
implementation of denominator in your code.

--

___
Python tracker 

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