Skip to content

Commit

Permalink
remove double-quote preference here....
Browse files Browse the repository at this point in the history
it is now done in xdis which is where it is better done
  • Loading branch information
rocky committed Feb 18, 2024
1 parent 40c4764 commit 3e00880
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
10 changes: 0 additions & 10 deletions uncompyle6/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,16 +649,6 @@ def get_scanner(version: Union[str, tuple], is_pypy=False, show_asm=None) -> Sca
return scanner


def prefer_double_quote(string: str) -> str:
"""
Prefer a double quoted string over a
single quoted string when possible
"""
if string[1:-1].find('"') == -1:
return f'"{string[1:-1]}"'
return string


if __name__ == "__main__":
import inspect

Expand Down
3 changes: 1 addition & 2 deletions uncompyle6/scanners/scanner3.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
from xdis.bytecode import _get_const_info
from xdis.opcodes.opcode_3x import parse_fn_counts_30_35

from uncompyle6.scanner import CONST_COLLECTIONS, Scanner, prefer_double_quote
from uncompyle6.scanner import CONST_COLLECTIONS, Scanner
from uncompyle6.scanners.tok import Token
from uncompyle6.util import get_code_name

Expand Down Expand Up @@ -612,7 +612,6 @@ def ingest(
pattr = "<code_object " + co_name + ">"
elif isinstance(const, str):
opname = "LOAD_STR"
pattr = prefer_double_quote(inst.argrepr)
else:
if isinstance(inst.arg, int) and inst.arg < len(co.co_consts):
argval, _ = _get_const_info(inst.arg, co.co_consts)
Expand Down
3 changes: 1 addition & 2 deletions uncompyle6/scanners/scanner37base.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from xdis import Instruction, instruction_size, iscode
from xdis.bytecode import _get_const_info

from uncompyle6.scanner import Scanner, Token, prefer_double_quote
from uncompyle6.scanner import Scanner, Token

globals().update(op3.opmap)

Expand Down Expand Up @@ -386,7 +386,6 @@ def tokens_append(j, token):
pattr = "<code_object " + const.co_name + ">"
elif isinstance(const, str):
opname = "LOAD_STR"
pattr = prefer_double_quote(inst.argrepr)
else:
if isinstance(inst.arg, int) and inst.arg < len(co.co_consts):
argval, _ = _get_const_info(inst.arg, co.co_consts)
Expand Down

0 comments on commit 3e00880

Please sign in to comment.