returns 'False' in case expression is partially correct
(thread_id, frame_id, expression, dbg)
| 540 | |
| 541 | |
| 542 | def console_exec(thread_id, frame_id, expression, dbg): |
| 543 | """returns 'False' in case expression is partially correct""" |
| 544 | frame = dbg.find_frame(thread_id, frame_id) |
| 545 | |
| 546 | is_multiline = expression.count("@LINE@") > 1 |
| 547 | expression = str(expression.replace("@LINE@", "\n")) |
| 548 | |
| 549 | # Not using frame.f_globals because of https://sourceforge.net/tracker2/?func=detail&aid=2541355&group_id=85796&atid=577329 |
| 550 | # (Names not resolved in generator expression in method) |
| 551 | # See message: http://mail.python.org/pipermail/python-list/2009-January/526522.html |
| 552 | updated_globals = {} |
| 553 | updated_globals.update(frame.f_globals) |
| 554 | updated_globals.update(frame.f_locals) # locals later because it has precedence over the actual globals |
| 555 | |
| 556 | if IPYTHON: |
| 557 | need_more = exec_code(CodeFragment(expression), updated_globals, frame.f_locals, dbg) |
| 558 | if not need_more: |
| 559 | pydevd_save_locals.save_locals(frame) |
| 560 | return need_more |
| 561 | |
| 562 | interpreter = ConsoleWriter() |
| 563 | |
| 564 | if not is_multiline: |
| 565 | try: |
| 566 | code = compile_command(expression) |
| 567 | except (OverflowError, SyntaxError, ValueError): |
| 568 | # Case 1 |
| 569 | interpreter.showsyntaxerror() |
| 570 | return False |
| 571 | if code is None: |
| 572 | # Case 2 |
| 573 | return True |
| 574 | else: |
| 575 | code = expression |
| 576 | |
| 577 | # Case 3 |
| 578 | |
| 579 | try: |
| 580 | Exec(code, updated_globals, frame.f_locals) |
| 581 | |
| 582 | except SystemExit: |
| 583 | raise |
| 584 | except: |
| 585 | interpreter.showtraceback() |
| 586 | else: |
| 587 | pydevd_save_locals.save_locals(frame) |
| 588 | return False |
| 589 | |
| 590 | |
| 591 | # ======================================================================================================================= |
nothing calls this directly
no test coverage detected