Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Changes from all commits
Commits
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
15 changes: 5 additions & 10 deletions 15 msgpack/fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ def newlist_hint(size):
TYPE_BIN = 4
TYPE_EXT = 5

DEFAULT_RECURSE_LIMIT = 511


def _check_type_strict(obj, t, type=type, tuple=tuple):
if type(t) is tuple:
Expand Down Expand Up @@ -682,7 +680,6 @@ def __init__(
def _pack(
self,
obj,
nest_limit=DEFAULT_RECURSE_LIMIT,
check=isinstance,
check_type_strict=_check_type_strict,
):
Expand All @@ -693,8 +690,6 @@ def _pack(
else:
list_types = (list, tuple)
while True:
if nest_limit < 0:
raise ValueError("recursion limit exceeded")
if obj is None:
return self._buffer.write(b"\xc0")
if check(obj, bool):
Expand Down Expand Up @@ -783,10 +778,10 @@ def _pack(
n = len(obj)
self._pack_array_header(n)
for i in range(n):
self._pack(obj[i], nest_limit - 1)
self._pack(obj[i])
return
if check(obj, dict):
return self._pack_map_pairs(len(obj), obj.items(), nest_limit - 1)
return self._pack_map_pairs(len(obj), obj.items())

if self._datetime and check(obj, _DateTime) and obj.tzinfo is not None:
obj = Timestamp.from_datetime(obj)
Expand Down Expand Up @@ -886,11 +881,11 @@ def _pack_map_header(self, n):
return self._buffer.write(struct.pack(">BI", 0xDF, n))
raise ValueError("Dict is too large")

def _pack_map_pairs(self, n, pairs, nest_limit=DEFAULT_RECURSE_LIMIT):
def _pack_map_pairs(self, n, pairs):
self._pack_map_header(n)
for k, v in pairs:
self._pack(k, nest_limit - 1)
self._pack(v, nest_limit - 1)
self._pack(k)
self._pack(v)

def _pack_raw_header(self, n):
if n <= 0x1F:
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.