Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitb128a06

Browse files
committed
Reorder result tuple of parse_code_object
The standard followed by APIs like pstat.Stats is to take a file, line,function triplet. The parse_code_object function (and callers exposingthis in Python like RemoteUnwinder.get_stack_trace) return function,file, line triplets which requires the caller to reorder these whenusing it in classes like pstat.Stats.
1 parentd963436 commitb128a06

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

‎Lib/test/test_external_inspection.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,17 @@ def foo():
114114
p.wait(timeout=SHORT_TIMEOUT)
115115

116116
thread_expected_stack_trace= [
117-
("foo",script_name,15),
118-
("baz",script_name,12),
119-
("bar",script_name,9),
120-
('Thread.run',threading.__file__,ANY)
117+
(script_name,15,"foo"),
118+
(script_name,12,"baz"),
119+
(script_name,9,"bar"),
120+
(threading.__file__,ANY,'Thread.run')
121121
]
122122
# Is possible that there are more threads, so we check that the
123123
# expected stack traces are in the result (looking at you Windows!)
124124
self.assertIn((ANY,thread_expected_stack_trace),stack_trace)
125125

126126
# Check that the main thread stack trace is in the result
127-
frame= ("<module>",script_name,19)
127+
frame= (script_name,19,"<module>")
128128
for_,stackinstack_trace:
129129
ifframeinstack:
130130
break
@@ -222,70 +222,70 @@ def new_eager_loop():
222222
root_task="Task-1"
223223
expected_stack_trace= [
224224
[
225-
("c5",script_name,10),
226-
("c4",script_name,14),
227-
("c3",script_name,17),
228-
("c2",script_name,20),
225+
(script_name,10,"c5"),
226+
(script_name,14,"c4"),
227+
(script_name,17,"c3"),
228+
(script_name,20,"c2"),
229229
],
230230
"c2_root",
231231
[
232232
[
233233
[
234234
(
235-
"TaskGroup._aexit",
236235
taskgroups.__file__,
237236
ANY,
237+
"TaskGroup._aexit"
238238
),
239239
(
240-
"TaskGroup.__aexit__",
241240
taskgroups.__file__,
242241
ANY,
242+
"TaskGroup.__aexit__"
243243
),
244-
("main",script_name,26),
244+
(script_name,26,"main"),
245245
],
246246
"Task-1",
247247
[],
248248
],
249249
[
250-
[("c1",script_name,23)],
250+
[(script_name,23,"c1")],
251251
"sub_main_1",
252252
[
253253
[
254254
[
255255
(
256-
"TaskGroup._aexit",
257256
taskgroups.__file__,
258257
ANY,
258+
"TaskGroup._aexit"
259259
),
260260
(
261-
"TaskGroup.__aexit__",
262261
taskgroups.__file__,
263262
ANY,
263+
"TaskGroup.__aexit__"
264264
),
265-
("main",script_name,26),
265+
(script_name,26,"main"),
266266
],
267267
"Task-1",
268268
[],
269269
]
270270
],
271271
],
272272
[
273-
[("c1",script_name,23)],
273+
[(script_name,23,"c1")],
274274
"sub_main_2",
275275
[
276276
[
277277
[
278278
(
279-
"TaskGroup._aexit",
280279
taskgroups.__file__,
281280
ANY,
281+
"TaskGroup._aexit"
282282
),
283283
(
284-
"TaskGroup.__aexit__",
285284
taskgroups.__file__,
286285
ANY,
286+
"TaskGroup.__aexit__"
287287
),
288-
("main",script_name,26),
288+
(script_name,26,"main"),
289289
],
290290
"Task-1",
291291
[],
@@ -363,9 +363,9 @@ async def main():
363363

364364
expected_stack_trace= [
365365
[
366-
("gen_nested_call",script_name,10),
367-
("gen",script_name,16),
368-
("main",script_name,19),
366+
(script_name,10,"gen_nested_call"),
367+
(script_name,16,"gen"),
368+
(script_name,19,"main"),
369369
],
370370
"Task-1",
371371
[],
@@ -439,9 +439,9 @@ async def main():
439439
stack_trace[2].sort(key=lambdax:x[1])
440440

441441
expected_stack_trace= [
442-
[("deep",script_name,11), ("c1",script_name,15)],
442+
[(script_name,11,"deep"), (script_name,15,"c1")],
443443
"Task-2",
444-
[[[("main",script_name,21)],"Task-1", []]],
444+
[[[(script_name,21,"main")],"Task-1", []]],
445445
]
446446
self.assertEqual(stack_trace,expected_stack_trace)
447447

@@ -515,8 +515,8 @@ async def main():
515515
stack_trace[2].sort(key=lambdax:x[1])
516516
expected_stack_trace= [
517517
[
518-
("deep",script_name,11),
519-
("c1",script_name,15),
518+
(script_name,11,"deep"),
519+
(script_name,15,"c1"),
520520
("staggered_race.<locals>.run_one_coro",staggered.__file__,ANY),
521521
],
522522
"Task-2",
@@ -662,16 +662,16 @@ async def main():
662662
self.assertIn((ANY,"Task-1", []),entries)
663663
main_stack= [
664664
(
665-
"TaskGroup._aexit",
666665
taskgroups.__file__,
667666
ANY,
667+
"TaskGroup._aexit",
668668
),
669669
(
670-
"TaskGroup.__aexit__",
671670
taskgroups.__file__,
672671
ANY,
672+
"TaskGroup.__aexit__",
673673
),
674-
("main",script_name,60),
674+
(script_name,60,"main"),
675675
]
676676
self.assertIn(
677677
(ANY,"server task", [[main_stack,ANY]]),
@@ -686,16 +686,16 @@ async def main():
686686
[
687687
[
688688
(
689-
"TaskGroup._aexit",
690689
taskgroups.__file__,
691690
ANY,
691+
"TaskGroup._aexit",
692692
),
693693
(
694-
"TaskGroup.__aexit__",
695694
taskgroups.__file__,
696695
ANY,
696+
"TaskGroup.__aexit__",
697697
),
698-
("echo_client_spam",script_name,41),
698+
(script_name,41,"echo_client_spam"),
699699
],
700700
ANY,
701701
]
@@ -741,14 +741,14 @@ def test_self_trace(self):
741741
stack[:2],
742742
[
743743
(
744-
"get_stack_trace",
745744
__file__,
746745
get_stack_trace.__code__.co_firstlineno+2,
746+
"get_stack_trace",
747747
),
748748
(
749-
"TestGetStackTrace.test_self_trace",
750749
__file__,
751750
self.test_self_trace.__code__.co_firstlineno+6,
751+
"TestGetStackTrace.test_self_trace",
752752
),
753753
]
754754
)

‎Modules/_remote_debugging_module.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,9 +1562,9 @@ parse_code_object(RemoteUnwinderObject *unwinder,
15621562

15631563
Py_INCREF(meta->func_name);
15641564
Py_INCREF(meta->file_name);
1565-
PyTuple_SET_ITEM(tuple,0,meta->func_name);
1566-
PyTuple_SET_ITEM(tuple,1,meta->file_name);
1567-
PyTuple_SET_ITEM(tuple,2,lineno);
1565+
PyTuple_SET_ITEM(tuple,0,meta->file_name);
1566+
PyTuple_SET_ITEM(tuple,1,lineno);
1567+
PyTuple_SET_ITEM(tuple,2,meta->func_name);
15681568

15691569
*result=tuple;
15701570
return0;
@@ -2921,4 +2921,4 @@ PyMODINIT_FUNC
29212921
PyInit__remote_debugging(void)
29222922
{
29232923
returnPyModuleDef_Init(&remote_debugging_module);
2924-
}
2924+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp