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
4bc45b7a
Commit
4bc45b7a
authored
Nov 25, 2011
by
Meador Inge
Browse files
Options
Browse Files
Download
Plain Diff
Issue #13380: add an internal function for resetting the ctypes caches
parents
4d098735
11e38131
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
9 deletions
+25
-9
Lib/ctypes/__init__.py
Lib/ctypes/__init__.py
+16
-9
Lib/ctypes/test/test_as_parameter.py
Lib/ctypes/test/test_as_parameter.py
+1
-0
Lib/ctypes/test/test_functions.py
Lib/ctypes/test/test_functions.py
+1
-0
Lib/test/regrtest.py
Lib/test/regrtest.py
+7
-0
No files found.
Lib/ctypes/__init__.py
View file @
4bc45b7a
...
...
@@ -265,7 +265,21 @@ class c_wchar_p(_SimpleCData):
class
c_wchar
(
_SimpleCData
):
_type_
=
"u"
POINTER
(
c_wchar
).
from_param
=
c_wchar_p
.
from_param
#_SimpleCData.c_wchar_p_from_param
def
_reset_cache
():
_pointer_type_cache
.
clear
()
_c_functype_cache
.
clear
()
if
_os
.
name
in
(
"nt"
,
"ce"
):
_win_functype_cache
.
clear
()
# _SimpleCData.c_wchar_p_from_param
POINTER
(
c_wchar
).
from_param
=
c_wchar_p
.
from_param
# _SimpleCData.c_char_p_from_param
POINTER
(
c_char
).
from_param
=
c_char_p
.
from_param
_pointer_type_cache
[
None
]
=
c_void_p
# XXX for whatever reasons, creating the first instance of a callback
# function is needed for the unittests on Win64 to succeed. This MAY
# be a compiler bug, since the problem occurs only when _ctypes is
# compiled with the MS SDK compiler. Or an uninitialized variable?
CFUNCTYPE
(
c_int
)(
lambda
:
None
)
def
create_unicode_buffer
(
init
,
size
=
None
):
"""create_unicode_buffer(aString) -> character array
...
...
@@ -285,7 +299,6 @@ def create_unicode_buffer(init, size=None):
return
buf
raise
TypeError
(
init
)
POINTER
(
c_char
).
from_param
=
c_char_p
.
from_param
#_SimpleCData.c_char_p_from_param
# XXX Deprecated
def
SetPointerType
(
pointer
,
cls
):
...
...
@@ -445,8 +458,6 @@ if _os.name in ("nt", "ce"):
descr
=
FormatError
(
code
).
strip
()
return
WindowsError
(
code
,
descr
)
_pointer_type_cache
[
None
]
=
c_void_p
if
sizeof
(
c_uint
)
==
sizeof
(
c_void_p
):
c_size_t
=
c_uint
c_ssize_t
=
c_int
...
...
@@ -529,8 +540,4 @@ for kind in [c_ushort, c_uint, c_ulong, c_ulonglong]:
elif
sizeof
(
kind
)
==
8
:
c_uint64
=
kind
del
(
kind
)
# XXX for whatever reasons, creating the first instance of a callback
# function is needed for the unittests on Win64 to succeed. This MAY
# be a compiler bug, since the problem occurs only when _ctypes is
# compiled with the MS SDK compiler. Or an uninitialized variable?
CFUNCTYPE
(
c_int
)(
lambda
:
None
)
_reset_cache
()
Lib/ctypes/test/test_as_parameter.py
View file @
4bc45b7a
...
...
@@ -74,6 +74,7 @@ class BasicWrapTestCase(unittest.TestCase):
def
test_callbacks
(
self
):
f
=
dll
.
_testfunc_callback_i_if
f
.
restype
=
c_int
f
.
argtypes
=
None
MyCallback
=
CFUNCTYPE
(
c_int
,
c_int
)
...
...
Lib/ctypes/test/test_functions.py
View file @
4bc45b7a
...
...
@@ -250,6 +250,7 @@ class FunctionTestCase(unittest.TestCase):
def
test_callbacks
(
self
):
f
=
dll
.
_testfunc_callback_i_if
f
.
restype
=
c_int
f
.
argtypes
=
None
MyCallback
=
CFUNCTYPE
(
c_int
,
c_int
)
...
...
Lib/test/regrtest.py
View file @
4bc45b7a
...
...
@@ -1401,6 +1401,13 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
filecmp._cache.clear()
struct._clearcache()
doctest.master = None
try:
import ctypes
except ImportError:
# Don't worry about resetting the cache if ctypes is not supported
pass
else:
ctypes._reset_cache()
# Collect cyclic trash.
gc.collect()
...
...
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