guydav commited on
Commit
ccfd32e
1 Parent(s): 6b1d82a

Fiexd a minor bug

Browse files
Files changed (1) hide show
  1. restrictedpython_code_eval.py +2 -3
restrictedpython_code_eval.py CHANGED
@@ -474,8 +474,6 @@ def _unsafe_execute(check_program, result, timeout,
474
  # Disable functionalities that can make destructive changes to the test.
475
  reliability_guard()
476
 
477
- print(allowed_imports, allow_str_format, allow_underscore_variable_names)
478
-
479
  # Run program.
480
  try:
481
  builtins = {}
@@ -506,7 +504,7 @@ def _unsafe_execute(check_program, result, timeout,
506
 
507
  if allow_str_format:
508
  exec_globals['getattr'] = safer_getattr_allowing_string_format # type: ignore
509
- exec_globals['__builtins__']['getattr'] = safer_getattr_allowing_string_format
510
 
511
  if '__metaclass__' not in exec_globals:
512
  exec_globals['__metaclass__'] = type # type: ignore
@@ -528,6 +526,7 @@ def _unsafe_execute(check_program, result, timeout,
528
 
529
  if 'getattr' not in exec_globals:
530
  exec_globals['getattr'] = safer_getattr # type: ignore
 
531
 
532
  if '_write_' not in exec_globals:
533
  exec_globals['_write_'] = _default_write_ # type: ignore
 
474
  # Disable functionalities that can make destructive changes to the test.
475
  reliability_guard()
476
 
 
 
477
  # Run program.
478
  try:
479
  builtins = {}
 
504
 
505
  if allow_str_format:
506
  exec_globals['getattr'] = safer_getattr_allowing_string_format # type: ignore
507
+ exec_globals['__builtins__']['_getattr_'] = safer_getattr_allowing_string_format
508
 
509
  if '__metaclass__' not in exec_globals:
510
  exec_globals['__metaclass__'] = type # type: ignore
 
526
 
527
  if 'getattr' not in exec_globals:
528
  exec_globals['getattr'] = safer_getattr # type: ignore
529
+ exec_globals['__builtins__']['_getattr_'] = safer_getattr
530
 
531
  if '_write_' not in exec_globals:
532
  exec_globals['_write_'] = _default_write_ # type: ignore