File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -171,6 +171,16 @@ def test_unbuffered_input(self):
171171 self .assertEqual (rc , 0 )
172172 self .assert_ (data .startswith (b'x' ), data )
173173
174+ def test_large_PYTHONPATH (self ):
175+ with test .support .EnvironmentVarGuard () as env :
176+ path1 = "ABCDE" * 100
177+ path2 = "FGHIJ" * 100
178+ env ['PYTHONPATH' ] = path1 + os .pathsep + path2
179+ p = _spawn_python ('-S' , '-c' , 'import sys; print(sys.path)' )
180+ stdout , _ = p .communicate ()
181+ self .assert_ (path1 .encode ('ascii' ) in stdout )
182+ self .assert_ (path2 .encode ('ascii' ) in stdout )
183+
174184
175185def test_main ():
176186 test .support .run_unittest (CmdLineTest )
Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ What's New in Python 3.1 Release Candidate 2?
1212Core and Builtins
1313-----------------
1414
15+ - Issue #5924: On Windows, a large PYTHONPATH environment variable
16+ (more than 255 characters) would be completely ignored.
17+
1518- Issue #4547: When debugging a very large function, it was not always
1619 possible to update the lineno attribute of the current frame.
1720
Original file line number Diff line number Diff line change @@ -424,8 +424,6 @@ calculate_path(void)
424424 wchar_t * buf ;
425425 size_t bufsz ;
426426 wchar_t * pythonhome = Py_GetPythonHome ();
427- char * _envpath = Py_GETENV ("PYTHONPATH" );
428- wchar_t wenvpath [MAXPATHLEN + 1 ];
429427 wchar_t * envpath = NULL ;
430428
431429#ifdef MS_WINDOWS
@@ -434,13 +432,20 @@ calculate_path(void)
434432 wchar_t * userpath = NULL ;
435433 wchar_t zip_path [MAXPATHLEN + 1 ];
436434 size_t len ;
437- #endif
435+
436+ if (!Py_IgnoreEnvironmentFlag ) {
437+ envpath = _wgetenv (L"PYTHONPATH" );
438+ }
439+ #else
440+ char * _envpath = Py_GETENV ("PYTHONPATH" );
441+ wchar_t wenvpath [MAXPATHLEN + 1 ];
438442 if (_envpath ) {
439443 size_t r = mbstowcs (wenvpath , _envpath , MAXPATHLEN + 1 );
440444 envpath = wenvpath ;
441445 if (r == (size_t )-1 || r >= MAXPATHLEN )
442446 envpath = NULL ;
443447 }
448+ #endif
444449
445450 get_progpath ();
446451 /* progpath guaranteed \0 terminated in MAXPATH+1 bytes. */
You can’t perform that action at this time.
0 commit comments