Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6db1c40b
Commit
6db1c40b
authored
Feb 22, 2012
by
Charles-François Natali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #14077: importlib: Fix regression introduced by de6703671386.
parent
e887f313
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
Lib/importlib/_bootstrap.py
Lib/importlib/_bootstrap.py
+6
-3
No files found.
Lib/importlib/_bootstrap.py
View file @
6db1c40b
...
@@ -128,7 +128,9 @@ def _path_absolute(path):
...
@@ -128,7 +128,9 @@ def _path_absolute(path):
def
_write_atomic
(
path
,
data
):
def
_write_atomic
(
path
,
data
):
"""Function to write data to a path atomically."""
"""Best-effort function to write data to a path atomically.
Be prepared to handle a FileExistsError if concurrent writing of the
temporary file is attempted."""
# id() is used to generate a pseudo-random filename.
# id() is used to generate a pseudo-random filename.
path_tmp
=
'{}.{}'
.
format
(
path
,
id
(
path
))
path_tmp
=
'{}.{}'
.
format
(
path
,
id
(
path
))
fd
=
_os
.
open
(
path_tmp
,
_os
.
O_EXCL
|
_os
.
O_CREAT
|
_os
.
O_WRONLY
,
0o666
)
fd
=
_os
.
open
(
path_tmp
,
_os
.
O_EXCL
|
_os
.
O_CREAT
|
_os
.
O_WRONLY
,
0o666
)
...
@@ -595,8 +597,9 @@ class _SourceFileLoader(_FileLoader, SourceLoader):
...
@@ -595,8 +597,9 @@ class _SourceFileLoader(_FileLoader, SourceLoader):
return
return
try
:
try
:
_write_atomic
(
path
,
data
)
_write_atomic
(
path
,
data
)
except
PermissionError
:
except
(
PermissionError
,
FileExistsError
):
# Don't worry if you can't write bytecode.
# Don't worry if you can't write bytecode or someone is writing
# it at the same time.
pass
pass
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment