File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -360,27 +360,27 @@ setpythonargv(argc, argv)
360360 char * * argv ;
361361{
362362 object * av = makeargvobject (argc , argv );
363+ object * path = sysget ("path" );
363364 if (av == NULL )
364365 fatal ("no mem for sys.argv" );
365366 if (sysset ("argv" , av ) != 0 )
366367 fatal ("can't assign sys.argv" );
367- if (argc > 0 ) {
368- object * path = sysget ("path" );
369- if (path != NULL ) {
370- char * p = strrchr (argv [0 ], SEP );
371- int n ;
372- object * a ;
373- if (p == NULL )
374- n = 0 ;
375- else
376- n = p + 1 - argv [0 ];
377- a = newsizedstringobject (argv [0 ], n );
378- if (a == NULL )
379- fatal ("no mem for sys.path insertion" );
380- if (inslistitem (path , 0 , a ) < 0 )
381- fatal ("sys.path.insert(0) failed" );
382- DECREF (a );
383- }
368+ if (path != NULL ) {
369+ char * p = NULL ;
370+ int n ;
371+ object * a ;
372+ if (argc > 0 && argv [0 ] != NULL )
373+ p = strrchr (argv [0 ], SEP );
374+ if (p == NULL )
375+ n = 0 ;
376+ else
377+ n = p + 1 - argv [0 ];
378+ a = newsizedstringobject (argv [0 ], n );
379+ if (a == NULL )
380+ fatal ("no mem for sys.path insertion" );
381+ if (inslistitem (path , 0 , a ) < 0 )
382+ fatal ("sys.path.insert(0) failed" );
383+ DECREF (a );
384384 }
385385 DECREF (av );
386386}
You can’t perform that action at this time.
0 commit comments