#!/usr/bin/env bash # # Usage: # ./common.sh set -o nounset set -o pipefail set -o errexitsetconst global FOO = "bar" readonly THIS_DIR = $[cd $[dirname $0] && pwd]setconst global FOO = "bar" readonly GRAMMAR = "$THIS_DIR/_tmp/py27.grammar.pickle" proc opy_ { env PYTHONPATH=$THIS_DIR $THIS_DIR/../bin/opy_.py @Argv } proc opyg { opy_ -g $GRAMMAR -- @Argv } # The old compile path proc _compile-one { # The production testlist_starexpr is unhandled in the compiler package. # Python 2.7 doesn't have it. #local g=2to3.grammar var g = 'py27.grammar' # pgen2 + old compiler/ #PYTHONPATH=. ./opy_main.py $g old-compile "$@" # opy is pgen2 + compiler2 opyg compile @Argv } proc _compile2-one { opyg compile2 @Argv } proc _stdlib-compile-one { # Run it from source, so we can patch. Bug still appears. #$PY27/python misc/stdlib_compile.py "$@" # No with statement #~/src/Python-2.4.6/python misc/stdlib_compile.py "$@" # NOT here #~/src/Python-2.6.9/python misc/stdlib_compile.py "$@" # Bug appears in Python 2.7.9 too! #~/src/Python-2.7.9/python misc/stdlib_compile.py "$@" # Why is it in 2.7.2? No hash randomization there? #~/src/Python-2.7.2/python misc/stdlib_compile.py "$@" # Woah it took 51 iterations to find! # Much rarer in Python 2.7.0. 100 iterations didn't find it? # Then 35 found it. Wow. ~/src/Python-2.7/python misc/stdlib_compile.py @Argv #misc/stdlib_compile.py "$@" } proc _ccompile-one { misc/ccompile.py @Argv } (CommandList children: [ (C {(set)} {(-o)} {(nounset)}) (C {(set)} {(-o)} {(pipefail)}) (C {(set)} {(-o)} {(errexit)}) (Assignment keyword: Assign_Readonly pairs: [ (assign_pair lhs: (LhsName name:THIS_DIR) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (AndOr children: [ (C {(cd)} { (CommandSubPart command_list: (CommandList children: [(C {(dirname)} {($ VSub_Number "$0")})] ) left_token: spids: [38 42] ) } ) (C {(pwd)}) ] op_id: Op_DAmp ) ] ) left_token: spids: [35 47] ) } spids: [34] ) ] spids: [32] ) (Assignment keyword: Assign_Readonly pairs: [ (assign_pair lhs: (LhsName name:GRAMMAR) op: Equal rhs: {($ VSub_Name "$THIS_DIR") (/_tmp/py27.grammar.pickle)} spids: [51] ) ] spids: [49] ) (FuncDef name: opy_ body: (BraceGroup children: [ (SimpleCommand words: [{($ VSub_Name "$THIS_DIR") (/../bin/opy_.py)} {(DQ ($ VSub_At "$@"))}] more_env: [(env_pair name:PYTHONPATH val:{($ VSub_Name "$THIS_DIR")} spids:[63])] ) ] spids: [60] ) spids: [56 59] ) (FuncDef name: opyg body: (BraceGroup children: [(C {(opy_)} {(-g)} {($ VSub_Name "$GRAMMAR")} {(--)} {(DQ ($ VSub_At "$@"))})] spids: [80] ) spids: [76 79] ) (FuncDef name: _compile-one body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [(assign_pair lhs:(LhsName name:g) op:Equal rhs:{(py27.grammar)} spids:[122])] spids: [120] ) (C {(opyg)} {(compile)} {(DQ ($ VSub_At "$@"))}) ] spids: [105] ) spids: [101 104] ) (FuncDef name: _compile2-one body: (BraceGroup children:[(C {(opyg)} {(compile2)} {(DQ ($ VSub_At "$@"))})] spids:[154]) spids: [150 153] ) (FuncDef name: _stdlib-compile-one body: (BraceGroup children: [ (C {(TildeSubPart prefix:"") (/src/Python-2.7/python)} {(misc/stdlib_compile.py)} {(DQ ($ VSub_At "$@"))} ) ] spids: [172] ) spids: [168 171] ) (FuncDef name: _ccompile-one body: (BraceGroup children:[(C {(misc/ccompile.py)} {(DQ ($ VSub_At "$@"))})] spids:[254]) spids: [250 253] ) ] )