Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
999d92d
Import order
julien-lang Jul 16, 2025
9777db0
Remove __future__ imports
julien-lang Jul 16, 2025
e3e72cd
Cleanup super prototype
julien-lang Jul 16, 2025
2e3b54b
six.iter....
julien-lang Jul 16, 2025
64fa354
Remove calls to six.text_type and six.binary_type
julien-lang Jul 16, 2025
d014745
Remove calls to ensure_bytes, ensure_text, ensure_strings
julien-lang Jul 16, 2025
153f179
test fixed
eduardoChaucaGallegos Jul 17, 2025
2de2822
fixup! test fixed
julien-lang Jul 17, 2025
24835e3
Black
julien-lang Jul 17, 2025
60bb0bc
Update shotgun_api3/shotgun.py
julien-lang Jul 17, 2025
473b811
six.moves imports
julien-lang Jul 16, 2025
f68f1ae
Cleanup BytesIO import from six
julien-lang Jul 16, 2025
0b956cc
simple json
julien-lang Jul 16, 2025
b94da1a
Cleanup Py2-3 compat with ImportError
julien-lang Jul 16, 2025
6e89b98
Simplify Base64
julien-lang Jul 16, 2025
439d0b3
fixup! six.moves imports
julien-lang Jul 17, 2025
adbc0da
fixup! six.moves imports
julien-lang Jul 17, 2025
c4d1e30
Remove deprecated custome mimetype module
julien-lang Jul 16, 2025
e93ed1e
Remove deprecated backported mock module
julien-lang Jul 16, 2025
12f1abe
Fixup assert_called_once
julien-lang Jul 17, 2025
ea953d2
Fixup CI tests
julien-lang Jul 17, 2025
f45faac
fixup! Fixup CI tests
julien-lang Jul 17, 2025
6a2b3e2
provides debug info
julien-lang Jul 17, 2025
cb800c1
fixup! provides debug info
julien-lang Jul 17, 2025
a4afffa
fixup! Remove deprecated backported mock module
julien-lang Jul 17, 2025
77c9cd3
Remove python2 from httplib2 module
julien-lang Jul 16, 2025
6124681
fixup issue with ssl_error_classes
julien-lang Jul 17, 2025
10119ec
Cleanup six.PY2/six.PY3 conditions
julien-lang Jul 16, 2025
c9648c1
Remove useless test in Python 3
julien-lang Jul 16, 2025
e7ca1eb
Replace sgsix.file_types by io.IOBase
julien-lang Jul 16, 2025
3cbc5ff
Replace ShotgunSSLError by ssl.SSLError
julien-lang Jul 16, 2025
5d8b18d
Cleanup Python-2 related comments and workarounds
julien-lang Jul 17, 2025
b90a64b
fixup! Cleanup six.PY2/six.PY3 conditions
julien-lang Jul 17, 2025
f6275cd
Remove deprecated ensure_ascii parameter from SG object
julien-lang Jul 16, 2025
5c4dc5b
fixup! Remove deprecated ensure_ascii parameter from SG object
julien-lang Jul 17, 2025
c321734
Test CI
julien-lang Jul 17, 2025
1f370fe
fixup! Test CI
julien-lang Jul 17, 2025
2eb8306
fixup! fixup! Test CI
julien-lang Jul 17, 2025
1463852
fixup! fixup! fixup! Test CI
julien-lang Jul 17, 2025
da922f9
fixup! fixup! fixup! fixup! Test CI
julien-lang Jul 17, 2025
ffdd11f
pulling from master and conflicts fixed
eduardoChaucaGallegos Sep 10, 2025
9cdef72
test fixed because conflict
eduardoChaucaGallegos Sep 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion shotgun_api3/lib/mockgun/mockgun.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ def __init__(self,
api_key=None,
convert_datetimes_to_utc=True,
http_proxy=None,
ensure_ascii=True,
connect=True,
ca_certs=None,
login=None,
Expand Down
33 changes: 0 additions & 33 deletions shotgun_api3/shotgun.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ def __init__(
api_key=None,
convert_datetimes_to_utc=True,
http_proxy=None,
ensure_ascii=True,
connect=True,
ca_certs=None,
login=None,
Expand Down Expand Up @@ -709,9 +708,6 @@ def __init__(
{self.config.scheme: proxy_addr}
)

if ensure_ascii:
self._json_loads = self._json_loads_ascii

self.client_caps = ClientCapabilities()
# this relies on self.client_caps being set first
self.reset_user_agent()
Expand Down Expand Up @@ -3981,35 +3977,6 @@ def _decode_response(self, headers, body):
def _json_loads(self, body):
return json.loads(body)

def _json_loads_ascii(self, body):
"""
See http://stackoverflow.com/questions/956867
"""

def _decode_list(lst):
newlist = []
for i in lst:
if isinstance(i, str):
i = sgutils.ensure_str(i)
elif isinstance(i, list):
i = _decode_list(i)
newlist.append(i)
return newlist

def _decode_dict(dct):
newdict = {}
for k, v in dct.items():
if isinstance(k, str):
k = sgutils.ensure_str(k)
if isinstance(v, str):
v = sgutils.ensure_str(v)
elif isinstance(v, list):
v = _decode_list(v)
newdict[k] = v
return newdict

return json.loads(body, object_hook=_decode_dict)

def _response_errors(self, sg_response):
"""
Raise any API errors specified in the response.
Expand Down
42 changes: 14 additions & 28 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import uuid
import warnings

from shotgun_api3.lib import six
from shotgun_api3.lib.httplib2 import Http

import shotgun_api3
Expand Down Expand Up @@ -828,28 +827,24 @@ def test_summary_values(self):
sorted(result["groups"], key=lambda x: x["group_name"]), groups
)

def test_ensure_ascii(self):
"""test_ensure_ascii tests ensure_unicode flag."""
sg_ascii = shotgun_api3.Shotgun(
self.config.server_url, ensure_ascii=True, **self.auth_args
)
def test_json_dumps_default_ensure_ascii_disabled(self):
"""Make sure SG'payload is using ensure_ascii for json dumps"""
sg = shotgun_api3.Shotgun(self.config.server_url, **self.auth_args)

result = sg_ascii.find_one(
"Note", [["id", "is", self.note["id"]]], fields=["content"]
)
if six.PY2:
# In Python3 there isn't a separate unicode type.
self.assertFalse(_has_unicode(result))
# Mock the _http_request method
sg._orig_http_request = sg._http_request
sg._http_request = unittest.mock.Mock(wraps=sg._orig_http_request)

def test_ensure_unicode(self):
"""test_ensure_unicode tests ensure_unicode flag."""
sg_unicode = shotgun_api3.Shotgun(
self.config.server_url, ensure_ascii=False, **self.auth_args
sg.find_one(
"Note",
[["content", "is", "Noëlご"]], # Force a non-ascii character
)
result = sg_unicode.find_one(
"Note", [["id", "is", self.note["id"]]], fields=["content"]

sg._http_request.assert_called_once()
self.assertIn(
b"No\xc3\xabl\xe3\x81\x94", # utf-8 encoded version of Noëlご
sg._http_request.call_args.args[2], # Get the body of the request
)
self.assertTrue(_has_unicode(result))

def test_work_schedule(self):
"""test_work_schedule tests WorkDayRules api"""
Expand Down Expand Up @@ -3409,15 +3404,6 @@ def test_import_httplib(self):
self.assertTrue(hasattr(socks, "HTTPError"))


def _has_unicode(data):
for k, v in data.items():
if isinstance(k, str):
return True
if isinstance(v, str):
return True
return False


def _get_path(url):
"""Returns path component of a url without the sheme, host, query, anchor, or any other
additional elements.
Expand Down
1 change: 0 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,6 @@ def _assert_decode_resonse(self, ensure_ascii, data):
self.config.script_name,
self.config.api_key,
http_proxy=self.config.http_proxy,
ensure_ascii=ensure_ascii,
connect=False,
)

Expand Down