[issue1442] pythonstartup addition of minor error checking

2007-11-13 Thread Joseph Armbruster

New submission from Joseph Armbruster:

Trunk revision: 58963

Description:  No warning or error is reported it a file pointed to by
PYTHONSTARTUP is not readable.

Request:  To display a warning so that the user may be notified.

Note:  Errors that may occur in PyRun_SimpleFileExFlags are being cast
away, may be worthwhile to report an error for those as well (unless
this was avoided for good reason :-)

Suggestion:

static void RunStartupFile(PyCompilerFlags *cf)
{
  char *startup = Py_GETENV("PYTHONSTARTUP");
  if (startup != NULL && startup[0] != '\0') {
FILE *fp = fopen(startup, "r");
if (fp != NULL) {
  (void) PyRun_SimpleFileExFlags(fp, startup, 0, cf);
  PyErr_Clear();
  fclose(fp);
}
else {
  fprintf(stderr,"Warning: Could not read startup file %s\n",startup);
}
  }
}

--
components: Interpreter Core
messages: 57482
nosy: JosephArmbruster
severity: minor
status: open
title: pythonstartup addition of minor error checking
type: behavior
versions: Python 2.6

__
Tracker <[EMAIL PROTECTED]>

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



[issue1442] pythonstartup addition of minor error checking

2007-11-14 Thread Martin v. Löwis

Changes by Martin v. Löwis:


--
keywords: +patch

__
Tracker <[EMAIL PROTECTED]>

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



[issue1442] pythonstartup addition of minor error checking

2007-11-14 Thread Christian Heimes

Christian Heimes added the comment:

Good idea!

Errors in the startup file are already reported by PyRun_*

--
nosy: +tiran
priority:  -> low
versions: +Python 3.0

__
Tracker <[EMAIL PROTECTED]>

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



[issue1442] pythonstartup addition of minor error checking

2007-11-14 Thread Christian Heimes

Christian Heimes added the comment:

I've a far better patch that uses Python's infrastructure to report the
error:

Index: Modules/main.c
===
--- Modules/main.c  (Revision 58966)
+++ Modules/main.c  (Arbeitskopie)
@@ -132,6 +132,16 @@
(void) PyRun_SimpleFileExFlags(fp, startup, 0, cf);
PyErr_Clear();
fclose(fp);
+   } else {
+   int save_errno;
+
+   save_errno = errno;
+   PySys_WriteStderr("Could not open PYTHONSTARTUP\n");
+   errno = save_errno;
+   PyErr_SetFromErrnoWithFilename(PyExc_IOError,
+   startup);
+   PyErr_Print();
+   PyErr_Clear();
}
}
 }


$ ./python
Python 3.0a1+ (py3k:58966M, Nov 14 2007, 17:17:06)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Could not open PYTHONSTARTUP
IOError: [Errno 2] No such file or directory:
'/home/heimes/.python/startup.py'
>>>  

Fixed in r58969 (py3k)

--
resolution:  -> accepted
versions:  -Python 3.0

__
Tracker <[EMAIL PROTECTED]>

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



[issue1442] pythonstartup addition of minor error checking

2007-11-24 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

Shall we close this issue?

--
nosy: +amaury.forgeotdarc

__
Tracker <[EMAIL PROTECTED]>

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



[issue1442] pythonstartup addition of minor error checking

2007-11-24 Thread Christian Heimes

Christian Heimes added the comment:

I think we should backport it to 2.6 and maybe 2.5.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1442] pythonstartup addition of minor error checking

2008-01-04 Thread Joseph Armbruster

Joseph Armbruster added the comment:

Backport to 2.6a0 and tested with:

Python 2.6a0 (trunk:59710M, Jan  4 2008, 11:36:45) [MSC v.1500 32 bit
(Intel)] on win32

Added file: http://bugs.python.org/file9063/pythonstartup.patch

__
Tracker <[EMAIL PROTECTED]>

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



[issue1442] pythonstartup addition of minor error checking

2008-03-28 Thread Georg Brandl

Georg Brandl <[EMAIL PROTECTED]> added the comment:

Backported to 2.6 in r62030 and 2.5 in r62031.

--
nosy: +georg.brandl
status: open -> closed

__
Tracker <[EMAIL PROTECTED]>

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