Skip to content

Commit 6eae578

Browse files
committed
started cleaning up cruft from pg_logger.py
1 parent 765c69c commit 6eae578

2 files changed

Lines changed: 35 additions & 55 deletions

File tree

v3/example-code/for-else.golden_py3

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,13 +1350,13 @@
13501350
"globals": {
13511351
"x_range": [
13521352
"REF",
1353-
3
1353+
2
13541354
],
13551355
"x": 2,
13561356
"n": 9
13571357
},
13581358
"heap": {
1359-
"3": [
1359+
"2": [
13601360
"INSTANCE_PPRINT",
13611361
"range",
13621362
"range(2, 9)"
@@ -1377,13 +1377,13 @@
13771377
"globals": {
13781378
"x_range": [
13791379
"REF",
1380-
3
1380+
2
13811381
],
13821382
"x": 2,
13831383
"n": 9
13841384
},
13851385
"heap": {
1386-
"3": [
1386+
"2": [
13871387
"INSTANCE_PPRINT",
13881388
"range",
13891389
"range(2, 9)"
@@ -1404,13 +1404,13 @@
14041404
"globals": {
14051405
"x_range": [
14061406
"REF",
1407-
3
1407+
2
14081408
],
14091409
"x": 2,
14101410
"n": 9
14111411
},
14121412
"heap": {
1413-
"3": [
1413+
"2": [
14141414
"INSTANCE_PPRINT",
14151415
"range",
14161416
"range(2, 9)"
@@ -1431,13 +1431,13 @@
14311431
"globals": {
14321432
"x_range": [
14331433
"REF",
1434-
3
1434+
2
14351435
],
14361436
"x": 3,
14371437
"n": 9
14381438
},
14391439
"heap": {
1440-
"3": [
1440+
"2": [
14411441
"INSTANCE_PPRINT",
14421442
"range",
14431443
"range(2, 9)"
@@ -1458,13 +1458,13 @@
14581458
"globals": {
14591459
"x_range": [
14601460
"REF",
1461-
3
1461+
2
14621462
],
14631463
"x": 3,
14641464
"n": 9
14651465
},
14661466
"heap": {
1467-
"3": [
1467+
"2": [
14681468
"INSTANCE_PPRINT",
14691469
"range",
14701470
"range(2, 9)"
@@ -1485,13 +1485,13 @@
14851485
"globals": {
14861486
"x_range": [
14871487
"REF",
1488-
3
1488+
2
14891489
],
14901490
"x": 3,
14911491
"n": 9
14921492
},
14931493
"heap": {
1494-
"3": [
1494+
"2": [
14951495
"INSTANCE_PPRINT",
14961496
"range",
14971497
"range(2, 9)"
@@ -1512,13 +1512,13 @@
15121512
"globals": {
15131513
"x_range": [
15141514
"REF",
1515-
3
1515+
2
15161516
],
15171517
"n": 9,
15181518
"x": 3
15191519
},
15201520
"heap": {
1521-
"3": [
1521+
"2": [
15221522
"INSTANCE_PPRINT",
15231523
"range",
15241524
"range(2, 9)"

v5-unity/pg_logger.py

Lines changed: 21 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@
4848
import pg_encoder
4949

5050

51-
# TODO: not threadsafe:
52-
5351
# upper-bound on the number of executed lines, in order to guard against
5452
# infinite loops
5553
#MAX_EXECUTED_LINES = 300
@@ -91,6 +89,7 @@ def write(self, s):
9189

9290
# These could lead to XSS or other code injection attacks, so be careful:
9391
# these are now deprecated as of 2016-06-28
92+
'''
9493
__html__ = None
9594
def setHTML(htmlStr):
9695
global __html__
@@ -105,6 +104,7 @@ def setCSS(cssStr):
105104
def setJS(jsStr):
106105
global __js__
107106
__js__ = jsStr
107+
'''
108108

109109

110110
# ugh, I can't figure out why in Python 2, __builtins__ seems to
@@ -189,11 +189,12 @@ def __restricted_import__(*args):
189189
if args[0] in all_allowed_imports:
190190
imported_mod = BUILTIN_IMPORT(*args)
191191

192-
if args[0] in CUSTOM_MODULE_IMPORTS:
193-
# add special magical functions to custom imported modules
194-
setattr(imported_mod, 'setHTML', setHTML)
195-
setattr(imported_mod, 'setCSS', setCSS)
196-
setattr(imported_mod, 'setJS', setJS)
192+
# these are now deprecated as of 2016-06-28
193+
#if args[0] in CUSTOM_MODULE_IMPORTS:
194+
# # add special magical functions to custom imported modules
195+
# setattr(imported_mod, 'setHTML', setHTML)
196+
# setattr(imported_mod, 'setCSS', setCSS)
197+
# setattr(imported_mod, 'setJS', setJS)
197198

198199
# somewhat weak protection against imported modules that contain one
199200
# of these troublesome builtins. again, NOTHING is foolproof ...
@@ -1265,13 +1266,13 @@ def create_encoded_stack_entry(cur_frame):
12651266

12661267
# TODO: refactor into a non-global
12671268
# these are now deprecated as of 2016-06-28
1268-
global __html__, __css__, __js__
1269-
if __html__:
1270-
trace_entry['html_output'] = __html__
1271-
if __css__:
1272-
trace_entry['css_output'] = __css__
1273-
if __js__:
1274-
trace_entry['js_output'] = __js__
1269+
#global __html__, __css__, __js__
1270+
#if __html__:
1271+
# trace_entry['html_output'] = __html__
1272+
#if __css__:
1273+
# trace_entry['css_output'] = __css__
1274+
#if __js__:
1275+
# trace_entry['js_output'] = __js__
12751276

12761277
# if there's an exception, then record its info:
12771278
if event_type == 'exception':
@@ -1398,13 +1399,6 @@ def _runscript(self, script_str):
13981399

13991400
user_builtins['mouse_input'] = mouse_input_wrapper
14001401

1401-
# TODO: we can disable these imports here, but a crafty user can
1402-
# always get a hold of them by importing one of the external
1403-
# modules, so there's no point in trying security by obscurity
1404-
user_builtins['setHTML'] = setHTML
1405-
user_builtins['setCSS'] = setCSS
1406-
user_builtins['setJS'] = setJS
1407-
14081402
if self.separate_stdout_by_module:
14091403
self.stdout_by_module["__main__"] = StringIO.StringIO()
14101404
if self.custom_modules:
@@ -1602,8 +1596,9 @@ def exec_script_str(script_str, raw_input_lst_json, options_json, finalizer_func
16021596
# TODO: if we want to support unicode, remove str() cast
16031597
input_string_queue = [str(e) for e in json.loads(raw_input_lst_json)]
16041598

1605-
global __html__, __css__, __js__
1606-
__html__, __css__, __js__ = None, None, None
1599+
# these are now deprecated as of 2016-06-28
1600+
#global __html__, __css__, __js__
1601+
#__html__, __css__, __js__ = None, None, None
16071602

16081603
try:
16091604
logger._runscript(script_str)
@@ -1633,28 +1628,13 @@ def exec_script_str_local(script_str, raw_input_lst_json, cumulative_mode, heap_
16331628
# TODO: if we want to support unicode, remove str() cast
16341629
input_string_queue = [str(e) for e in json.loads(raw_input_lst_json)]
16351630

1636-
global __html__, __css__, __js__
1637-
__html__, __css__, __js__ = None, None, None
1631+
# these are now deprecated as of 2016-06-28
1632+
#global __html__, __css__, __js__
1633+
#__html__, __css__, __js__ = None, None, None
16381634

16391635
try:
16401636
logger._runscript(script_str)
16411637
except bdb.BdbQuit:
16421638
pass
16431639
finally:
16441640
return logger.finalize()
1645-
1646-
1647-
# deprecated?!?
1648-
def exec_str_with_user_ns(script_str, user_ns, finalizer_func):
1649-
logger = PGLogger(False, False, False, finalizer_func, disable_security_checks=True)
1650-
1651-
global __html__, __css__, __js__
1652-
__html__, __css__, __js__ = None, None, None
1653-
1654-
try:
1655-
logger._runscript(script_str, user_ns)
1656-
except bdb.BdbQuit:
1657-
pass
1658-
finally:
1659-
return logger.finalize()
1660-

0 commit comments

Comments
 (0)