Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f7c6d86

Browse files
author
Thomas Heller
committed
Use a unicode string as unique_key instead of 8-bit string.
1 parent a188466 commit f7c6d86

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

Lib/ctypes/test/test_objects.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
2323
>>> array[4] = 'foo bar'
2424
>>> array._objects
25-
{s'4': b'foo bar'}
25+
{'4': b'foo bar'}
2626
>>> array[4]
2727
s'foo bar'
2828
>>>
@@ -47,9 +47,9 @@
4747
4848
>>> x.array[0] = 'spam spam spam'
4949
>>> x._objects
50-
{s'0:2': b'spam spam spam'}
50+
{'0:2': b'spam spam spam'}
5151
>>> x.array._b_base_._objects
52-
{s'0:2': b'spam spam spam'}
52+
{'0:2': b'spam spam spam'}
5353
>>>
5454
5555
'''

Modules/_ctypes/_ctypes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,7 @@ unique_key(CDataObject *target, Py_ssize_t index)
20272027
#endif
20282028
target = target->b_base;
20292029
}
2030-
return PyString_FromStringAndSize(string, cp-string);
2030+
return PyUnicode_FromStringAndSize(string, cp-string);
20312031
}
20322032

20332033
/*

0 commit comments

Comments
 (0)