[issue41761] multiprocessing.Queue prevents program exit when containing a reasonable amount of data

2020-09-16 Thread Dominik Schmid


Change by Dominik Schmid :


--
nosy: +davin, pitrou

___
Python tracker 

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



[issue41798] [C API] Revisit usage of the PyCapsule C API with multi-phase initialization API

2020-09-16 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

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



[issue39728] Instantiating enum with invalid value results in ValueError twice

2020-09-16 Thread Ethan Furman


Change by Ethan Furman :


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



[issue39728] Instantiating enum with invalid value results in ValueError twice

2020-09-16 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 5efb1a77e75648012f8b52960c8637fc296a5c6d by Ethan Furman in 
branch '3.8':
[3.8] bpo-39728: Enum: fix duplicate `ValueError` (GH-22277) (GH-22283)
https://github.com/python/cpython/commit/5efb1a77e75648012f8b52960c8637fc296a5c6d


--

___
Python tracker 

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



[issue39728] Instantiating enum with invalid value results in ValueError twice

2020-09-16 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset a9ba8ba9a71f3cb8d274c354ff67b6206abeb8ac by Ethan Furman in 
branch '3.9':
[3.9] bpo-39728: Enum: fix duplicate `ValueError` (GH-22277) (GH-22282)
https://github.com/python/cpython/commit/a9ba8ba9a71f3cb8d274c354ff67b6206abeb8ac


--

___
Python tracker 

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



[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-09-16 Thread Ethan Furman


Ethan Furman  added the comment:

There was an effort to make it so `_generate_next_value_` could be defined last 
and still work correctly -- unfortunately, it could not handle the more common 
case of using `auto()` with the default `_generate_next_value_`:

  class I(Enum):
  first = auto()
  second = first + 2# this line would fail

Closing the ticket.  Thank you everyone!

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



[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-09-16 Thread miss-islington


Change by miss-islington :


--
pull_requests: +21338
pull_request: https://github.com/python/cpython/pull/22287

___
Python tracker 

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



[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-09-16 Thread miss-islington


Change by miss-islington :


--
pull_requests: +21339
pull_request: https://github.com/python/cpython/pull/22286

___
Python tracker 

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



[issue40900] uuid module build fix on FreeBSD proposal

2020-09-16 Thread Danilo G. Baio


Change by Danilo G. Baio :


--
nosy: +dbaio

___
Python tracker 

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



[issue27032] Remove deprecated html.parser.HTMLParser.unescape()

2020-09-16 Thread Senthil Kumaran


Senthil Kumaran  added the comment:

Irit, yes. Serhiy's patch could be converted to a GitHub PR and it can be 
merged.

--
nosy: +orsenthil

___
Python tracker 

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



[issue27032] Remove deprecated html.parser.HTMLParser.unescape()

2020-09-16 Thread Irit Katriel


Irit Katriel  added the comment:

This was pending Python 2 EOL, so should be ok to do now, right?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41799] splunklib.client does not handle Unicode characters

2020-09-16 Thread Eric V. Smith


Change by Eric V. Smith :


--
status: open -> pending

___
Python tracker 

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



[issue37296] pdb next vs __next__

2020-09-16 Thread Rick


Rick  added the comment:

I have no idea what program this was in, it's lost in the depths of time.
I can't retain these things for over a year, too old, maybe in my twenties I 
would have remembered what code this was in but no longer.
Can it.

--

___
Python tracker 

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



[issue41602] Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module)

2020-09-16 Thread Thomas Grainger


Thomas Grainger  added the comment:

nice the tests pass with that fix

--

___
Python tracker 

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



[issue41602] Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module)

2020-09-16 Thread Guido van Rossum


Guido van Rossum  added the comment:

Why did you remove 3.10?

--

___
Python tracker 

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



[issue39452] Improve the __main__ module documentation

2020-09-16 Thread Géry

Géry  added the comment:

Thanks for your extended review Steven.

> You state that these two phrases are from the runpy documentation:
>
> * "run from the module namespace"
> * "run from the file system"
>
> but neither of those phrases appear in the runpy documentation here:
>
> https://docs.python.org/3/library/runpy.html

I agree. Actually the first paragraph of the page uses the phrases:

- "located using the module namespace";
- "located using the file system",

so instead of saying:

- "run a module located using the module namespace" to mean "python 
- "run a module located using the file system" to mean "python -m ",

I simplified to:

- "run from the module namespace"
- "run from the file system"

But since the terminology is misleading I have used these phrases instead:

- `python`: "module initialized from an interactive prompt";
- `python < `: "module initialized from standard input";
- `python `: "module initialized from a file argument";
- `python -c `: "module initialized from a `-c` argument";
- `python -m `: "module initialized from a `-m` argument";
- `import `: "module initialized from an import statement".

