~ubuntu-branches/ubuntu/precise/python3.2/precise-proposed

« back to all changes in this revision

Viewing changes to Modules/main.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-03-09 18:40:39 UTC
  • mfrom: (30.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20120309184039-j3yk2emxr1plyo21
Tags: 3.2.3~rc1-1
* Python 3.2.3 release candidate 1.
* Update to 20120309 from the 3.2 branch.
* Fix libpython.a symlink. Closes: #660146.
* Build-depend on xauth.
* Run the gdb tests for the debug build only.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
static int  orig_argc;
47
47
 
48
48
/* command line options */
49
 
#define BASE_OPTS L"bBc:dEhiJm:OqsStuvVW:xX:?"
 
49
#define BASE_OPTS L"bBc:dEhiJm:OqRsStuvVW:xX:?"
50
50
 
51
51
#define PROGRAM_OPTS BASE_OPTS
52
52
 
72
72
-O     : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n\
73
73
-OO    : remove doc-strings in addition to the -O optimizations\n\
74
74
-q     : don't print version and copyright messages on interactive startup\n\
 
75
-R     : use a pseudo-random salt to make hash() values of various types be\n\
 
76
         unpredictable between separate invocations of the interpreter, as\n\
 
77
         a defence against denial-of-service attacks\n\
75
78
-s     : don't add user site directory to sys.path; also PYTHONNOUSERSITE\n\
76
79
-S     : don't imply 'import site' on initialization\n\
77
80
";
99
102
"PYTHONHOME   : alternate <prefix> directory (or <prefix>%c<exec_prefix>).\n"
100
103
"               The default module search path uses %s.\n"
101
104
"PYTHONCASEOK : ignore case in 'import' statements (Windows).\n"
102
 
"PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n"
103
 
;
 
105
"PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n\
 
106
";
 
107
static char *usage_6 = "\
 
108
PYTHONHASHSEED: if this variable is set to 'random', the effect is the same\n\
 
109
   as specifying the -R option: a random value is used to seed the hashes of\n\
 
110
   str, bytes and datetime objects.  It can also be set to an integer\n\
 
111
   in the range [0,4294967295] to get hash values with a predictable seed.\n\
 
112
";
104
113
 
105
114
static int
106
115
usage(int exitcode, wchar_t* program)
116
125
        fputs(usage_3, f);
117
126
        fprintf(f, usage_4, DELIM);
118
127
        fprintf(f, usage_5, DELIM, PYTHONHOMEHELP);
 
128
        fputs(usage_6, f);
119
129
    }
120
130
#if defined(__VMS)
121
131
    if (exitcode == 0) {
327
337
    orig_argc = argc;           /* For Py_GetArgcArgv() */
328
338
    orig_argv = argv;
329
339
 
 
340
    /* Hash randomization needed early for all string operations
 
341
       (including -W and -X options). */
 
342
    while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) {
 
343
        if (c == 'm' || c == 'c') {
 
344
            /* -c / -m is the last option: following arguments are
 
345
               not interpreter options. */
 
346
            break;
 
347
        }
 
348
        switch (c) {
 
349
        case 'E':
 
350
            Py_IgnoreEnvironmentFlag++;
 
351
            break;
 
352
        case 'R':
 
353
            Py_HashRandomizationFlag++;
 
354
            break;
 
355
        }
 
356
    }
 
357
    /* The variable is only tested for existence here; _PyRandom_Init will
 
358
       check its value further. */
 
359
    if (!Py_HashRandomizationFlag &&
 
360
        (p = Py_GETENV("PYTHONHASHSEED")) && *p != '\0')
 
361
        Py_HashRandomizationFlag = 1;
 
362
 
 
363
    _PyRandom_Init();
 
364
 
330
365
    PySys_ResetWarnOptions();
 
366
    _PyOS_ResetGetOpt();
331
367
 
332
368
    while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) {
333
369
        if (c == 'c') {
388
424
            break;
389
425
 
390
426
        case 'E':
391
 
            Py_IgnoreEnvironmentFlag++;
 
427
            /* Already handled above */
392
428
            break;
393
429
 
394
430
        case 't':
429
465
            Py_QuietFlag++;
430
466
            break;
431
467
 
 
468
        case 'R':
 
469
            /* Already handled above */
 
470
            break;
 
471
 
432
472
        /* This space reserved for other options */
433
473
 
434
474
        default:
654
694
            if (fp == NULL) {
655
695
                char *cfilename_buffer;
656
696
                const char *cfilename;
 
697
                int err = errno;
657
698
                cfilename_buffer = _Py_wchar2char(filename, NULL);
658
699
                if (cfilename_buffer != NULL)
659
700
                    cfilename = cfilename_buffer;
660
701
                else
661
702
                    cfilename = "<unprintable file name>";
662
703
                fprintf(stderr, "%ls: can't open file '%s': [Errno %d] %s\n",
663
 
                    argv[0], cfilename, errno, strerror(errno));
 
704
                    argv[0], cfilename, err, strerror(err));
664
705
                if (cfilename_buffer)
665
706
                    PyMem_Free(cfilename_buffer);
666
707
                return 2;