| 911 | self.async_awaitable = ns["__pdb_await"]() |
| 912 | |
| 913 | def _read_code(self, line): |
| 914 | buffer = line |
| 915 | is_await_code = False |
| 916 | code = None |
| 917 | try: |
| 918 | if (code := codeop.compile_command(line + '\n', '<stdin>', 'single')) is None: |
| 919 | # Multi-line mode |
| 920 | with self._enable_multiline_input(): |
| 921 | buffer = line |
| 922 | continue_prompt = "... " |
| 923 | while (code := codeop.compile_command(buffer, '<stdin>', 'single')) is None: |
| 924 | if self.use_rawinput: |
| 925 | try: |
| 926 | line = input(continue_prompt) |
| 927 | except (EOFError, KeyboardInterrupt): |
| 928 | self.lastcmd = "" |
| 929 | print('\n') |
| 930 | return None, None, False |
| 931 | else: |
| 932 | self.stdout.write(continue_prompt) |
| 933 | self.stdout.flush() |
| 934 | line = self.stdin.readline() |
| 935 | if not len(line): |
| 936 | self.lastcmd = "" |
| 937 | self.stdout.write('\n') |
| 938 | self.stdout.flush() |
| 939 | return None, None, False |
| 940 | else: |
| 941 | line = line.rstrip('\r\n') |
| 942 | if line.isspace(): |
| 943 | # empty line, just continue |
| 944 | buffer += '\n' |
| 945 | else: |
| 946 | buffer += '\n' + line |
| 947 | self.lastcmd = buffer |
| 948 | except SyntaxError as e: |
| 949 | # Maybe it's an await expression/statement |
| 950 | if ( |
| 951 | self.async_shim_frame is not None |
| 952 | and e.msg == "'await' outside function" |
| 953 | ): |
| 954 | is_await_code = True |
| 955 | else: |
| 956 | raise |
| 957 | |
| 958 | return code, buffer, is_await_code |
| 959 | |
| 960 | def default(self, line): |
| 961 | if line[:1] == '!': line = line[1:].strip() |