From 4a379a469e97df6c8858fa270687df54476ed880 Mon Sep 17 00:00:00 2001 From: Marco Barisione Date: Sun, 7 Aug 2022 15:28:21 +0100 Subject: [PATCH 1/2] Do not raise an error for invalid octal escape sequences (#64) --- CHANGELOG.md | 1 + pygdbmi/gdbescapes.py | 8 +++++++- tests/test_pygdbmi.py | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be88847..4a884a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 0.10.0.3 * Fixed a bug where notifications without a payload were not recognized as such +* Invalid octal sequences produced by GDB are left unchanged instead of causing a `UnicodeDecodeError` (#64) ## 0.10.0.2 * Strings containing escapes are now unescaped, both for messages in error records, which were previously mangled (#57), and textual records, which were previously left escaped (#58) diff --git a/pygdbmi/gdbescapes.py b/pygdbmi/gdbescapes.py index 5d8cc50..ccba4c1 100644 --- a/pygdbmi/gdbescapes.py +++ b/pygdbmi/gdbescapes.py @@ -166,7 +166,13 @@ def _unescape_internal( raise ValueError( f"Invalid octal number {octal_number!r} in {escaped_str!r}" ) from exc - replaced = octal_sequence_bytes.decode("utf-8") + try: + replaced = octal_sequence_bytes.decode("utf-8") + except UnicodeDecodeError: + # GDB should never generate invalid sequences but, according to #64, + # it can do that on Windows. In this case we just keep the sequence + # unchanged. + replaced = f"\\{escaped_octal}" elif escaped_char is not None: # We found a single escaped character. diff --git a/tests/test_pygdbmi.py b/tests/test_pygdbmi.py index 6737dd5..a684d3c 100755 --- a/tests/test_pygdbmi.py +++ b/tests/test_pygdbmi.py @@ -502,6 +502,9 @@ def test_unescape(self) -> None: with self.assertRaisesRegex(ValueError, "Invalid escape character"): unescape(bad) + # An octal sequence that is not valid UTF-8 doesn't get changes, see #64. + assert_match(unescape(r"254 '\376'"), r"254 '\376'") + def test_advance_past_string_with_gdb_escapes(self) -> None: """Test the advance_past_string_with_gdb_escapes function""" From 72897f8701d07fde89a940c0ed0d7ef7c900a6df Mon Sep 17 00:00:00 2001 From: Chad Smith Date: Tue, 9 Aug 2022 21:40:43 -0700 Subject: [PATCH 2/2] update and freeze mkdoc dependencies (#73) --- .github/workflows/tests.yml | 4 +- CHANGELOG.md | 124 ++++++++++++++++++++++-------------- MANIFEST.in | 2 + mkdoc_requirements.in | 5 ++ mkdoc_requirements.txt | 78 +++++++++++++++++++++++ noxfile.py | 21 +++--- 6 files changed, 170 insertions(+), 64 deletions(-) create mode 100644 mkdoc_requirements.in create mode 100644 mkdoc_requirements.txt diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8b53f69..a8bab36 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -42,7 +42,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: "3.8" + python-version: "3.10" - name: Install dependencies run: | python -m pip install --upgrade pip @@ -58,7 +58,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: "3.8" + python-version: "3.10" - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a884a7..108900e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,103 +1,129 @@ # pygdbmi release history -## 0.10.0.3 -* Fixed a bug where notifications without a payload were not recognized as such -* Invalid octal sequences produced by GDB are left unchanged instead of causing a `UnicodeDecodeError` (#64) +## dev + +- Fixed a bug where notifications without a payload were not recognized as such +- Invalid octal sequences produced by GDB are left unchanged instead of causing a `UnicodeDecodeError` (#64) + +Internal changes + +- Update and freeze dependencies for documentation generation ## 0.10.0.2 -* Strings containing escapes are now unescaped, both for messages in error records, which were previously mangled (#57), and textual records, which were previously left escaped (#58) -* Dropped support for Python 3.6 and added explicit support for Python 3.9 and 3.10. + +- Strings containing escapes are now unescaped, both for messages in error records, which were previously mangled (#57), and textual records, which were previously left escaped (#58) +- Dropped support for Python 3.6 and added explicit support for Python 3.9 and 3.10. ## 0.10.0.1 -* Fix bug with `time_to_check_for_additional_output_sec`, as it was not being used when passed to `GdbController` + +- Fix bug with `time_to_check_for_additional_output_sec`, as it was not being used when passed to `GdbController` ## 0.10.0.0 - **Breaking Changes** +**Breaking Changes** -* Drop support for Python 3.5 -* Update `GdbController()` API. New API is `GdbController(command: Optional[List[str]], time_to_check_for_additional_output_sec: Optional[int])`. -* `GdbController.verify_valid_gdb_subprocess()` was removed -* Remove `NoGdbProcessError` error +- Drop support for Python 3.5 +- Update `GdbController()` API. New API is `GdbController(command: Optional[List[str]], time_to_check_for_additional_output_sec: Optional[int])`. +- `GdbController.verify_valid_gdb_subprocess()` was removed +- Remove `NoGdbProcessError` error Other Changes -* Add new `IoManager` class to handle more generic use-cases -* [dev] use pytest for testing -* gdb mi parsing remains unchanged +- Add new `IoManager` class to handle more generic use-cases +- [dev] use pytest for testing +- gdb mi parsing remains unchanged ## 0.9.0.3 -* Drop support for 2.7, 3.4 -* Add support for 3.7, 3.8 -* Add `py.typed` file so mypy can enforce type hints on `pygdbmi` -* Do not log in StringStream (#36) -* Updates to build and CI tests (use nox) -* Use mkdocs and mkdocstrings -* Doc updates +- Drop support for 2.7, 3.4 +- Add support for 3.7, 3.8 +- Add `py.typed` file so mypy can enforce type hints on `pygdbmi` +- Do not log in StringStream (#36) +- Updates to build and CI tests (use nox) +- Use mkdocs and mkdocstrings +- Doc updates ## 0.9.0.2 -* More doc updates + +- More doc updates ## 0.9.0.1 -* Update docs + +- Update docs ## 0.9.0.0 -* Stop buffering output -* Use logger in GdbController; modify `verbose` arguments. -* Remove support for Python 3.3 + +- Stop buffering output +- Use logger in GdbController; modify `verbose` arguments. +- Remove support for Python 3.3 ## 0.8.4.0 -* Add method `get_subprocess_cmd` to view the gdb command run in the shell + +- Add method `get_subprocess_cmd` to view the gdb command run in the shell ## 0.8.3.0 -* Improve reading gdb responses on unix (performance, bugfix) (@mouuff) + +- Improve reading gdb responses on unix (performance, bugfix) (@mouuff) ## 0.8.2.0 -* Add support for [record and replay (rr) gdb supplement](http://rr-project.org/) + +- Add support for [record and replay (rr) gdb supplement](http://rr-project.org/) ## 0.8.1.1 -* Discard unexpected text from gdb + +- Discard unexpected text from gdb ## 0.8.1.0 -* Add native Windows support + +- Add native Windows support ## 0.8.0.0 -* Make parsing more efficient when gdb outputs large strings -* Add new methods to GdbController class: `spawn_new_gdb_subprocess`, `send_signal_to_gdb`, and `interrupt_gdb` + +- Make parsing more efficient when gdb outputs large strings +- Add new methods to GdbController class: `spawn_new_gdb_subprocess`, `send_signal_to_gdb`, and `interrupt_gdb` ## 0.7.4.5 -* Update setup.py + +- Update setup.py ## 0.7.4.4 -* Fix windows ctypes import (#23, @rudolfwalter) + +- Fix windows ctypes import (#23, @rudolfwalter) ## 0.7.4.3 -* Workaround gdb bug with repeated dictionary keys + +- Workaround gdb bug with repeated dictionary keys ## 0.7.4.2 -* Improved buffering of incomplete gdb mi output (@trapito) -* Remove support of Python 3.2 + +- Improved buffering of incomplete gdb mi output (@trapito) +- Remove support of Python 3.2 ## 0.7.4.1 -* Preserve leading and trailing spaces in gdb/mi output (plus unit tests) -* Add unit test for buffering of gdb/mi output -* Documentation updates -* Refactoring + +- Preserve leading and trailing spaces in gdb/mi output (plus unit tests) +- Add unit test for buffering of gdb/mi output +- Documentation updates +- Refactoring ## 0.7.4.0 -* Add more exception types (`NoGdbProcessError`, `GdbTimeoutError`) -* Add logic fixes for Windows (@johncf) -* Use codecs.open() to open the readme.rst, to prevent locale related bugs (@mariusmue) + +- Add more exception types (`NoGdbProcessError`, `GdbTimeoutError`) +- Add logic fixes for Windows (@johncf) +- Use codecs.open() to open the readme.rst, to prevent locale related bugs (@mariusmue) ## 0.7.3.3 -* Add alternate pipe implementation for Windows + +- Add alternate pipe implementation for Windows ## 0.7.3.2 -* Replace `epoll` with `select` for osx compatibility (@felipesere) + +- Replace `epoll` with `select` for osx compatibility (@felipesere) ## 0.7.3.1 -* Fix README + +- Fix README ## 0.7.3.0 -* Add support for gdb/mi (optional) tokens (@mariusmue) + +- Add support for gdb/mi (optional) tokens (@mariusmue) diff --git a/MANIFEST.in b/MANIFEST.in index 5f4664f..da1347f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,6 +7,8 @@ exclude example.py exclude .flake8 exclude noxfile.py exclude mkdocs.yml +exclude *.in +exclude *.txt prune tests prune docs \ No newline at end of file diff --git a/mkdoc_requirements.in b/mkdoc_requirements.in new file mode 100644 index 0000000..41cf19d --- /dev/null +++ b/mkdoc_requirements.in @@ -0,0 +1,5 @@ +. +mkdocstrings[python] +mkdocs +mkdocs-material +pygments \ No newline at end of file diff --git a/mkdoc_requirements.txt b/mkdoc_requirements.txt new file mode 100644 index 0000000..ec947c9 --- /dev/null +++ b/mkdoc_requirements.txt @@ -0,0 +1,78 @@ +# +# This file is autogenerated by pip-compile with python 3.10 +# To update, run: +# +# pip-compile mkdoc_requirements.in +# +click==8.1.3 + # via mkdocs +ghp-import==2.1.0 + # via mkdocs +griffe==0.22.0 + # via mkdocstrings-python +importlib-metadata==4.12.0 + # via mkdocs +jinja2==3.1.2 + # via + # mkdocs + # mkdocs-material + # mkdocstrings +markdown==3.3.7 + # via + # mkdocs + # mkdocs-autorefs + # mkdocs-material + # mkdocstrings + # pymdown-extensions +markupsafe==2.1.1 + # via + # jinja2 + # mkdocstrings +mergedeep==1.3.4 + # via mkdocs +mkdocs==1.3.1 + # via + # -r mkdoc_requirements.in + # mkdocs-autorefs + # mkdocs-material + # mkdocstrings +mkdocs-autorefs==0.4.1 + # via mkdocstrings +mkdocs-material==8.3.9 + # via -r mkdoc_requirements.in +mkdocs-material-extensions==1.0.3 + # via mkdocs-material +mkdocstrings[python]==0.19.0 + # via + # -r mkdoc_requirements.in + # mkdocstrings-python +mkdocstrings-python==0.7.1 + # via mkdocstrings +packaging==21.3 + # via mkdocs + . + # via -r mkdoc_requirements.in +pygments==2.12.0 + # via + # -r mkdoc_requirements.in + # mkdocs-material +pymdown-extensions==9.5 + # via + # mkdocs-material + # mkdocstrings +pyparsing==3.0.9 + # via packaging +python-dateutil==2.8.2 + # via ghp-import +pyyaml==6.0 + # via + # mkdocs + # pyyaml-env-tag +pyyaml-env-tag==0.1 + # via mkdocs +six==1.16.0 + # via python-dateutil +watchdog==2.1.9 + # via mkdocs +zipp==3.8.1 + # via importlib-metadata diff --git a/noxfile.py b/noxfile.py index 1038c81..ec091bd 100644 --- a/noxfile.py +++ b/noxfile.py @@ -26,30 +26,25 @@ def lint(session): session.run("python", "setup.py", "check", "--metadata", "--strict") -doc_dependencies = [ - ".", - "mkdocstrings", - "mkdocs", - "mkdocs-material", - "pygments", -] +def install_mkdoc_dependencies(session): + session.install("-r", "mkdoc_requirements.txt") -@nox.session(python="3.7") +@nox.session def docs(session): - session.install(*doc_dependencies) + install_mkdoc_dependencies(session) session.run("mkdocs", "build") -@nox.session(python="3.7") +@nox.session def serve_docs(session): - session.install(*doc_dependencies) + install_mkdoc_dependencies(session) session.run("mkdocs", "serve") -@nox.session(python="3.7") +@nox.session def publish_docs(session): - session.install(*doc_dependencies) + install_mkdoc_dependencies(session) session.run("mkdocs", "gh-deploy")