[issue42331] 'base64' has no attribute 'decodestring'

2020-11-12 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

The tracker is for issues related to CPython. This seems to be an issue with 
gsutil on Python 3.9 compatibility. This seems to have been fixed as below :

https://github.com/GoogleCloudPlatform/gsutil/issues/1118

--
nosy: +xtreak
resolution:  -> third party
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



[issue42329] typing classes do not have __name__ attributes in 3.7+

2020-11-12 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

Not a big deal if we don't, I just found it odd so I figured I'd pose the
question. That it's been in three releases and only just now come up is
pretty telling that isn't critical.

The code in question was trying to identify public functions in a module by
inspecting names and I think they've got a more pedantic way to do that
than their existing code that wouldn't be tripped up by a mere callable
without a __name__.

On Wed, Nov 11, 2020, 8:47 PM Guido van Rossum 
wrote:

>
> Guido van Rossum  added the comment:
>
> Between 3.6 and 3.7 they stopped being types.
>
> IIRC this enabled optimizations. (Serhiy?)
>
> I don't think this is important, but I suppose you have some code that
> this breaks?
>
> The name is passed to the constructor of _SpecialGenericAlias, so I'm fine
> with fixing this, though the backports may get tricky when you get down to
> 3.7.
>
> --
> nosy: +serhiy.storchaka
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue16879] distutils.command.config uses fragile constant temporary file name

2020-11-12 Thread Amir Mohamadi


Amir Mohamadi  added the comment:

Can I open a PR for it?

--
nosy: +Amir

___
Python tracker 

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



[issue42246] Implement PEP 626

2020-11-12 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 877df851c3ecdb55306840e247596e7b7805a60a by Mark Shannon in 
branch 'master':
bpo-42246: Partial implementation of PEP 626. (GH-23113)
https://github.com/python/cpython/commit/877df851c3ecdb55306840e247596e7b7805a60a


--

___
Python tracker 

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



[issue42237] test_socket.SendfileUsingSendfileTest fails on illumos

2020-11-12 Thread Andrew Svetlov


Andrew Svetlov  added the comment:


New changeset fd4ed57674c675e05bd5d577dd5047a333c76c78 by Jakub Stasiak in 
branch 'master':
bpo-42237: Fix os.sendfile() on illumos (GH-23154)
https://github.com/python/cpython/commit/fd4ed57674c675e05bd5d577dd5047a333c76c78


--
nosy: +asvetlov

___
Python tracker 

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



[issue42237] test_socket.SendfileUsingSendfileTest fails on illumos

2020-11-12 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 4.0 -> 5.0
pull_requests: +22141
pull_request: https://github.com/python/cpython/pull/23244

___
Python tracker 

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



[issue41116] build on macOS 11 (beta) does not find system-supplied third-party libraries

2020-11-12 Thread Sijmen J. Mulder


Sijmen J. Mulder  added the comment:

With './configure; make' of master on macOS 11 on Apple Silicon I get the 
library detection failure. The quick and easy fix was to amend inc_dirs and 
lib_dirs in setup.py:

 if MACOS:
+sysroot = macosx_sdk_root()
+self.inc_dirs.append(sysroot + '/usr/include')
+self.lib_dirs.append(sysroot + '/usr/lib')

Interestingly the lzma library is found, but the module fails because it cannot 
find lzma.h, which does indeed appear to be missing in the SDK.

--
nosy: +sjmulder

___
Python tracker 

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



[issue42246] Implement PEP 626

2020-11-12 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +22142
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/23245

___
Python tracker 

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



[issue42237] test_socket.SendfileUsingSendfileTest fails on illumos

2020-11-12 Thread miss-islington


miss-islington  added the comment:


New changeset 7ae19ef5cf5d4f464588133bd48f81d80ea54aee by Miss Islington (bot) 
in branch '3.9':
bpo-42237: Fix os.sendfile() on illumos (GH-23154)
https://github.com/python/cpython/commit/7ae19ef5cf5d4f464588133bd48f81d80ea54aee


--

___
Python tracker 

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



[issue32426] Tkinter.ttk Widget does not define wich option exists to set the cursor

2020-11-12 Thread Pat Thoyts


Pat Thoyts  added the comment:

The Tk documentation for the acceptable cursor names is the cursors manual 
page. https://www.tcl.tk/man/tcl/TkCmd/cursors.htm

Tk does not provide a way to get all these names in script.

This should probably be closed.

--
nosy: +patthoyts

___
Python tracker 

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



[issue42237] test_socket.SendfileUsingSendfileTest fails on illumos

2020-11-12 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
pull_requests: +22143
pull_request: https://github.com/python/cpython/pull/23246

___
Python tracker 

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



[issue24831] Load average in test suite too high

2020-11-12 Thread STINNER Victor


STINNER Victor  added the comment:

No activity for 5 years, so far this issue is more an open discussion than a 
list of concrete changes, so I close the issue as out of date.

If some tests are too CPU or I/O intensive, you can skip them using the -x 
option. Use --ignorefile to only skip specific test methods.

About the temporary directory, regrtest now has a --tempdir option.

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



[issue32426] Tkinter.ttk Widget does not define wich option exists to set the cursor

2020-11-12 Thread Alessandro Piccione


Alessandro Piccione  added the comment:

As suggested the documentation for "cursor" is here: 
https://www.tcl.tk/man/tcl/TkCmd/cursors.htm

Close [SOLVED]

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



[issue42332] add __weakref__ to types.GenericAlias

2020-11-12 Thread Tin Tvrtković

New submission from Tin Tvrtković :

For example, dict[int, int] cannot be used with singledispatch because 
types.GenericAlias doesn't support weak references.

I'm an author of a third party library (https://github.com/Tinche/cattrs) for 
which this functionality would be useful.

Here's a similar issue in typing (note that this issue is for 
*types*.GenericAlias) that was fixed: 
https://github.com/python/typing/issues/345

--
messages: 380816
nosy: gvanrossum, tinchester
priority: normal
severity: normal
status: open
title: add __weakref__ to types.GenericAlias
type: enhancement
versions: Python 3.10, Python 3.9

___
Python tracker 

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



[issue42237] test_socket.SendfileUsingSendfileTest fails on illumos

2020-11-12 Thread Andrew Svetlov


