Skip to content

Commit

Permalink
Properly escape strings.
Browse files Browse the repository at this point in the history
Backported from decompyle3
  • Loading branch information
rocky committed Mar 25, 2024
1 parent 3b1d5bd commit 458d472
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions uncompyle6/semantics/customize36.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2023 by Rocky Bernstein
# Copyright (c) 2019-2024 by Rocky Bernstein
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -15,16 +15,17 @@
"""Isolate Python 3.6 version-specific semantic actions here.
"""

from xdis import iscode
from spark_parser.ast import GenericASTTraversalPruningException
from xdis import iscode

from uncompyle6.scanners.tok import Token
from uncompyle6.semantics.helper import flatten_list, escape_string, strip_quotes
from uncompyle6.semantics.consts import (
INDENT_PER_LEVEL,
PRECEDENCE,
TABLE_DIRECT,
TABLE_R,
)
from uncompyle6.semantics.helper import escape_string, flatten_list, strip_quotes
from uncompyle6.util import get_code_name


Expand All @@ -38,7 +39,6 @@ def escape_format(s):


def customize_for_version36(self, version):

# fmt: off
PRECEDENCE["call_kw"] = 0
PRECEDENCE["call_kw36"] = 1
Expand Down Expand Up @@ -276,7 +276,7 @@ def call_ex_kw(node):
if value == "":
fmt = "%c(%p)"
else:
fmt = "%%c(%s, %%p)" % value
fmt = "%c" + ("(%s, " % value).replace("%", "%%") + "%p)"

self.template_engine(
(fmt, (0, "expr"), (2, "build_map_unpack_with_call", 100)), node
Expand All @@ -295,7 +295,7 @@ def call_ex_kw2(node):
if value == "":
fmt = "%c(%p)"
else:
fmt = "%%c(%s, %%p)" % value
fmt = "%c" + ("(%s, " % value).replace("%", "%%") + "%p)"

self.template_engine(
(fmt, (0, "expr"), (2, "build_map_unpack_with_call", 100)), node
Expand Down Expand Up @@ -707,6 +707,7 @@ def n_list_comp_async(node):
self.comprehension_walk_newer(node, iter_index=3, code_index=0)
self.write("]")
self.prune()

self.n_list_comp_async = n_list_comp_async

# def kwargs_only_36(node):
Expand Down

0 comments on commit 458d472

Please sign in to comment.