@@ -380,64 +380,51 @@ static int
380
380
pymain_run_startup (PyConfig * config , PyCompilerFlags * cf , int * exitcode )
381
381
{
382
382
int ret ;
383
- PyObject * startup_obj = NULL ;
384
383
if (!config -> use_environment ) {
385
384
return 0 ;
386
385
}
386
+ PyObject * startup = NULL ;
387
387
#ifdef MS_WINDOWS
388
- const wchar_t * wstartup = _wgetenv (L"PYTHONSTARTUP" );
389
- if (wstartup == NULL || wstartup [0 ] == L'\0' ) {
388
+ const wchar_t * env = _wgetenv (L"PYTHONSTARTUP" );
389
+ if (env == NULL || env [0 ] == L'\0' ) {
390
390
return 0 ;
391
391
}
392
- PyObject * startup_bytes = NULL ;
393
- startup_obj = PyUnicode_FromWideChar (wstartup , wcslen (wstartup ));
394
- if (startup_obj == NULL ) {
395
- goto error ;
396
- }
397
- startup_bytes = PyUnicode_EncodeFSDefault (startup_obj );
398
- if (startup_bytes == NULL ) {
392
+ startup = PyUnicode_FromWideChar (env , wcslen (env ));
393
+ if (startup == NULL ) {
399
394
goto error ;
400
395
}
401
- const char * startup = PyBytes_AS_STRING (startup_bytes );
402
396
#else
403
- const char * startup = _Py_GetEnv (config -> use_environment , "PYTHONSTARTUP" );
404
- if (startup == NULL ) {
397
+ const char * env = _Py_GetEnv (config -> use_environment , "PYTHONSTARTUP" );
398
+ if (env == NULL ) {
405
399
return 0 ;
406
400
}
407
- startup_obj = PyUnicode_DecodeFSDefault (startup );
408
- if (startup_obj == NULL ) {
401
+ startup = PyUnicode_DecodeFSDefault (env );
402
+ if (startup == NULL ) {
409
403
goto error ;
410
404
}
411
405
#endif
412
- if (PySys_Audit ("cpython.run_startup" , "O" , startup_obj ) < 0 ) {
406
+ if (PySys_Audit ("cpython.run_startup" , "O" , startup ) < 0 ) {
413
407
goto error ;
414
408
}
415
409
416
- #ifdef MS_WINDOWS
417
- FILE * fp = _Py_wfopen (wstartup , L"r" );
418
- #else
419
- FILE * fp = _Py_fopen (startup , "r" );
420
- #endif
410
+ FILE * fp = _Py_fopen_obj (startup , "r" );
421
411
if (fp == NULL ) {
422
412
int save_errno = errno ;
423
413
PyErr_Clear ();
424
414
PySys_WriteStderr ("Could not open PYTHONSTARTUP\n" );
425
415
426
416
errno = save_errno ;
427
- PyErr_SetFromErrnoWithFilenameObjects (PyExc_OSError , startup_obj , NULL );
417
+ PyErr_SetFromErrnoWithFilenameObjects (PyExc_OSError , startup , NULL );
428
418
goto error ;
429
419
}
430
420
431
- (void ) PyRun_SimpleFileExFlags (fp , startup , 0 , cf );
421
+ (void ) _PyRun_SimpleFileObject (fp , startup , 0 , cf );
432
422
PyErr_Clear ();
433
423
fclose (fp );
434
424
ret = 0 ;
435
425
436
426
done :
437
- #ifdef MS_WINDOWS
438
- Py_XDECREF (startup_bytes );
439
- #endif
440
- Py_XDECREF (startup_obj );
427
+ Py_XDECREF (startup );
441
428
return ret ;
442
429
443
430
error :
0 commit comments