FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Use 'B' instead of 'b' to parse/build char value. by masamitsu-murase · Pull Request #305 · stackless-dev/stackless · GitHub

This repository was archived by the owner on Feb 13, 2025. It is now read-only.
/ stackless Public archive
forked from python/cpython

Use 'B' instead of 'b' to parse/build char value. - #305

Open
masamitsu-murase wants to merge 1 commit into
stackless-dev:3.8-slpfrom
masamitsu-murase:use_B_to_parse_signed_char
Open

Use 'B' instead of 'b' to parse/build char value.#305
masamitsu-murase wants to merge 1 commit into
stackless-dev:3.8-slpfrom
masamitsu-murase:use_B_to_parse_signed_char

Conversation

masamitsu-murase commented Sep 18, 2021
edited
Loading

Copy link
Copy Markdown

Issue:

  • pickle.load raises OverflowError if loaded content includes PyFrameObject, whose f_executing is set to SLP_FRAME_EXECUTING_INVALID, i.e. -1.

Solution:

  • Use 'B' instead of 'b' to parse/build char value when frame object is pickled.

How to reproduce this issue:

  • The following code causes OverflowError unexpectedly.
     import pickle
     import stackless
     import sys
    
    
     try:
         raise RuntimeError()
     except:
         traceback_object = sys.exc_info()[2]
     a = pickle.dumps(traceback_object)
     b = pickle.loads(a)
     c = pickle.dumps(b)
     d = pickle.loads(c)
     # => This raises "OverflowError: unsigned byte integer is less than minimum".

Details:

  • f_executing in PyFrameObject is declared as char, which might be signed depending on implementation.
    Therefore, 'B' should be specified when Py_BuildValue and PyArg_ParseTuple is called.
  • If 'b' is specified instead of 'B' and f_executing is set to SLP_FRAME_EXECUTING_INVALID, PyArg_ParseTuple in frame_setstate in Stackless\pickling\prickelpit.c raises OverflowError.
    This is raised in convertsimple in Python\getargs.c because SLP_FRAME_EXECUTING_INVALID is less than 0.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL