Message153900
| Author |
pitrou |
| Recipients |
brett.cannon, neologix, pitrou |
| Date |
2012年02月21日.20:37:48 |
| SpamBayes Score |
0.0046325317 |
| Marked as misclassified |
No |
| Message-id |
<1329856669.7.0.228910710943.issue14077@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I am proposing the following patch to have a better unique filename:
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -129,8 +129,8 @@ def _path_absolute(path):
def _write_atomic(path, data):
"""Function to write data to a path atomically."""
- # id() is used to generate a pseudo-random filename.
- path_tmp = '{}.{}'.format(path, id(path))
+ # getpid() and id() are used to generate a pseudo-random filename.
+ path_tmp = '{}.{}-{}'.format(path, _os.getpid(), id(path))
fd = _os.open(path_tmp, _os.O_EXCL | _os.O_CREAT | _os.O_WRONLY, 0o666)
try:
# We first write data to a temporary file, and then use os.replace() to |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年02月21日 20:37:49 | pitrou | set | recipients:
+ pitrou, brett.cannon, neologix |
| 2012年02月21日 20:37:49 | pitrou | set | messageid: <1329856669.7.0.228910710943.issue14077@psf.upfronthosting.co.za> |
| 2012年02月21日 20:37:49 | pitrou | link | issue14077 messages |
| 2012年02月21日 20:37:48 | pitrou | create |
|