Add Python 3 port (unwrap_py3.py)#3
Open
DenisStark77 wants to merge 1 commit into
Open
Conversation
unwrap.py targets Python 2: print statement, base64.decodestring, chr() returning bytes. This commit adds a sibling unwrap_py3.py that preserves the original algorithm (including the embedded charmap[] substitution table) but is compatible with Python 3: - print(...) function-call form - base64.b64decode + explicit bytes() construction over the charmap - file opens with explicit encoding (latin-1 input, utf-8 output) - preserves the original loop's "len(base64str) < base64len includes embedded newlines, strip newlines before decode" semantics so the parser still recognizes the same wrapped blocks. unwrap.py is left in place for legacy Python 2 users; the README now documents both invocations. Smoke-tested against ~460 real Way4 (OpenWay) wrapped Oracle PL/SQL package bodies on Python 3.9 — 459/459 packages decoded cleanly, ~900k total lines of readable output, no decode errors.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Python 3 port of the unwrapper as a sibling file (
unwrap_py3.py); leaves the originalunwrap.pyin place for Python 2 users.Why
The original
unwrap.pyis Python 2 only:print decode_base64_package(...)— Py2 statement formbase64.decodestring— removed in Py3chr(charmap[ord(byte)])— relies on Py2's "string = bytes" semanticsOn Python 3 it fails at parse time with
SyntaxError. The port preserves the original algorithm (and the embeddedcharmap[]substitution table — copied verbatim) but uses the Py3-native APIs:print(...)function formbase64.b64decode+ an explicitbytes(charmap[b] for b in base64dec)constructionlatin-1input,utf-8decoded outputlen(base64str) < base64lenincludes embedded newlines, which are stripped just before decoding — so the parser recognizes the same wrapped-block layout the original handlesTesting
Smoke-tested against ~460 real Oracle PL/SQL wrapped package bodies (Way4 / OpenWay distribution) on Python 3.9:
What this PR does not do
unwrap.py— keeps both files so existing Py2 invocations still work.charmap[]table is byte-for-byte identical.If you'd prefer the port to replace
unwrap.pyrather than coexist, happy to push that as a follow-up commit.