What the documentation tries to explain is that in all of these cases except 
the last one, code is executed in the __main__ module.

I have updated the PR.



> The PR changes the term "scope" to "environment", but I think that is wrong. 
> An environment is potentially greater than a scope. `__main__` is a module 
> namespace, hence a scope. The environment includes things outside of that 
> scope, such as the builtins, environment variables, the current working 
> directory, the python path, etc. We don't talk about modules being an 
> environment, but as making up a scope.

I disagree. According to Wikipedia 
(https://en.wikipedia.org/wiki/Scope_(computer_science)), the term "scope" is 
the part of a program where a name binding is valid, while the term 
"environment" (synonym of "context") is the set of name bindings that are valid 
within a part of a program. Therefore "scope" is a property of a name binding 
(a name binding has a scope), and "environment" is a property of a part of a 
program (a part of a program has an environment).

And the term "environment" is actually already used in the original title and 
synopsis of the document (and it is correct):

> :mod:`__main__` --- Top-level script environment

> .. module:: __main__
> :synopsis: The environment where the top-level script is run.

So my change to the body fixes the inconsistent and incorrect usage of "scope":

- ``'__main__'`` is the name of the scope in which top-level code executes.
+ ``'__main__'`` is the name of the environment where top-level code is run.

- A module can discover whether or not it is running in the main scope
+ A module can discover whether or not it is running in the main environment



> Placing the comment above the `if`, where it will apply to the entire `if` 
> statement, is incorrect.

I agree. Sometimes you see comments before if statements but they usually don't 
start with "execute".

I have updated the PR.



> The second problem is that when running a module with -m it *is* imported. 
> PEP 338 is clear about this:

I agree. I should have said "when the module is not initialized from an import 
statement".

But note that even before my change the original document already used the 
phrase "not imported":

- executing code in a module when it is run as a script or with ``python
- -m`` but not when it is imported::
+ executing code in a module when it is not imported::

- # execute only if run as a script
+ # Execute only if the module is not imported.

I have updated the PR.

--

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


Serhiy Storchaka  added the comment:

There are other abstract object APIs: PyNumber, PySequence, PyMapping, etc. In 
particularly PyIter_Next() works with the iterator protocol, there is no single 
iterator class. Seems PyGen_* API is related to concrete class, but we can 
introduce new namespace for the generator protocol.

--

___
Python tracker 

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



[issue41602] Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module)

2020-09-16 Thread Thomas Grainger


Thomas Grainger  added the comment:

I pushed that patch

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



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

2020-09-16 Thread Yury Selivanov


Yury Selivanov  added the comment:

> I think it should be specific to generators and coroutines. Calling 
> `PyObject_CallMethodIdOneArg(coro, &PyId_send, arg);` and interpreting 
> exceptions to emulate the low level API seems a bit too much.

To add to my point: typically higher-level APIs go under the `PyObject_*` 
namespace, whereas `Py{Type}_*` is more concrete. So I'd make `PyGen_Send` to 
only work with `PyGen` and `PyCoro`.

--

___
Python tracker 

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



[issue41602] Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module)

2020-09-16 Thread Guido van Rossum


Guido van Rossum  added the comment:

Thanks, I think this is the fix:

diff --git a/Modules/main.c b/Modules/main.c
index 4a76f4461b..3d1bbee3a0 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -288,6 +288,10 @@ pymain_run_module(const wchar_t *modname, int set_argv0)
 return pymain_exit_err_print();
 }
 result = PyObject_Call(runmodule, runargs, NULL);
+if (!result && PyErr_Occurred() == PyExc_KeyboardInterrupt) {
+_Py_UnhandledKeyboardInterrupt = 1;
+}
+
 Py_DECREF(runpy);
 Py_DECREF(runmodule);
 Py_DECREF(module);


Can you submit it as a PR? I don't have the time (but I can review once you've 
got tests working etc.)

--

___
Python tracker 

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



[issue41602] Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module)

2020-09-16 Thread Guido van Rossum


Change by Guido van Rossum :


--
stage: patch review -> needs patch
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



[issue37903] IDLE Shell sidebar.

2020-09-16 Thread E. Paine


Change by E. Paine :


--
assignee:  -> terry.reedy
components: +IDLE
nosy: +epaine
versions: +Python 3.10 -Python 3.7

___
Python tracker 

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



[issue41602] Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module)

2020-09-16 Thread Thomas Grainger


Thomas Grainger  added the comment:

I'm assuming _Py_UnhandledKeyboardInterrupt is getting incorrectly cleared 
somewhere in here

https://github.com/python/cpython/blob/fc23a9483ef0d7c98bea9f82392377d0b6ef7b18/Modules/main.c#L291-L300

Py_DECREF(runpy);
Py_DECREF(runmodule);
Py_DECREF(module);
Py_DECREF(runargs);
if (result == NULL) {
return pymain_exit_err_print();
}
Py_DECREF(result);
return 0;
}

