annotate Python/strerror.c @ 21725:5d2bfbd47f1b legacy-trunk

A tentative fix for SF bug #503837 (Roeland Rengelink): type.__module__ problems (again?) This simply initializes the __module__ local in a class statement from the __name__ global. I'm not 100% sure that this is the correct fix, although it usually does the right thing. The problem is that if the class statement executes in a custom namespace, the __name__ global may be taken from __builtins__, in which case it would have the value __builtin__, or it may not exist at all (if the custom namespace also has a custom __builtins__), in which case the class statement will fail. Nevertheless, unless someone finds a better solution, this is a 2.2.1 bugfix too.
author Guido van Rossum <guido@python.org>
date Tue, 15 Jan 2002 21:06:07 +0000
parents 379fc66f4c96
children 86fdf8fe7f17
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 61
diff changeset
1
61
5c4dd9348e81 Added provision for THINK C which doesn't have sys_nerrors or sys_errlist.
Guido van Rossum <guido@python.org>
parents: 6
diff changeset
2 /* PD implementation of strerror() for systems that don't have it.
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 Author: Guido van Rossum, CWI Amsterdam, Oct. 1990, <guido@cwi.nl>. */
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 #include <stdio.h>
21077
379fc66f4c96 Use PyOS_snprintf instead of sprintf.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 14375
diff changeset
6 #include "Python.h"
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
7
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 extern int sys_nerr;
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 extern char *sys_errlist[];
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
10
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 char *
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
12 strerror(int err)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 {
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 static char buf[20];
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 if (err >= 0 && err < sys_nerr)
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 return sys_errlist[err];
21077
379fc66f4c96 Use PyOS_snprintf instead of sprintf.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 14375
diff changeset
17 PyOS_snprintf(buf, sizeof(buf), "Unknown errno %d", err);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 return buf;
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 }
61
5c4dd9348e81 Added provision for THINK C which doesn't have sys_nerrors or sys_errlist.
Guido van Rossum <guido@python.org>
parents: 6
diff changeset
20
1848
b724599401ff Merge back to main trunk
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
21 #ifdef macintosh
61
5c4dd9348e81 Added provision for THINK C which doesn't have sys_nerrors or sys_errlist.
Guido van Rossum <guido@python.org>
parents: 6
diff changeset
22 int sys_nerr = 0;
5c4dd9348e81 Added provision for THINK C which doesn't have sys_nerrors or sys_errlist.
Guido van Rossum <guido@python.org>
parents: 6
diff changeset
23 char *sys_errlist[1] = 0;
5c4dd9348e81 Added provision for THINK C which doesn't have sys_nerrors or sys_errlist.
Guido van Rossum <guido@python.org>
parents: 6
diff changeset
24 #endif