Issue36015
Created on 2019-02-17 19:20 by Riccardo Magliocchetti, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 11908 | merged | Riccardo Magliocchetti, 2019-02-17 19:20 | |
| PR 13183 | merged | miss-islington, 2019-05-08 07:15 | |
| Messages (11) | |||
|---|---|---|---|
| msg335784 - (view) | Author: Riccardo Magliocchetti (Riccardo Magliocchetti) * | Date: 2019-02-17 19:20 | |
When debugging uwsgi logging issues with python3.7 i got this on python 3.7.2: Traceback (most recent call last): File "/usr/lib/python3.7/logging/__init__.py", line 269, in _after_at_fork_weak_calls _at_fork_weak_calls('release') File "/usr/lib/python3.7/logging/__init__.py", line 261, in _at_fork_weak_calls method_name, "method:", err, file=sys.stderr) File "/usr/lib/python3.7/logging/__init__.py", line 1066, in __repr__ name = name + ' ' TypeError: unsupported operand type(s) for +: 'int' and 'str' AFAICS uwsgi creates sys.stderr as an unbuffered file with PyFile_FromFd() and sets it to sys dict. |
|||
| msg335814 - (view) | Author: Vinay Sajip (vinay.sajip) * ![]() |
Date: 2019-02-18 11:15 | |
I'm not sure this is a problem with logging. The code immediately preceding the failure is:
name = getattr(self.stream, 'name', '')
if name:
name += ' '
So, the failure occurs because the stream has a name attribute which is not a string. Even if sys.stderr itself is an unbuffered file, why is its 'name' attribute not a string? I don't imagine the name would be actually used for I/O, and having it set to an integer is a surprise.
I propose to close this (and the associated PR) unless a good reason is given why we have to support non-string names here.
|
|||
| msg335819 - (view) | Author: Riccardo Magliocchetti (Riccardo Magliocchetti) * | Date: 2019-02-18 11:28 | |
Yeah, I'm not sure the pr is just papering over the real issue :) Need to check what io.open sets on name. IF it setting the fd as name instead of creating a string that would be still be a bug in Python to me. Could you please wait a bit for me to check that before closing? |
|||
| msg335822 - (view) | Author: Ronald Oussoren (ronaldoussoren) * ![]() |
Date: 2019-02-18 11:40 | |
In Python 3.7.2: >>> open(2, 'a') <_io.TextIOWrapper name=2 mode='a' encoding='UTF-8'> >>> m = _ >>> m.name 2 >>> type(_) <class 'int'> That is, when opening a file descriptor the name is set to the value of that file descriptor as an integer. BTW. The implementation of PyFile_FromFd is a thin wrapper around the open function. |
|||
| msg335843 - (view) | Author: Vinay Sajip (vinay.sajip) * ![]() |
Date: 2019-02-18 15:39 | |
> That is, when opening a file descriptor the name is set to the value of that file descriptor as an integer. I see. But I wonder if there is anything that relies on the name being an integer? It seems pretty counter-intuitive for a 'name' attribute to be set to something other than a string. |
|||
| msg335868 - (view) | Author: Riccardo Magliocchetti (Riccardo Magliocchetti) * | Date: 2019-02-18 21:49 | |
Looking at Modules/_io/fileio.c::_io_FileIO___init___impl it seems an int for nameobj is just fine. Not sure I am looking at the right code though :) |
|||
| msg337207 - (view) | Author: Riccardo Magliocchetti (Riccardo Magliocchetti) * | Date: 2019-03-05 15:30 | |
@Vinay Do you have any update on this? thanks |
|||
| msg337362 - (view) | Author: Vinay Sajip (vinay.sajip) * ![]() |
Date: 2019-03-07 06:25 | |
Sorry, Riccardo, been very busy lately and not had time to look at it :-( Soon, I hope. |
|||
| msg341766 - (view) | Author: Riccardo Magliocchetti (Riccardo Magliocchetti) * | Date: 2019-05-07 16:17 | |
Friendly ping, would be helpful to get this resolved for 3.8.0. Thanks! |
|||
| msg341832 - (view) | Author: Vinay Sajip (vinay.sajip) * ![]() |
Date: 2019-05-07 21:36 | |
New changeset ca87eebb22d202c33f3317cbf85059cadc64fa9f by Vinay Sajip (Riccardo Magliocchetti) in branch 'master': bpo-36015: Handle StreamHandler representaton of stream with an integer name (GH-11908) https://github.com/python/cpython/commit/ca87eebb22d202c33f3317cbf85059cadc64fa9f |
|||
| msg342590 - (view) | Author: Vinay Sajip (vinay.sajip) * ![]() |
Date: 2019-05-15 18:06 | |
New changeset 78dd781ef4d41dfefad53aa3bc52c39b0d443b19 by Vinay Sajip (Miss Islington (bot)) in branch '3.7': bpo-36015: Handle StreamHandler representaton of stream with an integer name (GH-11908) (GH-13183) https://github.com/python/cpython/commit/78dd781ef4d41dfefad53aa3bc52c39b0d443b19 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:11 | admin | set | github: 80196 |
| 2019-05-15 18:41:32 | vinay.sajip | set | status: open -> closed resolution: not a bug -> fixed stage: patch review -> resolved |
| 2019-05-15 18:06:41 | vinay.sajip | set | messages: + msg342590 |
| 2019-05-08 07:15:36 | miss-islington | set | pull_requests: + pull_request13098 |
| 2019-05-07 21:36:42 | vinay.sajip | set | messages: + msg341832 |
| 2019-05-07 16:17:34 | Riccardo Magliocchetti | set | messages: + msg341766 |
| 2019-03-07 06:25:56 | vinay.sajip | set | messages: + msg337362 |
| 2019-03-05 15:30:39 | Riccardo Magliocchetti | set | messages: + msg337207 |
| 2019-02-18 21:49:49 | Riccardo Magliocchetti | set | messages: + msg335868 |
| 2019-02-18 15:40:49 | vinay.sajip | set | title: streamhandler canont represent streams with an integer as name -> streamhandler cannot represent streams with an integer as name |
| 2019-02-18 15:39:28 | vinay.sajip | set | messages: + msg335843 |
| 2019-02-18 11:40:56 | ronaldoussoren | set | nosy:
+ ronaldoussoren messages: + msg335822 |
| 2019-02-18 11:28:37 | Riccardo Magliocchetti | set | status: pending -> open messages: + msg335819 |
| 2019-02-18 11:15:56 | vinay.sajip | set | status: open -> pending resolution: not a bug messages: + msg335814 |
| 2019-02-18 08:43:50 | SilentGhost | set | nosy:
+ vinay.sajip type: crash -> behavior |
| 2019-02-17 19:20:57 | Riccardo Magliocchetti | set | keywords:
+ patch stage: patch review pull_requests: + pull_request11933 |
| 2019-02-17 19:20:24 | Riccardo Magliocchetti | create | |
