[issue26789] logging: Trying to log during Python finalization with NameError: name 'open' is not defined

2020-11-02 Thread STINNER Victor
STINNER Victor added the comment: I fixed the issue in the master and I will not backport the change to stable branches on purpose. Thanks for the review Vinay! -- I pushed a change in Python 3.10 which reduces the risk of "NameError: name 'open' is not defined" when logging really late

[issue26789] logging: Trying to log during Python finalization with NameError: name 'open' is not defined

2020-11-02 Thread STINNER Victor
STINNER Victor added the comment: New changeset 45df61fd2d58e8db33179f3b5d00e53fe6a7e592 by Victor Stinner in branch 'master': bpo-26789: Fix logging.FileHandler._open() at exit (GH-23053) https://github.com/python/cpython/commit/45df61fd2d58e8db33179f3b5d00e53fe6a7e592 --

[issue26789] logging: Trying to log during Python finalization with NameError: name 'open' is not defined

2020-10-30 Thread STINNER Victor
STINNER Victor added the comment: Attached PR 23053 fix the root issue of the infamous "NameError: name 'open' is not defined" error in the logging module. -- ___ Python tracker

[issue26789] logging: Trying to log during Python finalization with NameError: name 'open' is not defined

2020-10-30 Thread STINNER Victor
STINNER Victor added the comment: Note: Attached error.py no longer works with a recent aiohttp version. -- ___ Python tracker ___

[issue26789] logging: Trying to log during Python finalization with NameError: name 'open' is not defined

2020-10-30 Thread STINNER Victor
Change by STINNER Victor : -- keywords: +patch pull_requests: +21972 stage: -> patch review pull_request: https://github.com/python/cpython/pull/23053 ___ Python tracker ___

[issue26789] logging: Trying to log during Python finalization with NameError: name 'open' is not defined

2020-10-30 Thread STINNER Victor
STINNER Victor added the comment: > Issue26789. asyncio creates reference loops which caused to executing code > late at shutdown, and that code uses logging which always fail. Well, I suggest to attempt fixing logging. The reference cycle in asyncio.Task.set_exception() is *by design*.

[issue26789] logging: Trying to log during Python finalization with NameError: name 'open' is not defined

2020-10-30 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I am not sure that its all the same issue. There may be several different issues: * Issue39513. Logging fails with confusing traceback when called late at shutdown. I think that if logging cannot work at this stage it should either do nothing or emit a

[issue26789] logging: Trying to log during Python finalization with NameError: name 'open' is not defined

2020-10-30 Thread STINNER Victor
STINNER Victor added the comment: > It looks like a bug in finalize_interp_clear() which triggers a garbage > collection, whereas Python is no longer usable. I created bpo-42208 "Using logging or warnings during Python finalization does crash Python". --

[issue26789] logging: Trying to log during Python finalization with NameError: name 'open' is not defined

2020-10-30 Thread STINNER Victor
STINNER Victor added the comment: I hacked logging.FileHandler to keep a reference to the builtin open() function. I got new problems. In my test, I got a crash because of an unclosed file. It happens after PyInterpreterState_Clear(), in finalize_interp_clear(): /* Last explicit GC

[issue26789] logging: Trying to log during Python finalization with NameError: name 'open' is not defined

2020-10-30 Thread Vedran Čačić
Vedran Čačić added the comment: > In the OP, the error is caused by `open` being unavailable, which is a > builtin. According to what Serhiy says, this error would be after step 6 I think you read the post above incorrectly. The phase 3 is the one where open is removed, since it's not a

[issue26789] logging: Trying to log during Python finalization with NameError: name 'open' is not defined

2020-10-30 Thread STINNER Victor
STINNER Victor added the comment: I marked bpo-39513 and bpo-42203 as duplicates of this issue. I changed the title to reflect that the root issue is that logging during Python finalization can fail with NameError: name 'open' is not defined. -- components: +Library (Lib) -asyncio