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
17f05bbc
Commit
17f05bbc
authored
Jan 17, 2019
by
Timo Furrer
Committed by
Berker Peksag
Jan 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-33687: Fix call to os.chmod() in uu.decode() (GH-7282)
parent
f1d8e7cf
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
4 deletions
+22
-4
Lib/test/test_uu.py
Lib/test/test_uu.py
+19
-0
Lib/uu.py
Lib/uu.py
+1
-4
Misc/NEWS.d/next/Library/2018-06-10-14-08-52.bpo-33687.1zZdnA.rst
...S.d/next/Library/2018-06-10-14-08-52.bpo-33687.1zZdnA.rst
+2
-0
No files found.
Lib/test/test_uu.py
View file @
17f05bbc
...
@@ -6,6 +6,8 @@ Nick Mathewson
...
@@ -6,6 +6,8 @@ Nick Mathewson
import
unittest
import
unittest
from
test
import
support
from
test
import
support
import
os
import
stat
import
sys
import
sys
import
uu
import
uu
import
io
import
io
...
@@ -218,6 +220,23 @@ class UUFileTest(unittest.TestCase):
...
@@ -218,6 +220,23 @@ class UUFileTest(unittest.TestCase):
with
open
(
self
.
tmpin
,
'rb'
)
as
f
:
with
open
(
self
.
tmpin
,
'rb'
)
as
f
:
self
.
assertRaises
(
uu
.
Error
,
uu
.
decode
,
f
)
self
.
assertRaises
(
uu
.
Error
,
uu
.
decode
,
f
)
def
test_decode_mode
(
self
):
# Verify that decode() will set the given mode for the out_file
expected_mode
=
0o444
with
open
(
self
.
tmpin
,
'wb'
)
as
f
:
f
.
write
(
encodedtextwrapped
(
expected_mode
,
self
.
tmpout
))
# make file writable again, so it can be removed (Windows only)
self
.
addCleanup
(
os
.
chmod
,
self
.
tmpout
,
expected_mode
|
stat
.
S_IWRITE
)
with
open
(
self
.
tmpin
,
'rb'
)
as
f
:
uu
.
decode
(
f
)
self
.
assertEqual
(
stat
.
S_IMODE
(
os
.
stat
(
self
.
tmpout
).
st_mode
),
expected_mode
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
unittest
.
main
()
unittest
.
main
()
Lib/uu.py
View file @
17f05bbc
...
@@ -133,10 +133,7 @@ def decode(in_file, out_file=None, mode=None, quiet=False):
...
@@ -133,10 +133,7 @@ def decode(in_file, out_file=None, mode=None, quiet=False):
out_file
=
sys
.
stdout
.
buffer
out_file
=
sys
.
stdout
.
buffer
elif
isinstance
(
out_file
,
str
):
elif
isinstance
(
out_file
,
str
):
fp
=
open
(
out_file
,
'wb'
)
fp
=
open
(
out_file
,
'wb'
)
try
:
os
.
chmod
(
out_file
,
mode
)
os
.
path
.
chmod
(
out_file
,
mode
)
except
AttributeError
:
pass
out_file
=
fp
out_file
=
fp
opened_files
.
append
(
out_file
)
opened_files
.
append
(
out_file
)
#
#
...
...
Misc/NEWS.d/next/Library/2018-06-10-14-08-52.bpo-33687.1zZdnA.rst
0 → 100644
View file @
17f05bbc
Fix the call to ``os.chmod()`` for ``uu.decode()`` if a mode is given or
decoded. Patch by Timo Furrer.
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