Regression in add_attachment(), fails on bytes object
bvle opened this issue · 0 comments
bvle commented
Bug summary
When a bytes
object is passed as the attachment argument to add_attachment()
it raises an AttributeError. This was not the case before #1366 (first seen in v3.3.0).
Is there an existing issue for this?
- I have searched the existing issues
Jira Instance type
Jira Server or Data Center (Self-hosted)
Jira instance version
v8.9.0#809000-sha1:4ceb90a
jira-python version
3.5.2
Python Interpreter version
Python 3.11.4 (main, Jun 9 2023, 07:59:55) [GCC 12.3.0] on linux
Which operating systems have you used?
- Linux
- macOS
- Windows
Reproduction steps
from jira import JIRA
jira = JIRA(basic_auth=("admin", "admin"))
jira.add_attachment(
issue="QQ-1",
attachment=b"example content",
filename="example.txt",
)
print("ok")
Stack trace
Traceback (most recent call last):
File "/home/bvl/dev/scratch/./test_regression_1366.py", line 4, in <module>
jira.add_attachment(
File "/home/bvl/dev/scratch/venv/lib/python3.11/site-packages/jira/client.py", line 123, in wrapper
result = func(*arg_list, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bvl/dev/scratch/venv/lib/python3.11/site-packages/jira/client.py", line 1032, in add_attachment
encoded_data, request_headers = generate_multipartencoded_request_args()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bvl/dev/scratch/venv/lib/python3.11/site-packages/jira/client.py", line 1009, in generate_multipartencoded_request_args
attachment_io.seek(0)
^^^^^^^^^^^^^^^^^^
AttributeError: 'bytes' object has no attribute 'seek'
Expected behaviour
The attachment will be present on the issue, with the given content and filename.
$ python ./test_regression_1366.py
ok
Additional Context
Related #1521