-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Repeatable test case:
[utdrmac@test1 ~]$ python3 -m venv pdctest
[utdrmac@test1 ~]$ cd pdctest/
[utdrmac@test1 pdctest]$ . bin/activate
(pdctest) [utdrmac@test1 pdctest]$
(pdctest) [utdrmac@test1 pdctest]$ python --version
Python 3.13.3
(pdctest) [utdrmac@test1 pdctest]$ pip install python-disk-collections
Collecting python-disk-collections
Using cached python_disk_collections-0.0.6-py2.py3-none-any.whl.metadata (9.2 kB)
Using cached python_disk_collections-0.0.6-py2.py3-none-any.whl (12 kB)
Installing collected packages: python-disk-collections
Successfully installed python-disk-collections-0.0.6
(pdctest) [utdrmac@test1 pdctest]$ cat << EOL > githubexample.py
> from diskcollections.serializers import PickleSerializer
from diskcollections.iterables import List, PersistentDirectoryClient
from functools import partial
dir_abc = partial(PersistentDirectoryClient, "abc")
persistent_list = List(client_class=dir_abc, serializer_class=PickleSerializer)
# All 3 of these append calls fail. Uncomment 1 to check.
persistent_list.append({"a": 1, "b": 2})
#persistent_list.append("Hello")
#persistent_list.append(123456)
print(persistent_list)
> EOL
(pdctest) [utdrmac@test1 pdctest]$ python githubexample.py
Traceback (most recent call last):
File "/Users/utdrmac/pdctest/githubexample.py", line 7, in <module>
persistent_list.append({"a": 1, "b": 2})
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "<frozen _collections_abc>", line 1135, in append
File "/Users/utdrmac/pdctest/lib/python3.13/site-packages/diskcollections/iterables/iterables.py", line 69, in insert
self.__client.insert(index, encoded_value)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "/Users/utdrmac/pdctest/lib/python3.13/site-packages/diskcollections/iterables/clients.py", line 174, in insert
file.write(value)
~~~~~~~~~~^^^^^^^
TypeError: write() argument must be str, not bytes
serializers.py:#L9, pickle.dumps() returns a bytestring.
iterables/clients.py#L82 does not open the file for binary writes, thus failure as above.
By modifying L82 to "w+b", the issue seems to be resolved.
Metadata
Metadata
Assignees
Labels
No labels