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

Skip to content

Commit 22952a3

Browse files
committed
SF bug 735293: Command line timeit.py sets sys.path badly
Paul Moore's patch to have timeit.py check the current directory for imports (instead of the directory for Lib/timeit.py).
1 parent 235d1ef commit 22952a3

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

Lib/timeit.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ def main(args=None):
236236
print __doc__,
237237
return 0
238238
setup = "\n".join(setup) or "pass"
239+
# Include the current directory, so that local imports work (sys.path
240+
# contains the directory of this script, rather than the current
241+
# directory)
242+
import os
243+
sys.path.insert(0, os.curdir)
239244
t = Timer(stmt, setup, timer)
240245
if number == 0:
241246
# determine number so that 0.2 <= total time < 2.0

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ Trent Mick
370370
Roman Milner
371371
Dom Mitchell
372372
Doug Moen
373+
Paul Moore
373374
The Dragon De Monsyne
374375
Skip Montanaro
375376
James A Morrison

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ Library
5858
- Fixed socket speed loss caused by use of the _socketobject wrapper class
5959
in socket.py.
6060

61+
- timeit.py now checks the current directory for imports.
62+
6163
Tools/Demos
6264
-----------
6365

0 commit comments

Comments
 (0)