This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Checks for PySys_GetObject("std???") == Py_None
Type: Stage:
Components: Interpreter Core Versions: Python 3.0
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: christian.heimes, gvanrossum
Priority: low Keywords: patch

Created on 2007-11-14 00:51 by christian.heimes, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
py3k_std_none_check.patch christian.heimes, 2007-11-14 00:51
Messages (6)
msg57476 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2007-11-14 00:51
Can you please review the patch. It's not urgent. It adds additional
tests for std??? == Py_None to some functions to speed up things or
raise more meaningful exceptions when sys.std??? is None.
msg57491 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-11-14 17:53
The patch looks okay, but I just thought of something -- why not make
sys.stdout and friends be undefined (i.e. NULL) instead of setting them
to None?  That way this patch isn't necessary and you only need one
small change to builtin_print() -- which you need anyway (Try deleting
sys.stdout and then printing something.)
msg57496 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2007-11-14 18:39
Guido van Rossum wrote:
> The patch looks okay, but I just thought of something -- why not make
> sys.stdout and friends be undefined (i.e. NULL) instead of setting them
> to None?  That way this patch isn't necessary and you only need one
> small change to builtin_print() -- which you need anyway (Try deleting
> sys.stdout and then printing something.)

I prefer "if sys.stdout is None" over "if hasattr(sys, 'stdout'):" and
"sys.stdout = None" over "del sys.stdout". I can't put words to it but
it feels more natural to set the stream to None (NULL) than to
incinerate the stream.

IMO the problem warrants a short poll at Python 3000 dev.

Christian
msg57499 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-11-14 18:54
Go for it.

On Nov 14, 2007 10:39 AM, Christian Heimes <report@bugs.python.org> wrote:
>
> Christian Heimes added the comment:
>
> Guido van Rossum wrote:
> > The patch looks okay, but I just thought of something -- why not make
> > sys.stdout and friends be undefined (i.e. NULL) instead of setting them
> > to None?  That way this patch isn't necessary and you only need one
> > small change to builtin_print() -- which you need anyway (Try deleting
> > sys.stdout and then printing something.)
>
> I prefer "if sys.stdout is None" over "if hasattr(sys, 'stdout'):" and
> "sys.stdout = None" over "del sys.stdout". I can't put words to it but
> it feels more natural to set the stream to None (NULL) than to
> incinerate the stream.
>
> IMO the problem warrants a short poll at Python 3000 dev.
>
> Christian
>
>
> __________________________________
> Tracker <report@bugs.python.org>
> <http://bugs.python.org/issue1440>
> __________________________________
>
msg57510 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-11-14 22:39
I take it back. You can check this in.
msg57517 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2007-11-15 02:27
Committed in r58974
History
Date User Action Args
2022-04-11 14:56:28adminsetgithub: 45781
2008-01-06 22:29:45adminsetkeywords: - py3k
versions: Python 3.0
2007-11-15 02:27:11christian.heimessetstatus: open -> closed
resolution: fixed
messages: + msg57517
2007-11-14 22:39:04gvanrossumsetmessages: + msg57510
2007-11-14 18:54:57gvanrossumsetmessages: + msg57499
2007-11-14 18:39:36christian.heimessetmessages: + msg57496
2007-11-14 17:53:12gvanrossumsetmessages: + msg57491
2007-11-14 00:51:07christian.heimescreate