Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dc69e72

Browse files
committed
Make test.regrtest.__file__ absolute, this was not always the case when running profile or trace, for example. (issue #9323)
1 parent 1df1536 commit dc69e72

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

Lib/test/regrtest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,13 @@ def getexpected(self):
14581458
return self.expected
14591459

14601460
if __name__ == '__main__':
1461-
# Simplification for findtestdir().
1461+
# findtestdir() gets the dirname out of __file__, so we have to make it
1462+
# absolute before changing the working directory.
1463+
# For example __file__ may be relative when running trace or profile.
1464+
# See issue #9323.
1465+
__file__ = os.path.abspath(__file__)
1466+
1467+
# sanity check
14621468
assert __file__ == os.path.abspath(sys.argv[0])
14631469

14641470
# When tests are run from the Python build directory, it is best practice

Misc/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ Tools/Demos
142142
as wide (UCS4) unicode builds for both the host interpreter (embedded
143143
inside gdb) and the interpreter under test.
144144

145+
Tests
146+
-----
147+
148+
- Issue #9323: Make test.regrtest.__file__ absolute, this was not always the
149+
case when running profile or trace, for example.
150+
145151
Build
146152
-----
147153

0 commit comments

Comments
 (0)