--

___
Python tracker 

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



[issue41602] Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module)

2020-09-16 Thread Guido van Rossum


Guido van Rossum  added the comment:

Okay, so according to eryksun the fix requires C code. @graingert, are you 
interested in developing such a fix? Or @eryksun do you have an idea on how to 
fix it?

--

___
Python tracker 

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



[issue37350] print ResourceWarning object traceback when raised as error with -W error and -X tracemalloc

2020-09-16 Thread Guido van Rossum


Change by Guido van Rossum :


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



[issue37604] warnings should use a ContextVar to manage filters/registry

2020-09-16 Thread Guido van Rossum


Change by Guido van Rossum :


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



[issue41602] Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module)

2020-09-16 Thread Thomas Grainger


Thomas Grainger  added the comment:

> Okay, I got it. Now my next question. What do you mean by "I've eliminated 
> runpy" and various other remarks along those lines?

I can use `runpy._run_module_as_main` from another Python entry, eg -c and get 
the correct `-2`

>>> subprocess.run(["python3", "-c", 
>>> "__import__('runpy')._run_module_as_main('spam')"])
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.8/runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
exec(code, run_globals)
  File "/home/graingert/projects/osirium-main/spam.py", line 1, in 
raise KeyboardInterrupt
KeyboardInterrupt
CompletedProcess(args=['python3', '-c', 
"__import__('runpy')._run_module_as_main('spam')"], returncode=-2)


> Have you actually identified the root cause of the problem? What's your 
> suggested fix (without test framework).

No I don't have a fix

--

___
Python tracker 

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



[issue36586] multiprocessing.Queue.close doesn't behave as documented

2020-09-16 Thread Guido van Rossum


Change by Guido van Rossum :


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



[issue36586] multiprocessing.Queue.close doesn't behave as documented

2020-09-16 Thread Guido van Rossum


Guido van Rossum  added the comment:

Closing for lack of activity.

--
nosy: +gvanrossum

___
Python tracker 

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



[issue37350] print ResourceWarning object traceback when raised as error with -W error and -X tracemalloc

2020-09-16 Thread Guido van Rossum


Guido van Rossum  added the comment:

Closing for lack of activity.

--
nosy: +gvanrossum

___
Python tracker 

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



[issue37604] warnings should use a ContextVar to manage filters/registry

2020-09-16 Thread Guido van Rossum


Guido van Rossum  added the comment:

Closing for lack of activity.

--
nosy: +gvanrossum

___
Python tracker 

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



[issue41602] Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module)

2020-09-16 Thread Eryk Sun


Eryk Sun  added the comment:

> The return code of python on linux when the program is ended with 
> a KeyboardInterrupt should be -2

In general, the exit status for an unhandled KeyboardInterrupt (i.e. 
_Py_UnhandledKeyboardInterrupt) should be the same as the default SIGINT 
handler. This is implemented by exit_sigint in Modules/main.c. In POSIX, it 
uses the actual default SIGINT handler via kill(). In Windows, it uses the exit 
status that the default console control handler would use, 
STATUS_CONTROL_C_EXIT (0xC000_013A).

--
nosy: +eryksun

___
Python tracker 

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



[issue40697] add fissix as a lib2to3 alternative

2020-09-16 Thread Guido van Rossum


Guido van Rossum  added the comment:

Closing for lack of activity.

--
nosy: +gvanrossum

___
Python tracker 

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



[issue41602] Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module)

2020-09-16 Thread Guido van Rossum


Guido van Rossum  added the comment:

Okay, I got it. Now my next question. What do you mean by "I've eliminated 
runpy" and various other remarks along those lines? Have you actually 
identified the root cause of the problem? What's your suggested fix (without 
test framework).

--

___
Python tracker 

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



[issue41602] Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module)

2020-09-16 Thread Thomas Grainger


Thomas Grainger  added the comment:

The return code of python on linux when the program is ended with a 
KeyboardInterrupt should be -2, this works in most cases - except when called 
via "python -m"


Does this repl help?

Python 3.8.2 (default, Jul 16 2020, 14:00:26) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pathlib, subprocess
>>> pathlib.Path("spam.py").write_text("raise KeyboardInterrupt")
23
>>> subprocess.run(["python3", "spam.py"])
Traceback (most recent call last):
  File "spam.py", line 1, in 
raise KeyboardInterrupt
KeyboardInterrupt
CompletedProcess(args=['python3', 'spam.py'], returncode=-2)
>>> subprocess.run(["python3", "-m", "spam"])
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
exec(code, run_globals)
  File "/home/graingert/projects/spam.py", line 1, in 
raise KeyboardInterrupt
KeyboardInterrupt
CompletedProcess(args=['python3', '-m', 'spam'], returncode=1)
>>>

