Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResourceStringsAsyncUpload.upload seems broken in SDK 3.5.0 #117

Open
mkarolin opened this issue May 28, 2024 · 0 comments
Open

ResourceStringsAsyncUpload.upload seems broken in SDK 3.5.0 #117

mkarolin opened this issue May 28, 2024 · 0 comments

Comments

@mkarolin
Copy link

With Python 3.10, Transifex Python SDK 2.1.0 this works as expected:

transifex_api.ResourceStringsAsyncUpload.upload(resource, content)

However, after upgrading to Python 3.12.3, Transifex Python SDK 3.5.0 the same code that worked with SDK 2.1.0 produces the following error:

  ...
  File "C:\transifex\api_v3_wrapper.py", line 127, in __upload_resource_content
    transifex_api.ResourceStringsAsyncUpload.upload(resource, content)
  File "C:\<reducted>\AppData\Roaming\Python\Python312\site-packages\transifex\api\__init__.py", line 48, in upload
    upload = cls.create_with_form(data=data, files={"content": content})
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\<reducted>\AppData\Roaming\Python\Python312\site-packages\transifex\api\jsonapi\resources.py", line 539, in create_with_form
    response_body = cls.API.request("post", cls.get_collection_url(), **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\<reducted>\AppData\Roaming\Python\Python312\site-packages\transifex\api\jsonapi\apis.py", line 184, in request
    response = requests.request(
               ^^^^^^^^^^^^^^^^^
  File "C:\<reducted>\AppData\Roaming\Python\Python312\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\<reducted>\AppData\Roaming\Python\Python312\site-packages\requests\sessions.py", line 575, in request
    prep = self.prepare_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\<reducted>\AppData\Roaming\Python\Python312\site-packages\requests\sessions.py", line 484, in prepare_request
    p.prepare(
  File "C:\<reducted>\AppData\Roaming\Python\Python312\site-packages\requests\models.py", line 370, in prepare
    self.prepare_body(data, files, json)
  File "C:\<reducted>\AppData\Roaming\Python\Python312\site-packages\requests\models.py", line 555, in prepare_body
    (body, content_type) = self._encode_files(files, data)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\<reducted>\AppData\Roaming\Python\Python312\site-packages\requests\models.py", line 201, in _encode_files
    body, content_type = encode_multipart_formdata(new_fields)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\<reducted>\AppData\Roaming\Python\Python312\site-packages\urllib3\filepost.py", line 81, in encode_multipart_formdata
    body.write(data)
TypeError: a bytes-like object is required, not 'Resource'

Packages:

Package            Version
------------------ ---------
asttokens          2.4.1
certifi            2024.2.2
charset-normalizer 3.3.2
click              8.1.7
colorama           0.4.6
future             1.0.0
idna               3.7
lxml               5.2.2
parsimonious       0.10.0
pip                24.0
pyseeyou           1.0.2
regex              2024.5.15
requests           2.32.2
six                1.16.0
toolz              0.12.1
transifex-python   3.5.0
urllib3            2.2.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant