| 2776 | return int(f"{v.major:02X}{v.minor:02X}{revision:02X}F0", 16) |
| 2777 | |
| 2778 | def _ensure_valid_message(self, msg): |
| 2779 | # Ensure the message conforms to our protocol. |
| 2780 | # If anything needs to be changed here for a patch release of Python, |
| 2781 | # the 'revision' in protocol_version() should be updated. |
| 2782 | match msg: |
| 2783 | case {"message": str(), "type": str()}: |
| 2784 | # Have the client show a message. The client chooses how to |
| 2785 | # format the message based on its type. The currently defined |
| 2786 | # types are "info" and "error". If a message has a type the |
| 2787 | # client doesn't recognize, it must be treated as "info". |
| 2788 | pass |
| 2789 | case {"help": str()}: |
| 2790 | # Have the client show the help for a given argument. |
| 2791 | pass |
| 2792 | case {"prompt": str(), "state": str()}: |
| 2793 | # Have the client display the given prompt and wait for a reply |
| 2794 | # from the user. If the client recognizes the state it may |
| 2795 | # enable mode-specific features like multi-line editing. |
| 2796 | # If it doesn't recognize the state it must prompt for a single |
| 2797 | # line only and send it directly to the server. A server won't |
| 2798 | # progress until it gets a "reply" or "signal" message, but can |
| 2799 | # process "complete" requests while waiting for the reply. |
| 2800 | pass |
| 2801 | case { |
| 2802 | "completions": list(completions) |
| 2803 | } if all(isinstance(c, str) for c in completions): |
| 2804 | # Return valid completions for a client's "complete" request. |
| 2805 | pass |
| 2806 | case { |
| 2807 | "command_list": list(command_list) |
| 2808 | } if all(isinstance(c, str) for c in command_list): |
| 2809 | # Report the list of legal PDB commands to the client. |
| 2810 | # Due to aliases this list is not static, but the client |
| 2811 | # needs to know it for multi-line editing. |
| 2812 | pass |
| 2813 | case _: |
| 2814 | raise AssertionError( |
| 2815 | f"PDB message doesn't follow the schema! {msg}" |
| 2816 | ) |
| 2817 | |
| 2818 | @classmethod |
| 2819 | def _start_signal_listener(cls, address): |