--

___
Python tracker 

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



[issue41799] splunklib.client does not handle Unicode characters

2020-09-16 Thread Eric V. Smith


Eric V. Smith  added the comment:

This looks like an issue with splunklib, which is not distributed with python. 

I'm not sure if it's the same splunklib, but you might try 
https://github.com/IntegralDefense/splunklib

--
nosy: +eric.smith

___
Python tracker 

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



[issue38981] better name for re.error Exception class.

2020-09-16 Thread Sourabh


Change by Sourabh :


--
nosy: +sourabh025
type: enhancement -> security

___
Python tracker 

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



[issue41746] Add optional type information to asdl_seq objects

2020-09-16 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset a5634c406767ef694df49b624adf9cfa6c0d9064 by Pablo Galindo in 
branch 'master':
bpo-41746: Add type information to asdl_seq objects (GH-3)
https://github.com/python/cpython/commit/a5634c406767ef694df49b624adf9cfa6c0d9064


--

___
Python tracker 

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



[issue41797] PyModule_GetState doesn't work with LazyLoader

2020-09-16 Thread Brett Cannon


Brett Cannon  added the comment:

Probably making LazyLoader skip being lazy for non-source modules probably 
makes the most sense and would be easiest to implement since it's an explicit 
opt-out.

--

___
Python tracker 

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



