@@ -369,36 +369,33 @@ def test_realpath_relative(self):
369369 "Missing symlink implementation" )
370370 @skip_if_ABSTFN_contains_backslash
371371 def test_realpath_symlink_loops (self ):
372- # Bug #930024, return the path unchanged if we get into an infinite
373- # symlink loop.
372+ # Bug #43757, raise OSError if we get into an infinite symlink loop.
374373 try :
375374 os .symlink (ABSTFN , ABSTFN )
376- self .assertEqual ( realpath ( ABSTFN ) , ABSTFN )
375+ self .assertRaises ( OSError , realpath , ABSTFN )
377376
378377 os .symlink (ABSTFN + "1" , ABSTFN + "2" )
379378 os .symlink (ABSTFN + "2" , ABSTFN + "1" )
380- self .assertEqual ( realpath ( ABSTFN + "1" ) , ABSTFN + "1" )
381- self .assertEqual ( realpath ( ABSTFN + "2" ) , ABSTFN + "2" )
379+ self .assertRaises ( OSError , realpath , ABSTFN + "1" )
380+ self .assertRaises ( OSError , realpath , ABSTFN + "2" )
382381
383- self .assertEqual ( realpath ( ABSTFN + "1/x" ) , ABSTFN + "1/x" )
384- self .assertEqual ( realpath ( ABSTFN + "1/.." ), dirname ( ABSTFN ) )
385- self .assertEqual ( realpath ( ABSTFN + "1/../x" ), dirname ( ABSTFN ) + " /x" )
382+ self .assertRaises ( OSError , realpath , ABSTFN + "1/x" )
383+ self .assertRaises ( OSError , realpath , ABSTFN + "1/.." )
384+ self .assertRaises ( OSError , realpath , ABSTFN + "1/../x" )
386385 os .symlink (ABSTFN + "x" , ABSTFN + "y" )
387- self .assertEqual (realpath (ABSTFN + "1/../" + basename (ABSTFN ) + "y" ),
388- ABSTFN + "y" )
389- self .assertEqual (realpath (ABSTFN + "1/../" + basename (ABSTFN ) + "1" ),
390- ABSTFN + "1" )
386+ self .assertRaises (OSError , realpath , ABSTFN + "1/../" + basename (ABSTFN ) + "y" )
387+ self .assertRaises (OSError , realpath , ABSTFN + "1/../" + basename (ABSTFN ) + "1" )
391388
392389 os .symlink (basename (ABSTFN ) + "a/b" , ABSTFN + "a" )
393- self .assertEqual ( realpath ( ABSTFN + "a" ) , ABSTFN + "a/b " )
390+ self .assertRaises ( OSError , realpath , ABSTFN + "a" )
394391
395392 os .symlink ("../" + basename (dirname (ABSTFN )) + "/" +
396393 basename (ABSTFN ) + "c" , ABSTFN + "c" )
397- self .assertEqual ( realpath ( ABSTFN + "c" ) , ABSTFN + "c" )
394+ self .assertRaises ( OSError , realpath , ABSTFN + "c" )
398395
399396 # Test using relative path as well.
400397 with os_helper .change_cwd (dirname (ABSTFN )):
401- self .assertEqual ( realpath ( basename (ABSTFN )), ABSTFN )
398+ self .assertRaises ( OSError , realpath , basename (ABSTFN ))
402399 finally :
403400 os_helper .unlink (ABSTFN )
404401 os_helper .unlink (ABSTFN + "1" )
0 commit comments