MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _r_object

Method _r_object

tools/python-3.11.9-amd64/Tools/scripts/umarshal.py:181–301  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

179 self.level = old_level
180
181 def _r_object(self) -> Any:
182 code = self.r_byte()
183 flag = code & FLAG_REF
184 type = code & ~FLAG_REF
185 # print(" "*self.level + f"{code} {flag} {type} {chr(type)!r}")
186 self.level += 1
187
188 def R_REF(obj: Any) -> Any:
189 if flag:
190 obj = self.r_ref(obj, flag)
191 return obj
192
193 if type == Type.NULL:
194 return NULL
195 elif type == Type.NONE:
196 return None
197 elif type == Type.ELLIPSIS:
198 return Ellipsis
199 elif type == Type.FALSE:
200 return False
201 elif type == Type.TRUE:
202 return True
203 elif type == Type.INT:
204 return R_REF(self.r_long())
205 elif type == Type.INT64:
206 return R_REF(self.r_long64())
207 elif type == Type.LONG:
208 return R_REF(self.r_PyLong())
209 elif type == Type.FLOAT:
210 return R_REF(self.r_float_str())
211 elif type == Type.BINARY_FLOAT:
212 return R_REF(self.r_float_bin())
213 elif type == Type.COMPLEX:
214 return R_REF(complex(self.r_float_str(),
215 self.r_float_str()))
216 elif type == Type.BINARY_COMPLEX:
217 return R_REF(complex(self.r_float_bin(),
218 self.r_float_bin()))
219 elif type == Type.STRING:
220 n = self.r_long()
221 return R_REF(self.r_string(n))
222 elif type == Type.ASCII_INTERNED or type == Type.ASCII:
223 n = self.r_long()
224 return R_REF(self.r_string(n).decode("ascii"))
225 elif type == Type.SHORT_ASCII_INTERNED or type == Type.SHORT_ASCII:
226 n = self.r_byte()
227 return R_REF(self.r_string(n).decode("ascii"))
228 elif type == Type.INTERNED or type == Type.UNICODE:
229 n = self.r_long()
230 return R_REF(self.r_string(n).decode("utf8", "surrogatepass"))
231 elif type == Type.SMALL_TUPLE:
232 n = self.r_byte()
233 idx = self.r_ref_reserve(flag)
234 retval: Any = tuple(self.r_object() for _ in range(n))
235 self.r_ref_insert(retval, idx, flag)
236 return retval
237 elif type == Type.TUPLE:
238 n = self.r_long()

Callers 1

r_objectMethod · 0.95

Calls 15

r_byteMethod · 0.95
r_longMethod · 0.95
r_long64Method · 0.95
r_PyLongMethod · 0.95
r_float_strMethod · 0.95
r_float_binMethod · 0.95
r_stringMethod · 0.95
r_ref_reserveMethod · 0.95
r_objectMethod · 0.95
r_ref_insertMethod · 0.95
tupleClass · 0.85
CodeClass · 0.85

Tested by

no test coverage detected