[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-09-16 Thread Ethan Furman


Change by Ethan Furman :


--
pull_requests: +21337
pull_request: https://github.com/python/cpython/pull/22285

___
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-16 Thread Yury Selivanov


Yury Selivanov  added the comment:

> Since coroutines inherit the generator protocol more or less, I think 
> "PyGen_Send()" is a more suitable name, better than "PyCoro_Send()".

OK, +1. PyGen_Send it is.

> Also should it be specific to generators/coroutines and accept PyGenObject*

I think it should be specific to generators and coroutines. Calling 
`PyObject_CallMethodIdOneArg(coro, &PyId_send, arg);` and interpreting 
exceptions to emulate the low level API seems a bit too much.

--

___
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-16 Thread Vladimir Matveev


Vladimir Matveev  added the comment:

Also should it be specific to generators/coroutines and accept PyGenObject* or 
should it try to handle multiple cases and expose the result for them in 
uniform way, i.e.
```
if (PyGen_CheckExact(gen) || PyCoro_CheckExact(gen)) {
   // use coroutine/generator specific code that avoids raising exceptions
   *result = ...
   return PYGEN_RETURN;
}
PyObject *ret;
if (arg == Py_None) {
  ret = Py_TYPE(gen)->tp_iternext(gen);
}
else {
  ret = _PyObject_CallMethodIdOneArg(coro, &PyId_send, arg);
}
if (ret != NULL) {
  *result = ret;
  return PYGEN_YIELD;
}
if (_PyGen_FetchStopIterationValue(result) == 0) {
  return PYGEN_RETURN;
}
return PYGEN_ERROR;
```

--

___
Python tracker 

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



[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-09-16 Thread Ethan Furman


Change by Ethan Furman :


--
pull_requests: +21336
pull_request: https://github.com/python/cpython/pull/22284

___
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-16 Thread Stefan Behnel


Stefan Behnel  added the comment:

I'm happy to see this moving forward.

Not convinved of the "PyIter_Send()" name, though. I don't consider this part 
of the iterator protocol. It's specific to generators and coroutines. Cython 
would probably guard its usage by "PyGen_CheckExact()" or 
"PyCoro_CheckExact()", and not use it for arbitrary iterators.

Since coroutines inherit the generator protocol more or less, I think 
"PyGen_Send()" is a more suitable name, better than "PyCoro_Send()".

--

___
Python tracker 

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



[issue41799] splunklib.client does not handle Unicode characters

2020-09-16 Thread Jay Patel

New submission from Jay Patel :

Using splunklib.client module to use Pythonic interface to the Splunk REST API. 
I am using the connect method of the module to connect and log in to a Splunk 
instance.

Code:
import splunklib.client as splunk_client
kwargs_config_flags = {
'host': "test_instance漢字",
'port': 8089,
'username': ,
'password': ,
'owner': None,
'app': None}
sc = splunk_client.connect(**kwargs_config_flags)

For python 3
Output:
''latin-1' codec can't encode characters in position 0-1: ordinal not in 
range(256)'

I tried to encode the host to utf-8, "test_instance漢字".encode("utf-8")
Output:
'a bytes-like object is required, not 'str''

For python 2
It is working as expected.
output: 'nodename nor servname provided, or not known'

Is there a way by which this can be handled at the module level?

--
components: Unicode
messages: 377005
nosy: ezio.melotti, jpatel, vstinner
priority: normal
severity: normal
status: open
title: splunklib.client does not handle Unicode characters
type: behavior
versions: Python 3.6

___
Python tracker 

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



[issue39728] Instantiating enum with invalid value results in ValueError twice

2020-09-16 Thread Ethan Furman


Change by Ethan Furman :


--
pull_requests: +21335
pull_request: https://github.com/python/cpython/pull/22283

___
Python tracker 

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



[issue39728] Instantiating enum with invalid value results in ValueError twice

2020-09-16 Thread Ethan Furman


Change by Ethan Furman :


--
pull_requests: +21334
pull_request: https://github.com/python/cpython/pull/22282

___
Python tracker 

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



[issue39728] Instantiating enum with invalid value results in ValueError twice

2020-09-16 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset c95ad7a91fbd7636f33a098d3b39964ab083bf49 by Ethan Furman in 
branch 'master':
bpo-39728: Enum: fix duplicate `ValueError` (GH-22277)
https://github.com/python/cpython/commit/c95ad7a91fbd7636f33a098d3b39964ab083bf49


--

___
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-16 Thread Yury Selivanov


Yury Selivanov  added the comment:

> As for returned value, I propose to return -1 in case of error, 1 for yielded 
> value and 0 for returned value (i.e. define PYGEN_RETURN = 0, PYGEN_YIELD = 1 
> and PYGEN_ERROR = -1, but without exposing public names).

Sure, that works.

--

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


Serhiy Storchaka  added the comment:

As for returned value, I propose to return -1 in case of error, 1 for yielded 
value and 0 for returned value (i.e. define PYGEN_RETURN = 0, PYGEN_YIELD = 1 
and PYGEN_ERROR = -1, but without exposing public names).

It would be uniform with other C API: many functions return -1 on error (if 
they return int and can fail), and PyDict_Next() and _PySet_NextEntry() return 
1 for every yielded item, and 0 if the iteration has been finished.

--

___
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-16 Thread Yury Selivanov


Yury Selivanov  added the comment:

Mark, Stefan,

I don't want this to be stale so I propose to move with my suggestions:

1. We make the new API public. Mark, if you have objections to that - please 
elaborate with some details. IMO, the corresponding Python API is long public 
and there's no harm in exposing a C version of it. Especially given the fact 
that uvloop, cython, and even asyncio itself will be relying on that API.

2. I propose to name the new API `PyIter_Send`. Motivation: it will work with 
both generators and coroutines and plays nicely with `PyIter_Next`.

--

___
Python tracker 

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



[issue41602] Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module)

2020-09-16 Thread Guido van Rossum

Guido van Rossum  added the comment:

Thomas, can you explain the problem in English? Those elaborate test programs 
don’t do it for me, sorry.

--

___
Python tracker 

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



[issue41762] Documentation job fails on CIs: duplicate token description of format_spec

2020-09-16 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +21333
pull_request: https://github.com/python/cpython/pull/22281

___
Python tracker 

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



[issue41762] Documentation job fails on CIs: duplicate token description of format_spec

2020-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

".. productionlist::" markup is related to "Grammar production displays":
https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#grammar-production-displays

We can try to pass a different unique name to each ".. productionlist::" markup:

"The productionGroup argument to productionlist serves to distinguish different 
sets of production lists that belong to different grammars. Multiple production 
lists with the same productionGroup thus define rules in the same scope."

--

___
Python tracker 

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



[issue23832] pdb's `longlist` shows only decorator if that one contains a lambda

2020-09-16 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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



[issue41517] Able to subclass enum with members by using multiple inheritance

2020-09-16 Thread Ethan Furman


Change by Ethan Furman :


--
assignee:  -> ethan.furman
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



[issue41517] Able to subclass enum with members by using multiple inheritance

2020-09-16 Thread miss-islington


miss-islington  added the comment:


New changeset 48f99250ff319e36b15b555128cd62e408d8165f by Miss Islington (bot) 
in branch '3.9':
bpo-41517: do not allow Enums to be extended (GH-22271)
https://github.com/python/cpython/commit/48f99250ff319e36b15b555128cd62e408d8165f


--

___
Python tracker 

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



[issue41517] Able to subclass enum with members by using multiple inheritance

2020-09-16 Thread miss-islington


miss-islington  added the comment:


New changeset 3f4012117bf80aa7c005f8fa6fb8e1f8b1aef5d5 by Miss Islington (bot) 
in branch '3.8':
bpo-41517: do not allow Enums to be extended (GH-22271)
https://github.com/python/cpython/commit/3f4012117bf80aa7c005f8fa6fb8e1f8b1aef5d5


--

___
Python tracker 

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



[issue41796] _ast module state should be made per interpreter

2020-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

> I started this here: 
> https://github.com/python/cpython/commit/60960cba606573450e76934c954787419524147d
>  Feel free to take that code.

Oh thanks! I was looking for your work, but I failed to find it.

It is really helpful!

I started to hack asdl_c.py locally, but Pablo asked me in private to wait a 
few days, since he is going to push large changes on this file soon.

This issue is an enhancement which can wait.

--

___
Python tracker 

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



[issue41798] [C API] Revisit usage of the PyCapsule C API with multi-phase initialization API

2020-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

> unicodedata: static variable

Right now, it's ok-ish. Mohamed Koubaa is working on PR 22145 to pass a module 
state into internal functions, and so the PyCapsule pointer must be different 
in each module instance.

--

___
Python tracker 

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



[issue41517] Able to subclass enum with members by using multiple inheritance

2020-09-16 Thread miss-islington


Change by miss-islington :


--
pull_requests: +21332
pull_request: https://github.com/python/cpython/pull/22279

___
Python tracker 

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



[issue41517] Able to subclass enum with members by using multiple inheritance

2020-09-16 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 3064dbf5df1021e85b507366a7ea448c8895efe7 by Ethan Furman in 
branch 'master':
bpo-41517: do not allow Enums to be extended (#22271)
https://github.com/python/cpython/commit/3064dbf5df1021e85b507366a7ea448c8895efe7


--

___
Python tracker 

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



[issue41517] Able to subclass enum with members by using multiple inheritance

2020-09-16 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 7.0 -> 8.0
pull_requests: +21331
pull_request: https://github.com/python/cpython/pull/22278

___
Python tracker 

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



[issue41798] [C API] Revisit usage of the PyCapsule C API with multi-phase initialization API

2020-09-16 Thread Petr Viktorin


Change by Petr Viktorin :


--
nosy: +petr.viktorin

___
Python tracker 

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



[issue1635741] Py_Finalize() doesn't clear all Python objects at exit

2020-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

> I rejected the PR 19122 which tries to port the _datetime module to the 
> multi-phase initialization API (PEP 489). We need first to enhance the 
> PyCapsule C API to pass the module instance to C functions, somehow.

I created bpo-41798: [C API] Revisit usage of the PyCapsule C API with 
multi-phase initialization API.

--

___
Python tracker 

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



[issue41798] [C API] Revisit usage of the PyCapsule C API with multi-phase initialization API

2020-09-16 Thread STINNER Victor


New submission from STINNER Victor :

More and more extension modules are converted to the multi-phase initialization 
API (PEP 489) in bpo-1635741.

The problem is that the usage of the PyCapsule C API is not adapted in these 
extensions, to isolate well capsule objects from other module instances.

For example, the pyexpat extension uses "static struct PyExpat_CAPI capi;". It 
was fine when it was not possible to create more than one instance of the 
extension module. But with PR 2 (currently under review), it becomes 
possible to have multiple extension module instances. Each module instance 
creates its own capsule object, but all capsule object points to the same 
unique "struct PyExpat_CAPI" instance.

For the specific case of the pyexpat in its current implementation, reusing the 
same "struct PyExpat_CAPI" instance is ok-ish, since the value is the same for 
all module instances. But this design sounds fragile.

It would be safer to allocate a "struct PyExpat_CAPI" on the heap memory in 
each module instance, and use a PyCapsule destructor function (3rd parameter of 
PyCapsule_New()).

The _ctypes does that:
---
void *space = PyMem_Calloc(2, sizeof(int));
if (space == NULL)
return NULL;
errobj = PyCapsule_New(space, CTYPES_CAPSULE_NAME_PYMEM, 
pymem_destructor);
---

with:
---
static void pymem_destructor(PyObject *ptr)
{
void *p = PyCapsule_GetPointer(ptr, CTYPES_CAPSULE_NAME_PYMEM);
if (p) {
PyMem_Free(p);
}
}
---


The PyCapsule API is used by multiple extension modules:

* _ctypes: allocate memory on the heap and uses a destructor to release it

* _curses: static variable, PyInit__curses() sets PyCurses_API[0] to 
&PyCursesWindow_Type (static type)

* _datetime: static variable, PyInit__datetime() creates a timezone object and 
stores it into CAPI.TimeZone_UTC

* _decimal: static variable

* _socket: static variable, PyInit__socket() sets PySocketModuleAPI.error to 
PyExc_OSError, and sets PySocketModuleAPI.timeout_error to _socket.timeout (a 
new exception object)

* pyexpat: static varaible

* unicodedata: static variable

* posix: nt._add_dll_directory() creates a PyCapsule using AddDllDirectory() 
result as a the pointer value
The _datetime module overrides the 


--

See also the PEP 630 "Isolating Extension Modules".

--
components: C API
messages: 376992
nosy: vstinner
priority: normal
severity: normal
status: open
title: [C API] Revisit usage of the PyCapsule C API with multi-phase 
initialization API
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



[issue39728] Instantiating enum with invalid value results in ValueError twice

2020-09-16 Thread Ethan Furman


Change by Ethan Furman :


--
pull_requests: +21330
pull_request: https://github.com/python/cpython/pull/22277

___
Python tracker 

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



[issue41797] PyModule_GetState doesn't work with LazyLoader

2020-09-16 Thread Petr Viktorin


New submission from Petr Viktorin :

One underlying issue from bpo-41631 is that importlib.util.LazyLoader produces 
modules that are only fully loaded after an attribute is accessed (through 
__getattribute__).

C-API functions like PyModule_GetState, PyModule_GetDict and such do not get 
attributes, and when called on a _LazyModule, they might try to access 
uninitialized C-level state.

I see two possible ways to fix this:
- Make PyModule_GetState, etc. trigger a full load. Since this is C-API, it 
would need a fast (no Python code) way either to do the full load or to detect 
_LazyModule.
- Make LazyLoader eager for either all extension & builtin modules, or for 
modules that have C-level storage. The latter would need a way to pass info 
from PyModuleDef to the loader.


Brett, does that analysis make sense from the importlib POV?

--
components: C API
messages: 376991
nosy: brett.cannon, petr.viktorin
priority: normal
severity: normal
status: open
title: PyModule_GetState doesn't work with LazyLoader

___
Python tracker 

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



[issue41687] sendfile implementation is not compatible with Solaris

2020-09-16 Thread miss-islington


miss-islington  added the comment:


New changeset 6a39888c2c4bcfbcdc61a1953911ad30c62da1ef by Miss Islington (bot) 
in branch '3.9':
bpo-41687: Fix error handling in Solaris sendfile implementation (GH-22128)
https://github.com/python/cpython/commit/6a39888c2c4bcfbcdc61a1953911ad30c62da1ef


--

___
Python tracker 

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



[issue41796] _ast module state should be made per interpreter

2020-09-16 Thread Petr Viktorin


Petr Viktorin  added the comment:

I started this here: 
https://github.com/python/cpython/commit/60960cba606573450e76934c954787419524147d
Feel free to take that code.

--
nosy: +petr.viktorin

___
Python tracker 

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



[issue41687] sendfile implementation is not compatible with Solaris

2020-09-16 Thread miss-islington


Change by miss-islington :


--
pull_requests: +21329
pull_request: https://github.com/python/cpython/pull/22274

___
Python tracker 

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



[issue41687] sendfile implementation is not compatible with Solaris

2020-09-16 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 7e356f17e4c91392b6fa45a512efc95923388813 by Łukasz Langa in 
branch '3.9':
[3.9] bpo-41687: Fix sendfile implementation to work with Solaris (GH-22040) 
(GH-22273)
https://github.com/python/cpython/commit/7e356f17e4c91392b6fa45a512efc95923388813


--

___
Python tracker 

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



[issue41784] Promote PyUnicode_AsUTF8AndSize to be available with the limited API (PEP 384)

2020-09-16 Thread Alex Gaynor


Alex Gaynor  added the comment:

Py_buffer is not part of the limited API at all, so I don't think it's usable 
for this.

--

___
Python tracker 

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



[issue39728] Instantiating enum with invalid value results in ValueError twice

2020-09-16 Thread Ethan Furman


Change by Ethan Furman :


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



[issue41687] sendfile implementation is not compatible with Solaris

2020-09-16 Thread Łukasz Langa

Change by Łukasz Langa :


--
nosy: +lukasz.langa
nosy_count: 4.0 -> 5.0
pull_requests: +21328
pull_request: https://github.com/python/cpython/pull/22273

___
Python tracker 

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



[issue41789] Enum: __str__ and friends sometimes erroneously replaced

2020-09-16 Thread Ethan Furman


Change by Ethan Furman :


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



[issue41789] Enum: __str__ and friends sometimes erroneously replaced

2020-09-16 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset a4677068dd61662f5a56b184d5e3aa07db65b88e by Ethan Furman in 
branch '3.9':
[3.9] bpo-41789: honor object overrides in Enum classes (GH-22250) (GH-22272)
https://github.com/python/cpython/commit/a4677068dd61662f5a56b184d5e3aa07db65b88e


--

___
Python tracker 

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



[issue19270] Document that sched.cancel() doesn't distinguish equal events and can break order

2020-09-16 Thread Jonas Norling


Jonas Norling  added the comment:

@bar.harel: I didn't find a PR, so I'd like to encourage you to submit one :-)

I stumbled onto this bug when the scheduler would cancel the wrong event for me 
(Python 3.7, 3.8). Raymond's suggestion 1 sounds reasonable; it would be very 
unlikely to break code that doesn't depend on internals in sched, and it 
simplifies the implementation a bit.

--
nosy: +wocket

___
Python tracker 

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



[issue41602] Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module)

2020-09-16 Thread Thomas Grainger


Thomas Grainger  added the comment:

adding `__main__` owners to nosy

--
nosy: +gvanrossum

___
Python tracker 

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



[issue41796] _ast module state should be made per interpreter

2020-09-16 Thread STINNER Victor


New submission from STINNER Victor :

In September 2019, the _ast extension module was converted to PEP 384 (stable 
ABI): bpo-38113.

In bpo-41631, I moved the _ast module state back to a global state, rather than 
a regular module state, to fix multiple bugs.

The state should be made per intepreter (moved into PyInterpreterState).

Also, each interpreter should have its own _ast types (_ast.AST, _ast.Constant, 
etc.), rather than sharing all types.

Hopefully, in 3.9, _ast types have been converted to heap types.

To fix bpo-41631, I wanted to convert _ast.AST heap type back into a static 
type, to prevenet a subinterpreter to modify it, but Petr Viktorin asked me to 
leave it as it is:
https://github.com/python/cpython/pull/21961#issuecomment-685821519

I agree since I would like to convert all static types to heap types: bpo-40077.

--
components: Interpreter Core
messages: 376983
nosy: vstinner
priority: normal
severity: normal
status: open
title: _ast module state should be made per interpreter
versions: Python 3.10

___
Python tracker 

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



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