Andrew Svetlov  added the comment:


New changeset f37628eb7117f222de24a6931aa7639e668cb7b0 by Jakub Stasiak in 
branch '3.8':
[3.8] bpo-42237: Fix os.sendfile() on illumos (GH-23154). (GH-23246)
https://github.com/python/cpython/commit/f37628eb7117f222de24a6931aa7639e668cb7b0


--

___
Python tracker 

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



[issue38823] Improve stdlib module initialization error handling.

2020-11-12 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +22144
pull_request: https://github.com/python/cpython/pull/23247

___
Python tracker 

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



[issue42237] test_socket.SendfileUsingSendfileTest fails on illumos

2020-11-12 Thread Andrew Svetlov


Change by Andrew Svetlov :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.8

___
Python tracker 

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



[issue42327] Add PyModule_Add()

2020-11-12 Thread STINNER Victor


STINNER Victor  added the comment:

Oh, I just rejected PR 17298. Copy of my message:
---
I added PyModule_AddObjectRef() which uses strong references, rather than only 
stealing a reference on success.

I also enhanced the documentation to show concrete examples:
https://docs.python.org/dev/c-api/module.html#c.PyModule_AddObjectRef

I modified a few extension to use PyModule_AddObjectRef(). Sometimes, 
PyModule_AddObject() is more appropriate. Sometimes, PyModule_AddObjectRef() is 
more appropriate. Both functions are relevant, and I don't see a clear winner.

I agree than fixing existing code is painful, but I hope that new code using 
mostly PyModule_AddObjectRef() would be simpler to review. I'm not sure that 
it's simpler to write new code using PyModule_AddObjectRef(), since you might 
need more Py_DECREF() calls.

My intent is to have more "regular" code about reference counting. See also: 
https://bugs.python.org/issue42294

Since you wrote that this API is a band aid on a broken API, I consider that 
you are fine with rejecting it and move on to the new PyModule_AddObjectRef().

Anyway, thanks for you attempt to make the C API less broken :-)
---

I added PyModule_AddObjectRef() in bpo-163574.

--

___
Python tracker 

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



[issue42327] Add PyModule_Add()

2020-11-12 Thread STINNER Victor


STINNER Victor  added the comment:

I'm using more and more often such macro:

#define MOD_ADD(name, expr) \
do { \
PyObject *obj = (expr); \
if (obj == NULL) { \
return -1; \
} \
if (PyModule_AddObjectRef(mod, name, obj) < 0) { \
Py_DECREF(obj); \
return -1; \
} \
Py_DECREF(obj); \
} while (0)

Would PyModule_Add() replace such macro?

--

___
Python tracker 

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



[issue42327] Add PyModule_Add()

2020-11-12 Thread STINNER Victor


STINNER Victor  added the comment:

If PyModule_Add() is added, I would suggest to rename PyModule_AddObjectRef() 
to PyModule_AddRef() for consistency.

IMHO PyModule_AddObjectRef() remains useful even if PyModule_Add() is added.

--

___
Python tracker 

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



[issue42327] Add PyModule_Add()

2020-11-12 Thread STINNER Victor


STINNER Victor  added the comment:

In practice, PyModule_AddRef(mod, obj) behaves as PyModule_Add(mod, 
Py_NewRef(obj)) if I understood correctly.

--

___
Python tracker 

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



[issue38823] Improve stdlib module initialization error handling.

2020-11-12 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset d19fa7a337d829e3dab3e9f919f5dcf09cf6f6ba by Victor Stinner in 
branch 'master':
bpo-38823: Fix refleaks in _ctypes extension init (GH-23247)
https://github.com/python/cpython/commit/d19fa7a337d829e3dab3e9f919f5dcf09cf6f6ba


--

___
Python tracker 

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



[issue38823] Improve stdlib module initialization error handling.

2020-11-12 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +22145
pull_request: https://github.com/python/cpython/pull/23248

___
Python tracker 

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



[issue42260] [C API] Add PyInterpreterState_SetConfig(): reconfigure an interpreter

2020-11-12 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +22146
pull_request: https://github.com/python/cpython/pull/23249

___
Python tracker 

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



[issue42260] [C API] Add PyInterpreterState_SetConfig(): reconfigure an interpreter

2020-11-12 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset ef75a625cdf8377d687a04948b4db9bc1917bf19 by Victor Stinner in 
branch 'master':
bpo-42260: Initialize time and warnings earlier at startup (GH-23249)
https://github.com/python/cpython/commit/ef75a625cdf8377d687a04948b4db9bc1917bf19


--

___
Python tracker 

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



[issue38823] Improve stdlib module initialization error handling.

2020-11-12 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset b5cc05bbe681dbe06d5ec6d34318815d1c1ad6c5 by Victor Stinner in 
branch 'master':
bpo-38823: Always build _ctypes with wchar_t (GH-23248)
https://github.com/python/cpython/commit/b5cc05bbe681dbe06d5ec6d34318815d1c1ad6c5


--

___
Python tracker 

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



[issue42312] sys.prefix is set incorrectly on Mac OS X

2020-11-12 Thread Michael Ferguson


Michael Ferguson  added the comment:

> The way sys.prefix is calculated on macOS ensures that the correct sys.prefix 
> is calculated even if you copy the binary to a different location. That's 
> functionality I don't want to drop.

I agree with you that it's important for the Python interpreter to find the 
libraries it is installed with even if the framework launcher is copied to a 
different location.

However I think it's possible to support finding the installation while fixing 
the issue I am bringing up. Finding the installation amounts to getting the 
correct `sys.base_prefix` (no matter where the launcher is copied). It seems to 
me that if the launcher is copied to a different directory, `sys.prefix` should 
change in some cases. That already happens when making a `venv` with copies 
instead of links. Could the framework launcher consider `argv[0]` without 
causing problems in this use case?

I think this is a bug and not a feature tradeoff because a platform-specific 
wrapper should be as transparent as possible and as a result should keep the 
`argv[0]` behavior that occurs without the wrapper.


In any case, do you think that there is a way to get the behavior I am looking 
for (basically, invoke a Python interpreter that has sys.prefix set to the venv 
but without a symbolic link)?

--

___
Python tracker 

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



[issue40939] Remove the old parser

2020-11-12 Thread STINNER Victor


