Skip to content

Improve error handling when read marshal data #101006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
serhiy-storchaka opened this issue Jan 13, 2023 · 0 comments
Closed

Improve error handling when read marshal data #101006

serhiy-storchaka opened this issue Jan 13, 2023 · 0 comments
Labels
3.10 only security fixes 3.11 only security fixes 3.12 only security fixes type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Jan 13, 2023

There are several issues in error handling in the marshal module:

  1. EOFError can override other errors such as MemoryError or OSError at the start of the object.
  2. When the NULL object occurs as a code object component, the error message can be misleading (like "NULL object in marshal data for list") or even ignored (if the code object is a dict key) and reading will continue.

Also, it is a common idiom to only call PyErr_Occurred() if the return code denotes a possible error. This is not always used in that code. While the performance gain may be tiny, it is better to get rid of an overhead, it can pay for itself after further optimizations.

Linked PRs

@serhiy-storchaka serhiy-storchaka added type-feature A feature request or enhancement 3.11 only security fixes 3.10 only security fixes 3.12 only security fixes labels Jan 13, 2023
@serhiy-storchaka serhiy-storchaka changed the title Improve error handling when read a marshal data Improve error handling when read marshal data Jan 13, 2023
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Jan 13, 2023
* EOFError no longer overrides other errors such as MemoryError or OSError at
  the start of the object.
* Raise more relevant error when the NULL object occurs as a code object
  component.
* Minimize an overhead of calling PyErr_Occurred().
serhiy-storchaka added a commit that referenced this issue Jun 29, 2023
* EOFError no longer overrides other errors such as MemoryError or OSError at
  the start of the object.
* Raise more relevant error when the NULL object occurs as a code object
  component.
* Minimize an overhead of calling PyErr_Occurred().
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 29, 2023
…nGH-101007)

* EOFError no longer overrides other errors such as MemoryError or OSError at
  the start of the object.
* Raise more relevant error when the NULL object occurs as a code object
  component.
* Minimize an overhead of calling PyErr_Occurred().
(cherry picked from commit 8bf6904)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 29, 2023
…nGH-101007)

* EOFError no longer overrides other errors such as MemoryError or OSError at
  the start of the object.
* Raise more relevant error when the NULL object occurs as a code object
  component.
* Minimize an overhead of calling PyErr_Occurred().
(cherry picked from commit 8bf6904)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this issue Jun 29, 2023
…01007) (GH-106226)

* EOFError no longer overrides other errors such as MemoryError or OSError at
  the start of the object.
* Raise more relevant error when the NULL object occurs as a code object
  component.
* Minimize an overhead of calling PyErr_Occurred().
(cherry picked from commit 8bf6904)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this issue Jun 29, 2023
…01007) (GH-106227)

* EOFError no longer overrides other errors such as MemoryError or OSError at
  the start of the object.
* Raise more relevant error when the NULL object occurs as a code object
  component.
* Minimize an overhead of calling PyErr_Occurred().
(cherry picked from commit 8bf6904)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.10 only security fixes 3.11 only security fixes 3.12 only security fixes type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant