@@ -223,7 +223,7 @@ pymain_import_readline(const PyConfig *config)
223
223
224
224
225
225
static int
226
- pymain_run_command (wchar_t * command , PyCompilerFlags * cf )
226
+ pymain_run_command (wchar_t * command )
227
227
{
228
228
PyObject * unicode , * bytes ;
229
229
int ret ;
@@ -243,7 +243,9 @@ pymain_run_command(wchar_t *command, PyCompilerFlags *cf)
243
243
goto error ;
244
244
}
245
245
246
- ret = PyRun_SimpleStringFlags (PyBytes_AsString (bytes ), cf );
246
+ PyCompilerFlags cf = _PyCompilerFlags_INIT ;
247
+ cf .cf_flags |= PyCF_IGNORE_COOKIE ;
248
+ ret = PyRun_SimpleStringFlags (PyBytes_AsString (bytes ), & cf );
247
249
Py_DECREF (bytes );
248
250
return (ret != 0 );
249
251
@@ -306,7 +308,7 @@ pymain_run_module(const wchar_t *modname, int set_argv0)
306
308
307
309
static int
308
310
pymain_run_file_obj (PyObject * program_name , PyObject * filename ,
309
- int skip_source_first_line , PyCompilerFlags * cf )
311
+ int skip_source_first_line )
310
312
{
311
313
if (PySys_Audit ("cpython.run_file" , "O" , filename ) < 0 ) {
312
314
return pymain_exit_err_print ();
@@ -347,12 +349,13 @@ pymain_run_file_obj(PyObject *program_name, PyObject *filename,
347
349
}
348
350
349
351
/* PyRun_AnyFileExFlags(closeit=1) calls fclose(fp) before running code */
350
- int run = _PyRun_AnyFileObject (fp , filename , 1 , cf );
352
+ PyCompilerFlags cf = _PyCompilerFlags_INIT ;
353
+ int run = _PyRun_AnyFileObject (fp , filename , 1 , & cf );
351
354
return (run != 0 );
352
355
}
353
356
354
357
static int
355
- pymain_run_file (const PyConfig * config , PyCompilerFlags * cf )
358
+ pymain_run_file (const PyConfig * config )
356
359
{
357
360
PyObject * filename = PyUnicode_FromWideChar (config -> run_filename , -1 );
358
361
if (filename == NULL ) {
@@ -367,15 +370,15 @@ pymain_run_file(const PyConfig *config, PyCompilerFlags *cf)
367
370
}
368
371
369
372
int res = pymain_run_file_obj (program_name , filename ,
370
- config -> skip_source_first_line , cf );
373
+ config -> skip_source_first_line );
371
374
Py_DECREF (filename );
372
375
Py_DECREF (program_name );
373
376
return res ;
374
377
}
375
378
376
379
377
380
static int
378
- pymain_run_startup (PyConfig * config , PyCompilerFlags * cf , int * exitcode )
381
+ pymain_run_startup (PyConfig * config , int * exitcode )
379
382
{
380
383
int ret ;
381
384
if (!config -> use_environment ) {
@@ -416,7 +419,8 @@ pymain_run_startup(PyConfig *config, PyCompilerFlags *cf, int *exitcode)
416
419
goto error ;
417
420
}
418
421
419
- (void ) _PyRun_SimpleFileObject (fp , startup , 0 , cf );
422
+ PyCompilerFlags cf = _PyCompilerFlags_INIT ;
423
+ (void ) _PyRun_SimpleFileObject (fp , startup , 0 , & cf );
420
424
PyErr_Clear ();
421
425
fclose (fp );
422
426
ret = 0 ;
@@ -469,14 +473,14 @@ pymain_run_interactive_hook(int *exitcode)
469
473
470
474
471
475
static int
472
- pymain_run_stdin (PyConfig * config , PyCompilerFlags * cf )
476
+ pymain_run_stdin (PyConfig * config )
473
477
{
474
478
if (stdin_is_interactive (config )) {
475
479
config -> inspect = 0 ;
476
480
Py_InspectFlag = 0 ; /* do exit on SystemExit */
477
481
478
482
int exitcode ;
479
- if (pymain_run_startup (config , cf , & exitcode )) {
483
+ if (pymain_run_startup (config , & exitcode )) {
480
484
return exitcode ;
481
485
}
482
486
@@ -494,13 +498,14 @@ pymain_run_stdin(PyConfig *config, PyCompilerFlags *cf)
494
498
return pymain_exit_err_print ();
495
499
}
496
500
497
- int run = PyRun_AnyFileExFlags (stdin , "<stdin>" , 0 , cf );
501
+ PyCompilerFlags cf = _PyCompilerFlags_INIT ;
502
+ int run = PyRun_AnyFileExFlags (stdin , "<stdin>" , 0 , & cf );
498
503
return (run != 0 );
499
504
}
500
505
501
506
502
507
static void
503
- pymain_repl (PyConfig * config , PyCompilerFlags * cf , int * exitcode )
508
+ pymain_repl (PyConfig * config , int * exitcode )
504
509
{
505
510
/* Check this environment variable at the end, to give programs the
506
511
opportunity to set it from Python. */
@@ -519,7 +524,8 @@ pymain_repl(PyConfig *config, PyCompilerFlags *cf, int *exitcode)
519
524
return ;
520
525
}
521
526
522
- int res = PyRun_AnyFileFlags (stdin , "<stdin>" , cf );
527
+ PyCompilerFlags cf = _PyCompilerFlags_INIT ;
528
+ int res = PyRun_AnyFileFlags (stdin , "<stdin>" , & cf );
523
529
* exitcode = (res != 0 );
524
530
}
525
531
@@ -565,13 +571,11 @@ pymain_run_python(int *exitcode)
565
571
}
566
572
}
567
573
568
- PyCompilerFlags cf = _PyCompilerFlags_INIT ;
569
-
570
574
pymain_header (config );
571
575
pymain_import_readline (config );
572
576
573
577
if (config -> run_command ) {
574
- * exitcode = pymain_run_command (config -> run_command , & cf );
578
+ * exitcode = pymain_run_command (config -> run_command );
575
579
}
576
580
else if (config -> run_module ) {
577
581
* exitcode = pymain_run_module (config -> run_module , 1 );
@@ -580,13 +584,13 @@ pymain_run_python(int *exitcode)
580
584
* exitcode = pymain_run_module (L"__main__" , 0 );
581
585
}
582
586
else if (config -> run_filename != NULL ) {
583
- * exitcode = pymain_run_file (config , & cf );
587
+ * exitcode = pymain_run_file (config );
584
588
}
585
589
else {
586
- * exitcode = pymain_run_stdin (config , & cf );
590
+ * exitcode = pymain_run_stdin (config );
587
591
}
588
592
589
- pymain_repl (config , & cf , exitcode );
593
+ pymain_repl (config , exitcode );
590
594
goto done ;
591
595
592
596
error :
0 commit comments