STINNER Victor  added the comment:

I reopen the issue.

Would you mind to explicitly list function removed from the C API in What's New 
in Python 3.10?
https://docs.python.org/dev/whatsnew/3.10.html#id4

I'm talking about the commit 1ed83adb0e95305af858bd41af531e487f54fee7.

For example, the unbound project no longer builds with Python 3.10 because 
PyParser_SimpleParseFile() has been removed:
https://bugzilla.redhat.com/show_bug.cgi?id=1889726

There is no mention of PyParser_SimpleParseFile() removal in What's New in 
Python 3.10. There is only a mention that it's being deprecated in What's New 
in Python 3.9.

--
resolution: fixed -> 
status: closed -> open

___
Python tracker 

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



[issue42312] sys.prefix is set incorrectly on Mac OS X

2020-11-12 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

> In any case, do you think that there is a way to get the behavior I am 
> looking for (basically, invoke a Python interpreter that has sys.prefix set 
> to the venv but without a symbolic link)?

Not that I know.

Using the python binary in the virtual environment is part of the design of 
this feature. That you can "fake" this on a lot of unix platforms by using a 
different interpreter with argv[0] set to a different path is a happy 
coincidence. 

I'm also not convinced that your trick actually accomplishes what you hope, the 
virtual environment still has a dependency on the Python installation in the 
original location. That location is mentioned in pyvenv.cfg at the root of the 
environment, and AFAIK that configuration is used to set up sys.path.

--

___
Python tracker 

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



[issue40939] Remove the old parser

2020-11-12 Thread STINNER Victor

STINNER Victor  added the comment:

> There is no mention of PyParser_SimpleParseFile() removal in What's New in 
> Python 3.10.

By the way, is there a replacement for this function? The unbound project uses 
it to display a SyntaxError when PyRun_SimpleFile() fails.

Petr Menšík asked:

"Could we instead modify PyRun_SimpleFile call to produce just one exception, 
then print it to stderr once and once into the log? (...) But it seems 
PyRun_SimpleFile does not throw Exception. Can you recommend variant or flags, 
which would make it raise an Exception, which log_py_err() would then to log 
file? After commenting out PyParser_SimpleParseFile it reports None, so it did 
not already raise an exception."

https://bugzilla.redhat.com/show_bug.cgi?id=1889726#c3

unbound used the removed function PyParser_SimpleParseFile() in 
pythonmod/pythonmod.c. Extract of unbound-1.12.0.tar.gz:

   if (PyRun_SimpleFile(script_py, pe->fname) < 0) {
  log_err("pythonmod: can't parse Python script %s", pe->fname);
  /* print the error to logs too, run it again */
  fseek(script_py, 0, SEEK_SET);
  /* we don't run the file, like this, because then side-effects
   *s = PyRun_File(script_py, pe->fname, Py_file_input, 
   *PyModule_GetDict(PyImport_AddModule("__main__")), pe->dict);
   * could happen (again). Instead we parse the file again to get
   * the error string in the logs, for when the daemon has stderr
   * removed.  SimpleFile run already printed to stderr, for then
   * this is called from unbound-checkconf or unbound -dd the user
   * has a nice formatted error.
  */
  /* ignore the NULL return of _node, it is NULL due to the parse failure
   * that we are expecting */
  (void)PyParser_SimpleParseFile(script_py, pe->fname, Py_file_input);
  log_py_err();
  PyGILState_Release(gil);
  fclose(script_py);
  return 0;
   }

--

___
Python tracker 

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



[issue42332] add __weakref__ to types.GenericAlias

2020-11-12 Thread Ken Jin


Change by Ken Jin :


--
keywords: +patch
nosy: +kj
nosy_count: 2.0 -> 3.0
pull_requests: +22147
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/23250

___
Python tracker 

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



[issue42327] Add PyModule_Add()

2020-11-12 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

PyModule_Add() allows to make such macro much simpler:

#define MOD_ADD(name, expr) \
do { \
if (PyModule_Add(mod, name, expr) < 0) { \
return -1; \
} \
} while (0)

PyModule_AddObjectRef() is just Py_XINCREF() followed by PyModule_Add(). But 
since most values added to the module are new references, Py_XINCREF() is 
usually not needed. The PyModule_Add* API is a convenient API. It is not 
necessary, you can use PyModule_GetDict() + PyDict_SetItemString(), but with 
this API it is easier. And PyModule_Add() is a correct PyModule_AddObject() 
(which was broken a long time ago and cannot be fixed now) and is more 
convenient than PyModule_AddObjectRef().

PyModule_AddIntConstant() and PyModule_AddStringConstant() can be easily 
expressed in terms of PyModule_Add():

PyModule_Add(m, name, PyLong_FromLong(value))
PyModule_Add(m, name, PyUnicode_FromString(value))

And it is easy to combine it with other functions: PyLong_FromLongLong(), 
PyLong_FromUnsignedLong(), PyLong_FromVoidPtr(), PyFloat_FromDouble(), 
PyCapsule_New(), PyType_FromSpec(), etc.

--

___
Python tracker 

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



[issue42329] typing classes do not have __name__ attributes in 3.7+

2020-11-12 Thread Guido van Rossum


Guido van Rossum  added the comment:

So shall we just close this?

--

___
Python tracker 

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



[issue42317] Docs of `typing.get_args`: Mention that due to caching of typing generics the order of arguments for Unions can be different from the one of the returned tuple

2020-11-12 Thread Ken Jin


Ken Jin  added the comment:

Dominik, would you like to submit a PR for this :) ?

--

___
Python tracker 

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



[issue42246] Implement PEP 626

2020-11-12 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +22148
pull_request: https://github.com/python/cpython/pull/23251

___
Python tracker 

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



[issue41987] singledispatchmethod raises an error when relying on a forward declaration

2020-11-12 Thread Guido van Rossum


Guido van Rossum  added the comment:

So the biggest difference I see is that ForwardRef._evaluate() has grown a 
recursive_guard argument in 3.9. This makes me think that in 3.8, only one 
level of evaluation was happening, and in 3.8, we keep evaluating until we 
don't see a string or ForwardRef.

