Skip to content

Commit a31fffe

Browse files
committed
got namedtuples working again
1 parent 3c24cb4 commit a31fffe

File tree

6 files changed

+126
-11011
lines changed

6 files changed

+126
-11011
lines changed

v3/example-code/closures/closure1.golden

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,13 @@
250250
}
251251
],
252252
"globals": {
253-
"foo": [
254-
"REF",
255-
1
256-
],
257253
"b": [
258254
"REF",
259255
2
256+
],
257+
"foo": [
258+
"REF",
259+
1
260260
]
261261
},
262262
"heap": {
@@ -326,13 +326,13 @@
326326
}
327327
],
328328
"globals": {
329-
"foo": [
330-
"REF",
331-
1
332-
],
333329
"b": [
334330
"REF",
335331
2
332+
],
333+
"foo": [
334+
"REF",
335+
1
336336
]
337337
},
338338
"heap": {
@@ -402,13 +402,13 @@
402402
}
403403
],
404404
"globals": {
405-
"foo": [
406-
"REF",
407-
1
408-
],
409405
"b": [
410406
"REF",
411407
2
408+
],
409+
"foo": [
410+
"REF",
411+
1
412412
]
413413
},
414414
"heap": {
@@ -480,13 +480,13 @@
480480
}
481481
],
482482
"globals": {
483-
"foo": [
484-
"REF",
485-
1
486-
],
487483
"b": [
488484
"REF",
489485
2
486+
],
487+
"foo": [
488+
"REF",
489+
1
490490
]
491491
},
492492
"heap": {

v3/example-code/py_tutorial.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4661,7 +4661,7 @@
46614661
4
46624662
],
46634663
"middleName": "Birchard",
4664-
"s2": "Rutherford Birchard Hayes",
4664+
"lastName": "Hayes",
46654665
"age": 26,
46664666
"orderedUniqueAges": [
46674667
"REF",
@@ -4678,7 +4678,7 @@
46784678
"person": "Tom Cruise",
46794679
"s": "Rutherford Birchard Hayes",
46804680
"b": "Ringo",
4681-
"lastName": "Hayes",
4681+
"s2": "Rutherford Birchard Hayes",
46824682
"thisAge": 28,
46834683
"pi": 3.142,
46844684
"worth": 40000000

v3/pg_logger.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def mouse_input_wrapper(prompt=''):
206206
BANNED_BUILTINS.append('input')
207207

208208

209-
IGNORE_VARS = set(('__user_stdout__', '__builtins__', '__name__', '__exception__', '__doc__', '__package__'))
209+
IGNORE_VARS = set(('__user_stdout__', '__OPT_toplevel__', '__builtins__', '__name__', '__exception__', '__doc__', '__package__'))
210210

211211
def get_user_stdout(frame):
212212
return frame.f_globals['__user_stdout__'].getvalue()
@@ -557,6 +557,12 @@ def interaction(self, frame, traceback, event_type):
557557
if top_frame.f_code.co_name == '__repr__':
558558
return
559559

560+
# if top_frame.f_globals doesn't contain the sentinel '__OPT_toplevel__',
561+
# then we're in another global scope altogether, so skip it!
562+
# (this comes up in tests/backend-tests/namedtuple.txt)
563+
if '__OPT_toplevel__' not in top_frame.f_globals:
564+
return
565+
560566

561567
# OLD CODE -- bail if any element on the stack matches these conditions
562568
# note that the old code passes tests/backend-tests/namedtuple.txt
@@ -1047,7 +1053,9 @@ def _runscript(self, script_str, custom_globals=None):
10471053

10481054
user_globals = {"__name__" : "__main__",
10491055
"__builtins__" : user_builtins,
1050-
"__user_stdout__" : user_stdout}
1056+
"__user_stdout__" : user_stdout,
1057+
# sentinel value for frames deriving from a top-level module
1058+
"__OPT_toplevel__": True}
10511059

10521060
if custom_globals:
10531061
user_globals.update(custom_globals)

0 commit comments

Comments
 (0)