Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 286191 | Differences between
and this patch

Collapse All | Expand All

(-)file_not_specified_in_diff (-5 / +34 lines)
Line  Link Here
0
-- Modules/main.c
0
++ Modules/main.c
Lines 452-458 Link Here
452
			filename = argv[_PyOS_optind];
452
			filename = argv[_PyOS_optind];
453
453
454
#else
454
#else
455
		filename = argv[_PyOS_optind];
455
		filename = strdup(argv[_PyOS_optind]);
456
		char *new_script_name = getenv("PYTHON_SCRIPT_NAME");
457
		if (new_script_name != NULL) {
458
			size_t old_script_name_length = strlen(argv[_PyOS_optind]);
459
			size_t new_script_name_length = strlen(new_script_name);
460
			size_t i;
461
			for (i = 0; i < old_script_name_length; i++) {
462
				if (i <= new_script_name_length)
463
					argv[_PyOS_optind][i] = new_script_name[i];
464
				else
465
					argv[_PyOS_optind][i] = '\0';
466
			}
467
		}
456
#endif
468
#endif
457
	}
469
	}
458
470
459
-- Modules/python.c
471
++ Modules/python.c
Lines 6-11 Link Here
6
#include <floatingpoint.h>
6
#include <floatingpoint.h>
7
#endif
7
#endif
8
8
9
#ifdef __linux__
10
#include <linux/prctl.h>
11
#include <sys/prctl.h>
12
#endif
13
9
int
14
int
10
main(int argc, char **argv)
15
main(int argc, char **argv)
11
{
16
{
Lines 20-24 Link Here
20
	m = fpgetmask();
25
	m = fpgetmask();
21
	fpsetmask(m & ~FP_X_OFL);
26
	fpsetmask(m & ~FP_X_OFL);
22
#endif
27
#endif
28
29
#ifdef __linux__
30
	char *process_name = getenv("PYTHON_PROCESS_NAME");
31
	if (process_name)
32
		prctl(PR_SET_NAME, process_name);
33
#endif
34
23
	return Py_Main(argc, argv);
35
	return Py_Main(argc, argv);
24
}
36
}
25
-- Python/sysmodule.c
37
++ Python/sysmodule.c
Lines 1490-1495 Link Here
1490
makeargvobject(int argc, char **argv)
1490
makeargvobject(int argc, char **argv)
1491
{
1491
{
1492
	PyObject *av;
1492
	PyObject *av;
1493
	char *script_name = getenv("PYTHON_SCRIPT_NAME");
1493
	if (argc <= 0 || argv == NULL) {
1494
	if (argc <= 0 || argv == NULL) {
1494
		/* Ensure at least one (empty) argument is seen */
1495
		/* Ensure at least one (empty) argument is seen */
1495
		static char *empty_argv[1] = {""};
1496
		static char *empty_argv[1] = {""};
Lines 1514-1520 Link Here
1514
			} else
1515
			} else
1515
				v = PyString_FromString(argv[i]);
1516
				v = PyString_FromString(argv[i]);
1516
#else
1517
#else
1517
			PyObject *v = PyString_FromString(argv[i]);
1518
			PyObject *v;
1519
			if (i == 0 && script_name != NULL)
1520
				v = PyString_FromString(script_name);
1521
			else
1522
				v = PyString_FromString(argv[i]);
1518
#endif
1523
#endif
1519
			if (v == NULL) {
1524
			if (v == NULL) {
1520
				Py_DECREF(av);
1525
				Py_DECREF(av);

Return to bug 286191