The specific examples all happen at a point where the forward ref "C" cannot be 
resolved at all yet (since they're happening *in the class body*).

Possibly the best way out is to treat unresolved references differently, and 
just return the ForwardRef to the caller -- after all this is what the example 
does in 3.8.

--

___
Python tracker 

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



[issue42327] Add PyModule_Add()

2020-11-12 Thread STINNER Victor


STINNER Victor  added the comment:

> PyModule_AddObjectRef() is just Py_XINCREF() followed by PyModule_Add(). But 
> since most values added to the module are new references, Py_XINCREF() is 
> usually not needed.

There is no general rule. I saw two main cases.


(A) Create an object only to add it into the module. PyModule_Add() and 
PyModule_AddObject() are good for that case.

Example in the array module:

PyObject *typecodes = PyUnicode_DecodeASCII(buffer, p - buffer, NULL);
if (PyModule_AddObject(m, "typecodes", typecodes) < 0) {
Py_XDECREF(typecodes);
return -1;
}

This code can be rewritten with PyModule_Add():

PyObject *typecodes = PyUnicode_DecodeASCII(buffer, p - buffer, NULL);
if (PyModule_Add(m, "typecodes", typecodes) < 0) {
return -1;
}

Py_XDECREF(typecodes) is no longer needed using PyModule_Add().


(B) Add an existing object into the module, but the objet is already stored 
elsewhere. PyModule_AddObjectRef() is good for that case. It became common to 
have this case when an object is also stored in the module state. 

Example in _ast:

state->AST_type = PyType_FromSpec(&AST_type_spec);
if (!state->AST_type) {
return 0;
}
(...)
if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {
return -1;
}

state->AST_type and module attribute both hold a strong reference to the type.

--

___
Python tracker 

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



[issue42332] add __weakref__ to types.GenericAlias

2020-11-12 Thread Tin Tvrtković

Tin Tvrtković  added the comment:

It would be great if we could get this into 3.9.

--

___
Python tracker 

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



[issue42321] Limitations of building a static python library on Windows (MSVC)

2020-11-12 Thread Steve Dower


Steve Dower  added the comment:

> Does a statically built Windows python.exe support C extension modules at all?

I've given this some thought in the past, and I suspect the answer is "no" 
unless you were to also statically link the extension modules into the same 
executable (which will likely require code modifications).

That may answer the rest of your queries, but perhaps not. I'll have to give 
those some more thought.

> For now, I'm disabling extensions on a static MSVC build.

This seems like the best option.

--

___
Python tracker 

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



[issue42332] add __weakref__ to types.GenericAlias

2020-11-12 Thread Guido van Rossum


Guido van Rossum  added the comment:

I think it's reasonable to consider this a bug to be fixed.

--

___
Python tracker 

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



[issue42333] Port ssl module to heap types and module state (PEP 573)

2020-11-12 Thread Christian Heimes


New submission from Christian Heimes :

Move all objects to module state. Convert all types and extensions to heap 
types.

--
messages: 380837
nosy: christian.heimes
priority: normal
severity: normal
stage: patch review
status: open
title: Port ssl module to heap types and module state (PEP 573)
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



[issue42333] Port ssl module to heap types and module state (PEP 573)

2020-11-12 Thread Christian Heimes


Change by Christian Heimes :


--
keywords: +patch
pull_requests: +22149
pull_request: https://github.com/python/cpython/pull/23253

___
Python tracker 

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



[issue42308] Add threading.__excepthook__ similar to sys.__excepthook__

2020-11-12 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 750c5abf43b7b1627ab59ead237bef4c2314d29e by Mario Corchero in 
branch 'master':
bpo-42308: Add threading.__excepthook__ (GH-23218)
https://github.com/python/cpython/commit/750c5abf43b7b1627ab59ead237bef4c2314d29e


--

___
Python tracker 

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



[issue42308] Add threading.__excepthook__ similar to sys.__excepthook__

2020-11-12 Thread STINNER Victor


STINNER Victor  added the comment:

PR merged, thanks Mario.

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



[issue42333] Port ssl module to heap types and module state (PEP 573)

2020-11-12 Thread hai shi


Change by hai shi :


--
nosy: +shihai1991

___
Python tracker 

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



[issue42334] Subclassing int and complex with keyword arguments weird

2020-11-12 Thread autospamfighter


New submission from autospamfighter :

I was trying to make a custom complex class that looked something like this and 
it failed. I replaced complex with int and it also failed, but I tried float 
and it worked.

---fail
class A(complex):
def __init__(self, test):
super().__init__()

A(test=5)

---fail
class A(int):
def __init__(self, test):
super().__init__()

A(test=5)

---work
class A(float):
def __init__(self, test):
super().__init__()

A(test=5)

--
components: Library (Lib)
messages: 380840
nosy: autospamfighter
priority: normal
severity: normal
status: open
title: Subclassing int and complex with keyword arguments weird
versions: Python 3.9

___
Python tracker 

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



[issue42329] typing classes do not have __name__ attributes in 3.7+

2020-11-12 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

working as intended, they aren't classes.

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



[issue42334] Subclassing int and complex with keyword arguments weird

2020-11-12 Thread autospamfighter


autospamfighter  added the comment:

I tried some more classes and str is weird, but dict and set work fine. very 
weird

--

___
Python tracker 

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



[issue41987] singledispatchmethod raises an error when relying on a forward declaration

2020-11-12 Thread Ryan Sobol


Ryan Sobol  added the comment:

Does anyone know why the treatment of unresolved references was changed in 3.9?

--

___
Python tracker 

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



[issue42273] Using LazyLoader leads to AttributeError

2020-11-12 Thread E. Paine


E. Paine  added the comment:

Sorry Brett to readd you to the nosy for this, but we only got half a sentence 
in msg380718 (which is surely not what you intended?).

While I agree with you that this is not a bug, I do feel at least a note in the 
docs would be helpful to explain the implications of *adding* to sys.modules 
(the existing docs only mention replacing the dictionary or removing items from 
it).

Again, sorry to readd you to the nosy but Kevin's msg380719 was specifically 
for you.

--
nosy: +brett.cannon

___
Python tracker 

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



[issue41987] singledispatchmethod raises an error when relying on a forward declaration

2020-11-12 Thread Ryan Sobol

Ryan Sobol  added the comment:

Also, I'm a bit puzzled about something from the previously mentioned Integer 
class and its use of __future__.annotations. 

Why is it possible to declare an Integer return type for the add() method, but 
only possible to declare an "Integer" forward reference for the _() method?

--

___
Python tracker 

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



[issue42246] Implement PEP 626

2020-11-12 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset cc75ab791dd5ae2cb9f6e0c3c5f734a6ae1eb2a9 by Mark Shannon in 
branch 'master':
bpo-42246: Eliminate jumps to exit blocks by copying those blocks. (#23251)
https://github.com/python/cpython/commit/cc75ab791dd5ae2cb9f6e0c3c5f734a6ae1eb2a9


--

___
Python tracker 

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



[issue42335] Python Crashes Exception code 0xc0000374 ntdll.dll

2020-11-12 Thread Charles Staton


New submission from Charles Staton :

Hello, I am experiencing crashes of Python 3.8.5 (32 bit) on multiple identical 
Windows 10 x64 (Enterprise 2016 LTSB) machines. The Crashes are of the sort 
with the Windows popup "Python has stopped working" and there is no traceback.

The crashes occur sporadically. My program might run several days or just an 
hour, but invariably Python will crash if you wait long enough. I have attached 
a zip file containing all of the information provided by Windows in Application 
Logs, as well as some AppVerifier logs. I do not believe the AppVerifier logs 
are relevant however, as running my program with AppVerifier turned on causes 
Python to crash immediately upon startup and the information provided by 
Windows in Application Logs seems to indicate that it's AppVerifier crashing, 
not Python.

My program is quite large and is importing several libraries. It has a PyQt5 
GUI, and I'm using PyQt5's QThreadpool() to run several threads concurrently 
which do various things like: communicate with a web API (rauth, requests), 
communicate with a PLC (pyModbusTCP), communicate with another PLC 
(python-Snap7), communicate with an RS485 printer (pySerial), write CSV logs to 
a network drive, et. al. 

I'm running this program in a venv setup by PyCharm. The full information is in 
the attached zip file but here's an excerpt:

Faulting application name: python.exe, version: 3.8.5150.1013, time stamp: 
0x5f15bc04
Faulting module name: ntdll.dll, version: 10.0.14393.206, time stamp: 0x57dacde1
Exception code: 0xc374
Fault offset: 0x000d9841
Faulting process id: 0x1550
Faulting application start time: 0x01d6b839c684e37d
Faulting application path: 
C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\python.exe
Faulting module path: C:\Windows\SYSTEM32\ntdll.dll
Report Id: 24636ab4-7c06-4cd6-b8f8-4e20bfc59dce

Googling various clues has given me a vague clue that this is caused by Python 
attempting to access memory that it shouldn't. I have no idea how that happens 
or why. I'm clueless as to how I should go about troubleshooting this. If 
anyone can help I will be very grateful.

--
components: Interpreter Core, Library (Lib), ctypes
files: Python Crash Data.zip
messages: 380847
nosy: strantor
priority: normal
severity: normal
status: open
title: Python Crashes Exception code 0xc374 ntdll.dll
versions: Python 3.8
Added file: https://bugs.python.org/file49594/Python Crash Data.zip

___
Python tracker 

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



[issue42317] Docs of `typing.get_args`: Mention that due to caching of typing generics the order of arguments for Unions can be different from the one of the returned tuple

2020-11-12 Thread Dominik V.


Change by Dominik V. :


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

___
Python tracker 

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



[issue42273] Using LazyLoader leads to AttributeError

2020-11-12 Thread Brett Cannon


Change by Brett Cannon :


--
nosy:  -brett.cannon

___
Python tracker 

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



[issue42273] Using LazyLoader leads to AttributeError

2020-11-12 Thread Brett Cannon


Brett Cannon  added the comment:

You can ignore the half sentence. I was contemplating closing this issue when I 
decided to leave it open in case someone wanted to propose something and 
another core dev wanted to take it on. But everything is working as I expect it 
to and you may want to do your own implementation on PyPI if you want fancier 
as it's already a delicate thing as it is and so adding complexity for this 
specific case is a tough sell.

--

___
Python tracker 

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



[issue32426] Tkinter: reference document of possible cursor names

2020-11-12 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

A link here is not a patch.  The current tkinter doc for the cursor option in 
https://docs.python.org/3/library/tkinter.html#tk-option-data-types badly needs 
updating.
"""
The standard X cursor names from cursorfont.h can be used, without the XC_ 
prefix. For example to get a hand cursor (XC_hand2), use the string "hand2". 
You can also specify a bitmap and mask file of your own. See page 179 of 
Ousterhout’s book.
"""

The ttk doc https://docs.python.org/3/library/tkinter.ttk.html#standard-options 
is, as noted, incomplete.
"Specifies the mouse cursor to be used for the widget. If set to the empty 
string (the default), the cursor is inherited for the parent widget."


I propose to replace the tkinter entry with a combined and updated entry.
"""
The name of the cursor to use when the mouse point is over the widget.  An 
empty string, the default, means to inherit the cursor from the parent widget 
or the system. "none" means no cursor.  Other names recognized by tk are listed 
at https://www.tcl.tk/man/tcl/TkCmd/cursors.htm.  Possible forms of the 
cross-platform cursors are illustrated at 
https://tkdocs.com/shipman/cursors.html.  The cursor hot spot, the point 
reported for mouse clicks, depends on the cursor.
"""

I may try to reference this, rather than copy it, in the ttk doc.

--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python
resolution: fixed -> 
stage: resolved -> needs patch
status: closed -> open
title: Tkinter.ttk Widget does not define wich option exists to set the cursor 
-> Tkinter: reference document of possible cursor names
type: resource usage -> 
versions: +Python 3.10 -Python 3.8

___
Python tracker 

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



[issue42317] Docs of `typing.get_args`: Mention that due to caching of typing generics the order of arguments for Unions can be different from the one of the returned tuple

2020-11-12 Thread Dominik V.


Dominik V.  added the comment:

Thinking more about it, I came to realize that it's not the Union that sits at 
the root of this behavior, but rather the caching performed by generic types in 
general. So if we consider

```
L1 = List[Union[int, str]]
L2 = List[Union[str, int]]
```

then `get_args(L1)[0] is get_args(L2)[0]` and so `get_args` has no influence on 
the order of arguments of the Union objects (they are already the same for L1 
and L2).

So I think it would be more accurate to add the following sentence instead:

> If `X` is a generic type, the returned objects `(Y, Z, ...)` might not be 
> identical to the ones used in the form `X[Y, Z, ...]` due to type caching.

Everything else follows from there (including flattening of nested Unions).

--

___
Python tracker 

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



[issue42317] Docs of `typing.get_args`: Mention that due to caching of typing generics the order of arguments for Unions can be different from the one of the returned tuple

2020-11-12 Thread Guido van Rossum


Guido van Rossum  added the comment:

Exactly!

--

___
Python tracker 

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



[issue41987] singledispatchmethod raises an error when relying on a forward declaration

2020-11-12 Thread Guido van Rossum


Guido van Rossum  added the comment:

> Does anyone know why the treatment of unresolved references was changed in 
> 3.9?

Probably to prepare for 3.10, where `from _future__ import annotations` is the 
default.

> Also, I'm a bit puzzled about something from the previously mentioned Integer 
> class and its use of __future__.annotations. 
>
> Why is it possible to declare an Integer return type for the add() method, 
> but only possible to declare an "Integer" forward reference for the _() 
> method?

I don't know -- you might want to look through the source code of 
singledispatch. Maybe the flow through the initial decorator is different than 
the flow through register().

--

___
Python tracker 

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



[issue42296] Infinite loop uninterruptable on Windows in 3.10

2020-11-12 Thread Guido van Rossum


Guido van Rossum  added the comment:

Can you think of a fix? (Presumably restore some code that was deleted from 
3.9?)

--

___
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-11-12 Thread STINNER Victor


STINNER Victor  added the comment:

See bpo-27400 for the _datetime module: strptime_module variable is not cleared 
by Py_Finalize().

--

___
Python tracker 

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



[issue40939] Remove the old parser

2020-11-12 Thread Guido van Rossum


Guido van Rossum  added the comment:

Honestly that code seems poorly thought out. If running it returns -1, an 
exception was presumably reported, but not necessarily SyntaxError -- so 
parsing it may not produce an error at all.

The functionality needed is in PyRun_InteractiveOneObjectEx(), but that is not 
public. :-(

--

___
Python tracker 

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



[issue42333] Port ssl module to heap types and module state (PEP 573)

2020-11-12 Thread Christian Heimes

Christian Heimes  added the comment:

I underestimated the effort but it's done:

   +567 −446
   1,013 lines changed

I even got rid of PyState_FindModule().

--

___
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-11-12 Thread Christian Heimes


Christian Heimes  added the comment:

See bpo-42333 for _ssl module. The PR introduces module state and ports the 
_ssl extension to multiphase initialization.

--
nosy: +christian.heimes

___
Python tracker 

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



[issue42336] Make PCbuild/build.bat build x64 by default

2020-11-12 Thread Steve Dower


New submission from Steve Dower :

Now that the 64-bit download is the default on python.org, we should make the 
build command default to 64-bit as well.

This should only affect contributors, so should be non-controversial. But we 
should add a "-x86" option to the batch file as well.

--
components: Build, Windows
messages: 380858
nosy: paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Make PCbuild/build.bat build x64 by default
versions: Python 3.10, Python 3.9

___
Python tracker 

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



[issue42337] Skip building web installers on Windows

2020-11-12 Thread Steve Dower


New submission from Steve Dower :

In future releases, we won't be advertising the web-based installers anymore. 
They never got much use, and the shorter list of downloads will be more 
beneficial to users than saving 10-20MB worth of bandwidth. The web site change 
has already been made, and depending on when RMs pick up the newer script might 
impact any future release.

For 3.10, at least, we can stop producing and uploading the web-based 
installer. It won't hurt to keep doing it, and the *_pdb.msi and *_d.msi files 
will remain (as those are always download on demand), but it can eventually 
stop being produced (should just be in Tools/msi/buildrelease.bat, IIRC).

--
assignee: steve.dower
components: Build, Windows
messages: 380859
nosy: paul.moore, steve.dower, tim.golden, zach.ware
priority: low
severity: normal
status: open
title: Skip building web installers on Windows
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



[issue42336] Make PCbuild/build.bat build x64 by default

2020-11-12 Thread Tim Peters


Tim Peters  added the comment:

+1. If you're feeling more ambitious, it would also be good to change build.bat 
and rt.bat to use the same "which platform?" spellings and with the same 
defaults.

--
nosy: +tim.peters

___
Python tracker 

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



[issue42338] Enable Debug Build For Python Native Modules in Windows, with Visual Studio Toolchain

2020-11-12 Thread Jeff Moguillansky


New submission from Jeff Moguillansky :

Hi,
We developed a Python module that interfaces with native code via Cython.  
We currently build on Windows with Visual Studio Toolchain. 
We encounter the following issues when trying to build a debug version:
1) 3rd party modules installed via PIP are Release mode, but Visual Studio 
toolchain doesn't allow to mix Debug and Release libs.  To workaround this 
issue, we build our module in "Release" mode, with debug symbols enabled, and 
with compiled optimization disabled (essentially a hack). 
2) To build our module we currently use the following hack:
step 1: run python.exe setup.py build --compiler=msvc
step 2: extract the output
step 3: change /Ox to /Od (disable compiler optimization)
add /Zi flag to compiler flags (enable debug symbols)
add /DEBUG flag to linker flags

Please advise what is the best solution?

--
components: Build
messages: 380861
nosy: jmoguill2
priority: normal
severity: normal
status: open
title: Enable Debug Build For Python Native Modules in Windows, with Visual 
Studio Toolchain
type: compile error
versions: Python 3.8

___
Python tracker 

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



[issue42319] The `functools.singledispatchmethod` example in the document cannot run

2020-11-12 Thread Jakub Stasiak


Jakub Stasiak  added the comment:

There's an earlier issue created that relates to this 
(https://bugs.python.org/issue39679) and there are some possible solutions to 
get singledispatchmethod and classmethod work there.

--
nosy: +jstasiak

___
Python tracker 

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



[issue40939] Remove the old parser

2020-11-12 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> By the way, is there a replacement for this function? The unbound project 
> uses it to display a SyntaxError when PyRun_SimpleFile() fails.

There is no replacement for the function because that function returned CST 
nodes and those not exist anymore.

--

___
Python tracker 

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



[issue17852] Built-in module _io can lose data from buffered files in reference cycles

2020-11-12 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 

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



[issue42296] Infinite loop uninterruptable on Windows in 3.10

2020-11-12 Thread Steve Dower


Steve Dower  added the comment:

This looks like the smallest change I can make to fix it:

diff --git a/Include/internal/pycore_pystate.h 
b/Include/internal/pycore_pystate.h
index 0cd5550cfd..9ff740b87b 100644
--- a/Include/internal/pycore_pystate.h
+++ b/Include/internal/pycore_pystate.h
@@ -34,7 +34,11 @@ _Py_IsMainInterpreter(PyThreadState* tstate)
 static inline int
 _Py_ThreadCanHandleSignals(PyInterpreterState *interp)
 {
+#ifndef MS_WINDOWS
 return (_Py_IsMainThread() && interp == _PyRuntime.interpreters.main);
+#else
+return (interp == _PyRuntime.interpreters.main);
+#endif
 }

I'll need Victor(?) to confirm whether checking for the main interpreter is 
sufficient. We're calling this from a new thread that AFAICT never holds the 
GIL, and we pass the main interpreter in explicitly (from trip_signal) so this 
check always succeeds (here, but not necessarily in other places where it is 
called).

--

___
Python tracker 

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



[issue42246] Implement PEP 626

2020-11-12 Thread STINNER Victor


STINNER Victor  added the comment:

> New changeset 877df851c3ecdb55306840e247596e7b7805a60a by Mark Shannon in 
> branch 'master':
> bpo-42246: Partial implementation of PEP 626. (GH-23113)

This change introduced reference leaks:
https://buildbot.python.org/all/#builders/384/builds/100

5 tests failed:
test_asyncgen test_builtin test_coroutines test_exceptions
test_syntax

For example:

$ ./python -m test test_syntax -R 3:3 -m 
test.test_syntax.SyntaxTestCase.test_no_indent
0:00:00 load avg: 1.59 Run tests sequentially
0:00:00 load avg: 1.59 [1/1] test_syntax
beginning 6 repetitions
123456
..
test_syntax leaked [27, 27, 27] references, sum=81
test_syntax leaked [20, 20, 20] memory blocks, sum=60
test_syntax failed

== Tests result: FAILURE ==

1 test failed:
test_syntax

Total duration: 955 ms
Tests result: FAILURE

--
nosy: +vstinner

___
Python tracker 

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



[issue42319] The `functools.singledispatchmethod` example in the document cannot run

2020-11-12 Thread hongweipeng


hongweipeng  added the comment:

Thanks,so close this one due to duplicate issue.

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



[issue42339] official embedded Python fails to import certain modules

2020-11-12 Thread Jelle Geerts


New submission from Jelle Geerts :

This problem happened with 'python-3.8.6-embed-amd64.zip' when trying to import 
certain modules.

Note that this problem does NOT happen with Python from 
'python-3.7.9-embed-amd64.zip' (its output is also attached below).

It happened with 'import socket', 'import ctypes', and so on (see below).

Platform: Windows 7 SP1 64-bit (also KB2999226 was installed)


Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AM
D64)] on win32
>>> import lzma
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 259, in load_module
  File "lzma.py", line 27, in 
ImportError: DLL load failed while importing _lzma: De parameter is onjuist.
>>> import socket
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 259, in load_module
  File "socket.py", line 49, in 
ImportError: DLL load failed while importing _socket: De parameter is onjuist.
>>> import ctypes
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 259, in load_module
  File "ctypes\__init__.py", line 7, in 
ImportError: DLL load failed while importing _ctypes: De parameter is onjuist.
>>> import bz2
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 259, in load_module
  File "bz2.py", line 19, in 
ImportError: DLL load failed while importing _bz2: De parameter is onjuist.
>>>


For comparison, with Python from 'python-3.7.9-embed-amd64.zip' it does work:


Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit
(AMD64)] on win32
>>> import lzma
>>> import socket
>>> import ctypes
>>> import bz2
>>>

--
components: Installation
messages: 380867
nosy: bughunter2
priority: normal
severity: normal
status: open
title: official embedded Python fails to import certain modules
type: crash
versions: Python 3.8

___
Python tracker 

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



[issue42340] KeyboardInterrupt should come with a warning

2020-11-12 Thread Benjamin Fogle


Change by Benjamin Fogle :


Added file: https://bugs.python.org/file49596/sigint_condition_2.py

___
Python tracker 

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



[issue42340] KeyboardInterrupt should come with a warning

