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
76b47655
Commit
76b47655
authored
Aug 19, 2014
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #15696: Add a __sizeof__ implementation for mmap objects on Windows.
parent
d6ec309c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
1 deletion
+28
-1
Lib/test/test_mmap.py
Lib/test/test_mmap.py
+10
-1
Misc/NEWS
Misc/NEWS
+2
-0
Modules/mmapmodule.c
Modules/mmapmodule.c
+16
-0
No files found.
Lib/test/test_mmap.py
View file @
76b47655
from
test.support
import
(
TESTFN
,
run_unittest
,
import_module
,
unlink
,
from
test.support
import
(
TESTFN
,
run_unittest
,
import_module
,
unlink
,
requires
,
_2G
,
_4G
,
gc_collect
)
requires
,
_2G
,
_4G
,
gc_collect
,
cpython_only
)
import
unittest
import
unittest
import
os
import
os
import
re
import
re
...
@@ -639,6 +639,15 @@ class MmapTests(unittest.TestCase):
...
@@ -639,6 +639,15 @@ class MmapTests(unittest.TestCase):
m2
.
close
()
m2
.
close
()
m1
.
close
()
m1
.
close
()
@
cpython_only
@
unittest
.
skipUnless
(
os
.
name
==
'nt'
,
'requires Windows'
)
def
test_sizeof
(
self
):
m1
=
mmap
.
mmap
(
-
1
,
100
)
tagname
=
"foo"
m2
=
mmap
.
mmap
(
-
1
,
100
,
tagname
=
tagname
)
self
.
assertEqual
(
sys
.
getsize
(
m2
),
sys
.
getsize
(
m1
)
+
len
(
tagname
)
+
1
)
@
unittest
.
skipUnless
(
os
.
name
==
'nt'
,
'requires Windows'
)
@
unittest
.
skipUnless
(
os
.
name
==
'nt'
,
'requires Windows'
)
def
test_crasher_on_windows
(
self
):
def
test_crasher_on_windows
(
self
):
# Should not crash (Issue 1733986)
# Should not crash (Issue 1733986)
...
...
Misc/NEWS
View file @
76b47655
...
@@ -27,6 +27,8 @@ Core and Builtins
...
@@ -27,6 +27,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #15696: Add a __sizeof__ implementation for mmap objects on Windows.
- Issue #22068: Avoided reference loops with Variables and Fonts in Tkinter.
- Issue #22068: Avoided reference loops with Variables and Fonts in Tkinter.
- Issue #22165: SimpleHTTPRequestHandler now supports undecodable file names.
- Issue #22165: SimpleHTTPRequestHandler now supports undecodable file names.
...
...
Modules/mmapmodule.c
View file @
76b47655
...
@@ -709,6 +709,19 @@ mmap__exit__method(PyObject *self, PyObject *args)
...
@@ -709,6 +709,19 @@ mmap__exit__method(PyObject *self, PyObject *args)
return
_PyObject_CallMethodId
(
self
,
&
PyId_close
,
NULL
);
return
_PyObject_CallMethodId
(
self
,
&
PyId_close
,
NULL
);
}
}
#ifdef MS_WINDOWS
static
PyObject
*
mmap__sizeof__method
(
mmap_object
*
self
,
void
*
unused
)
{
Py_ssize_t
res
;
res
=
sizeof
(
mmap_object
);
if
(
self
->
tagname
)
res
+=
strlen
(
self
->
tagname
)
+
1
;
return
PyLong_FromSsize_t
(
res
);
}
#endif
static
struct
PyMethodDef
mmap_object_methods
[]
=
{
static
struct
PyMethodDef
mmap_object_methods
[]
=
{
{
"close"
,
(
PyCFunction
)
mmap_close_method
,
METH_NOARGS
},
{
"close"
,
(
PyCFunction
)
mmap_close_method
,
METH_NOARGS
},
{
"find"
,
(
PyCFunction
)
mmap_find_method
,
METH_VARARGS
},
{
"find"
,
(
PyCFunction
)
mmap_find_method
,
METH_VARARGS
},
...
@@ -726,6 +739,9 @@ static struct PyMethodDef mmap_object_methods[] = {
...
@@ -726,6 +739,9 @@ static struct PyMethodDef mmap_object_methods[] = {
{
"write_byte"
,
(
PyCFunction
)
mmap_write_byte_method
,
METH_VARARGS
},
{
"write_byte"
,
(
PyCFunction
)
mmap_write_byte_method
,
METH_VARARGS
},
{
"__enter__"
,
(
PyCFunction
)
mmap__enter__method
,
METH_NOARGS
},
{
"__enter__"
,
(
PyCFunction
)
mmap__enter__method
,
METH_NOARGS
},
{
"__exit__"
,
(
PyCFunction
)
mmap__exit__method
,
METH_VARARGS
},
{
"__exit__"
,
(
PyCFunction
)
mmap__exit__method
,
METH_VARARGS
},
#ifdef MS_WINDOWS
{
"__sizeof__"
,
(
PyCFunction
)
mmap__sizeof__method
,
METH_NOARGS
},
#endif
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
...
...
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