2020-09-16 Thread STINNER Victor


Change by STINNER Victor :


--
title: Convert static types to PyType_FromSpec() -> Convert static types to 
heap types: use PyType_FromSpec()

___
Python tracker 

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



[issue37296] pdb next vs __next__

2020-09-16 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

I agree. Without further information it is impossible to move forward.

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



[issue41795] Allow assignment in yield statement

2020-09-16 Thread Ronald Oussoren


Change by Ronald Oussoren :


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



[issue41795] Allow assignment in yield statement

2020-09-16 Thread Richard Neumann


Richard Neumann  added the comment:

Awesome, I didn't know that.
I tried it without the parens and it gave me a SyntaxError.
This can be closed then as it's obviously already implemented.
Let's get to refactoring.

--

___
Python tracker 

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



[issue41795] Allow assignment in yield statement

2020-09-16 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

You can already do this with the walrus operator:

# ---
def test():
for i in range(10):
yield (square := i * i)

yield square + 1

# ---

This adds some parenthesis to your second alternative.

--
nosy: +ronaldoussoren

___
Python tracker 

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



[issue41795] Allow assignment in yield statement

2020-09-16 Thread Richard Neumann


New submission from Richard Neumann :

I often write factory (deserialization) methods for ORM models for web 
application backends that produce a number of records (ORM model instances) of 
itself and related database tables:

@classmethod
def from_json(cls, json):
"""Yields records from a JSON-ish dict."""
modules = json.pop('modules', None) or ()
order = super().from_json(json)
yield order

for module in modules:
yield OrderedModule(order=order, module=Module(module))

This yields the main record "order" and related records from OrderedModules, 
which have a foreign key to Order.
Thusly I can save all records by:

for record in Order.from_json(json):
record.save()

Since I have several of those deserialization functions for multiple tables in 
multiple databases, it'd be nice to reduce the amount of code with some extra 
syntactic sugar, like:

@classmethod
def from_json(cls, json):
"""Yields records from a JSON-ish dict."""
modules = json.pop('modules', None) or ()
yield order = super().from_json(json)  # Assignment via "="

for module in modules:
yield OrderedModule(order=order, module=Module(module))

or:

@classmethod
def from_json(cls, json):
"""Yields records from a JSON-ish dict."""
modules = json.pop('modules', None) or ()
yield order := super().from_json(json)  # Assignment via ":="

for module in modules:
yield OrderedModule(order=order, module=Module(module))

I therefor propose to allow assignment of names in generator-like yield 
statements as described above.

--
messages: 376979
nosy: conqp
priority: normal
severity: normal
status: open
title: Allow assignment in yield statement
type: enhancement
versions: Python 3.10

___
Python tracker 

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



[issue41784] Promote PyUnicode_AsUTF8AndSize to be available with the limited API (PEP 384)

2020-09-16 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I agree about PyUnicode_AsUTF8.

But I think it would be worth to ask PyPy team about PyUnicode_AsUTF8AndSize.

An alternate C API is PyUnicode_GetUTF8Buffer (issue39087). It requires 
explicit releasing the buffer after use, so it can be used even on 
implementations with moving garbage collector.

--

___
Python tracker 

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



[issue13340] list.index does not accept None as start or stop

2020-09-16 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Thank you for the reminder Irit. Your comments for issues and PRs are really 
helpful. Thank you for all this!

--
nosy: +serhiy.storchaka
resolution:  -> out of date
stage: needs patch -> 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