2020-11-12 Thread Benjamin Fogle


New submission from Benjamin Fogle :

This is related to bpo-29988, and I'm happy to move this to there. I made this 
a separate issue because this is a workaround, not a fix as was being discussed 
there. Also unlike bpo-29988, this is not restricted to context managers or 
finally blocks.

TL;DR: Raising exceptions from interrupt handlers (most notably 
KeyboardInterrupt) can wreak havoc in ways that are impossible to fix. This 
should be noted in the documentation, with a workaround.

I've attached a few example scripts that cause various strange behavior on 
Linux when a KeyboardInterrupt is raised at just the right time. There are 
likely many, many more possible examples:
  - sigint_condition_1.py: Cause a deadlock with threading.Condition
  - sigint_condition_2.py: Cause a double-release and/or notify on unacquired 
threading.Condition
  - sigint_tempfile.py: Cause NamedTemporaryFiles to not be deleted
  - sigint_zipfile.py: Cause ZipExtFile to corrupt its state

When a user presses Ctrl+C, a KeyboardInterrupt will be raised on the main 
thread at some later time. This exception may be raised after any bytecode, and 
most Python code, including the standard library, is not designed to handle 
exceptions that spring up from nowhere.

As a simple example, consider threading.Condition:

def __enter__(self):
return self._lock.__enter__()

The KeyboardInterrupt could be raised just prior to return. In this case, 
__exit__ will never be called, and the underlying lock will remain acquired. A 
similar problem occurs if KeyboardInterrupt occurs at the start of __exit__.

This can be mitigated by attempting to catch a KeyboardInterrupt *absolutely 
everywhere*, but even then, it can't be fixed completely.

def __enter__(self):
try:
# it could happen here, in which case we should not unlock
ret = self._lock.__enter__()
# it could happen here, in which case we must unlock
except KeyboardInterrupt:
# it could, in theory, happen again right here
...
raise
return ret
# it could happen here, which is the same problem we had before

This is not restricted to context handlers or try/finally blocks. The zipfile 
module is a good example of code that is almost certain to enter an 
inconsistent state if a KeyboardInterrupt is raised while it's doing work:

class ZipExtFile:
...
def read1(self, n):
...
self._readbuffer = b''
# what happens if KeyboardInterrupt happens here?
self._offset = 0
...

Due to how widespread this is, it's not worth "fixing". (And honestly, it seems 
to be a rare problem in practice.) I believe that it would be better to clearly 
document that KeyboardInterrupt (or any exception propagated from a signal 
handler) may leave the system
in an inconsistent state. Complex or high reliability applications should avoid 
catching KeyboardInterrupt as a way of gracefully shutting down, and should 
prefer registering their own SIGINT handler. They should also avoid raising 
exceptions from signal handlers at all.

--
assignee: docs@python
components: Documentation
messages: 380868
nosy: benfogle, docs@python
priority: normal
severity: normal
status: open
title: KeyboardInterrupt should come with a warning
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



[issue42340] KeyboardInterrupt should come with a warning

2020-11-12 Thread Benjamin Fogle


Change by Benjamin Fogle :


Added file: https://bugs.python.org/file49595/sigint_condition_1.py

___
Python tracker 

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



[issue42340] KeyboardInterrupt should come with a warning

2020-11-12 Thread Benjamin Fogle


Change by Benjamin Fogle :


Added file: https://bugs.python.org/file49597/sigint_tempfile.py

___
Python tracker 

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



[issue42340] KeyboardInterrupt should come with a warning

2020-11-12 Thread Benjamin Fogle


Change by Benjamin Fogle :


Added file: https://bugs.python.org/file49598/sigint_zipfile.py

___
Python tracker 

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



[issue42340] KeyboardInterrupt should come with a warning

2020-11-12 Thread Benjamin Fogle


Change by Benjamin Fogle :


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

___
Python tracker 

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



[issue42296] Infinite loop uninterruptable on Windows in 3.10

2020-11-12 Thread Eryk Sun


Eryk Sun  added the comment:

Note that this issue only applies to a process that has a single Python thread. 
With multiple Python threads, the signal handler gets called when the main 
thread acquires the GIL. 

As far as Windows console-driven SIGINT and SIGBREAK are concerned, C 
signal_handler() is called on a new thread that the interpreter has never seen 
before and will never see again. But there's also 
signal.raise_signal(signal.SIGINT) to consider, executing on a Python thread. 
Another path to trip_signal() is via _thread.interrupt_main(), i.e. 
PyErr_SetInterrupt().

_Py_ThreadCanHandleSignals() checks whether the current thread is the main 
thread in the main interpreter. It gets called to guarantee this condition in 
multiple places, such as handle_signals() in Python/ceval.c. So the 
_Py_IsMainThread() call is required. In Windows, maybe the main-thread check 
could be bypassed in SIGNAL_PENDING_SIGNALS() for a non-Python thread (i.e. no 
tstate), by directly setting ceval2->eval_breaker instead of calling 
COMPUTE_EVAL_BREAKER() in this case.

--

___
Python tracker 

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



[issue42141] Speedup various dict inits

2020-11-12 Thread Inada Naoki


Change by Inada Naoki :


--
resolution:  -> rejected

___
Python tracker 

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



[issue42334] Subclassing int and complex with keyword arguments weird

2020-11-12 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

This is because int, str, and complex are immutable. If I have 

class MyInt(int):
def __init__(self, stuff):
pass

then when I call MyInt("19"), the string "19" is passed to the constructor 
int.__new__ before the overridden initializer MyInt.__init__. You can only 
override that by implementing a MyInt.__new__ to override the int constructor.

This is not a bug.

--
nosy: +Dennis Sweeney

___
Python tracker 

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



[issue42334] Subclassing int and complex with keyword arguments weird

2020-11-12 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

Here's an example:

class A(complex):
def __init__(self, *args, test):
self.test = test
def __new__(cls, *args, test):
return super().__new__(cls, *args)

>>> a = A(1, test="TEST")
>>> a
(1+0j)
>>> a.test
'TEST'

>>> b = A(1, 1, test="TEST2")
>>> b
(1+1j)
>>> b.test
'TEST2'

--

___
Python tracker 

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



[issue42253] xml.dom.minidom.rst missing standalone documentation

2020-11-12 Thread Mike Frysinger


Change by Mike Frysinger :


--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python
title: xml.dom.minidom.rst missed informations -> xml.dom.minidom.rst missing 
standalone documentation

___
Python tracker 

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



[issue23436] xml.dom.minidom.Element.ownerDocument is hidden

2020-11-12 Thread Mike Frysinger


Change by Mike Frysinger :


--
title: xml.dom.minidom.Element.ownerDocument is hiden -> 
xml.dom.minidom.Element.ownerDocument is hidden

___
Python tracker 

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



[issue42341] xml.dom.minidom parsing omits Text nodes in top level

2020-11-12 Thread Mike Frysinger


New submission from Mike Frysinger :

$ python3
Python 3.8.5 (default, Aug  2 2020, 15:09:07) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from xml.dom import minidom

# Lets parse a simple XML file with comment & text nodes in the top level.
>>> dom = minidom.parseString('>> encoding="UTF-8"?>\n\n\n\n\n\n\n')

# Where did those newlines get to outside of  ?
>>> dom.toxml()
'\n\n\n'

# No Text nodes in the root list :(.
>>> dom.childNodes
[, , ]

# But they all exist fine under .
>>> dom.childNodes[2].childNodes
[, , , 
, ]

--
components: XML
messages: 380872
nosy: vapier
priority: normal
severity: normal
status: open
title: xml.dom.minidom parsing omits Text nodes in top level
versions: Python 3.8

___
Python tracker 

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



[issue42339] official embedded Python fails to import certain modules

2020-11-12 Thread Christian Heimes


Change by Christian Heimes :


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

___
Python tracker 

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