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
3d79dd9e
Commit
3d79dd9e
authored
Jul 12, 2007
by
Thomas Heller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
c_char_p.from_param accepts bytes. Fix test_parameters.
parent
7a76e8f6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
Lib/ctypes/test/test_parameters.py
Lib/ctypes/test/test_parameters.py
+3
-3
Modules/_ctypes/_ctypes.c
Modules/_ctypes/_ctypes.c
+1
-1
No files found.
Lib/ctypes/test/test_parameters.py
View file @
3d79dd9e
...
@@ -54,11 +54,11 @@ class SimpleTypesTestCase(unittest.TestCase):
...
@@ -54,11 +54,11 @@ class SimpleTypesTestCase(unittest.TestCase):
# c_char_p.from_param on a Python String packs the string
# c_char_p.from_param on a Python String packs the string
# into a cparam object
# into a cparam object
s
=
"123"
s
=
b
"123"
self
.
failUnless
(
c_char_p
.
from_param
(
s
).
_obj
is
s
)
self
.
failUnless
(
c_char_p
.
from_param
(
s
).
_obj
is
s
)
# new in 0.9.1: convert (encode) unicode to ascii
# new in 0.9.1: convert (encode) unicode to ascii
self
.
failUnlessEqual
(
c_char_p
.
from_param
(
"123"
).
_obj
,
"123"
)
self
.
failUnlessEqual
(
c_char_p
.
from_param
(
"123"
).
_obj
,
b
"123"
)
self
.
assertRaises
(
UnicodeEncodeError
,
c_char_p
.
from_param
,
"123
\
377
"
)
self
.
assertRaises
(
UnicodeEncodeError
,
c_char_p
.
from_param
,
"123
\
377
"
)
self
.
assertRaises
(
TypeError
,
c_char_p
.
from_param
,
42
)
self
.
assertRaises
(
TypeError
,
c_char_p
.
from_param
,
42
)
...
@@ -82,7 +82,7 @@ class SimpleTypesTestCase(unittest.TestCase):
...
@@ -82,7 +82,7 @@ class SimpleTypesTestCase(unittest.TestCase):
# new in 0.9.1: convert (decode) ascii to unicode
# new in 0.9.1: convert (decode) ascii to unicode
self
.
failUnlessEqual
(
c_wchar_p
.
from_param
(
"123"
).
_obj
,
"123"
)
self
.
failUnlessEqual
(
c_wchar_p
.
from_param
(
"123"
).
_obj
,
"123"
)
self
.
assertRaises
(
UnicodeDecodeError
,
c_wchar_p
.
from_param
,
"123
\
377
"
)
self
.
assertRaises
(
UnicodeDecodeError
,
c_wchar_p
.
from_param
,
b
"123
\
377
"
)
pa
=
c_wchar_p
.
from_param
(
c_wchar_p
(
"123"
))
pa
=
c_wchar_p
.
from_param
(
c_wchar_p
(
"123"
))
self
.
failUnlessEqual
(
type
(
pa
),
c_wchar_p
)
self
.
failUnlessEqual
(
type
(
pa
),
c_wchar_p
)
...
...
Modules/_ctypes/_ctypes.c
View file @
3d79dd9e
...
@@ -1183,7 +1183,7 @@ c_char_p_from_param(PyObject *type, PyObject *value)
...
@@ -1183,7 +1183,7 @@ c_char_p_from_param(PyObject *type, PyObject *value)
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
Py_None
;
return
Py_None
;
}
}
if
(
Py
String
_Check
(
value
)
||
PyUnicode_Check
(
value
))
{
if
(
Py
Bytes
_Check
(
value
)
||
PyUnicode_Check
(
value
))
{
PyCArgObject
*
parg
;
PyCArgObject
*
parg
;
struct
fielddesc
*
fd
=
getentry
(
"z"
);
struct
fielddesc
*
fd
=
getentry
(
"z"
);
...
...
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