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
631fdee6
Commit
631fdee6
authored
Aug 29, 2017
by
Oren Milman
Committed by
Serhiy Storchaka
Aug 29, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-31291: Fixed an assertion failure in zipimport.zipimporter.get_data() (#3226)
if pathname.replace('/', '\\') returns non-string.
parent
006617ff
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
1 deletion
+22
-1
Lib/test/test_zipimport.py
Lib/test/test_zipimport.py
+17
-0
Misc/NEWS.d/next/Core and Builtins/2017-08-28-11-51-29.bpo-31291.t8QggK.rst
...ore and Builtins/2017-08-28-11-51-29.bpo-31291.t8QggK.rst
+3
-0
Modules/zipimport.c
Modules/zipimport.c
+2
-1
No files found.
Lib/test/test_zipimport.py
View file @
631fdee6
...
...
@@ -521,6 +521,23 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
z
.
close
()
os
.
remove
(
TEMP_ZIP
)
def
test_issue31291
(
self
):
# There shouldn't be an assertion failure in get_data().
class
FunnyStr
(
str
):
def
replace
(
self
,
old
,
new
):
return
42
z
=
ZipFile
(
TEMP_ZIP
,
"w"
)
try
:
name
=
"test31291.dat"
data
=
b'foo'
z
.
writestr
(
name
,
data
)
z
.
close
()
zi
=
zipimport
.
zipimporter
(
TEMP_ZIP
)
self
.
assertEqual
(
data
,
zi
.
get_data
(
FunnyStr
(
name
)))
finally
:
z
.
close
()
os
.
remove
(
TEMP_ZIP
)
def
testImporterAttr
(
self
):
src
=
"""if 1: # indent hack
def get_file():
...
...
Misc/NEWS.d/next/Core and Builtins/2017-08-28-11-51-29.bpo-31291.t8QggK.rst
0 → 100644
View file @
631fdee6
Fix an assertion failure in `zipimport.zipimporter.get_data` on Windows,
when the return value of ``pathname.replace('/','\\')`` isn't a string.
Patch by Oren Milman.
Modules/zipimport.c
View file @
631fdee6
...
...
@@ -651,7 +651,8 @@ zipimport_zipimporter_get_data_impl(ZipImporter *self, PyObject *path)
Py_ssize_t
path_start
,
path_len
,
len
;
#ifdef ALTSEP
path
=
_PyObject_CallMethodId
(
path
,
&
PyId_replace
,
"CC"
,
ALTSEP
,
SEP
);
path
=
_PyObject_CallMethodId
((
PyObject
*
)
&
PyUnicode_Type
,
&
PyId_replace
,
"OCC"
,
path
,
ALTSEP
,
SEP
);
if
(
!
path
)
return
NULL
;
#else
...
...
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