Skip to content

Commit 3b9f2b2

Browse files
committed
Migrate to use Python 3
Migrate Python code to Python 3 by: * update scripts' shebang * migrate syntax in Python modules * delete unnecessary imports
1 parent 0423e4d commit 3b9f2b2

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

Sources/SwiftSyntax/TokenKind.swift.gyb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public enum TokenKind {
7676
case .eof: return .zero
7777
% for token in SYNTAX_TOKENS:
7878
% if token.text:
79-
case .${token.swift_kind()}: return SourceLength(utf8Length: ${len(token.text.decode('string_escape'))})
79+
case .${token.swift_kind()}: return SourceLength(utf8Length: ${len(token.text.encode('utf-8').decode('unicode-escape'))})
8080
% else:
8181
case .${token.swift_kind()}(let text): return SourceLength(of: text)
8282
% end
@@ -168,7 +168,7 @@ extension TokenKind {
168168
% for token in SYNTAX_TOKENS:
169169
% if token.text:
170170
case .${token.swift_kind()}:
171-
let length = ${len(token.text.decode('string_escape'))}
171+
let length = ${len(token.text.encode('utf-8').decode('unicode-escape'))}
172172
return body(.init(kind: .${token.swift_kind()}, length: length))
173173
% else:
174174
case .${token.swift_kind()}(var text):

Sources/SwiftSyntaxBuilder/gyb_helpers/SyntaxBuildableWrappers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from gyb_syntax_support import SYNTAX_TOKEN_MAP, create_node_map, SYNTAX_NODES
22
from gyb_syntax_support.kinds import SYNTAX_BASE_KINDS
33
from gyb_syntax_support.kinds import lowercase_first_word
4-
from ExpressibleAsConformances import SYNTAX_BUILDABLE_EXPRESSIBLE_AS_CONFORMANCES
5-
from utils import flat_documentation
4+
from .ExpressibleAsConformances import SYNTAX_BUILDABLE_EXPRESSIBLE_AS_CONFORMANCES
5+
from .utils import flat_documentation
66

77
class SyntaxBuildableChild:
88
"""
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
from SyntaxBuildableWrappers import SyntaxBuildableChild, SyntaxBuildableNode, SyntaxBuildableType
2-
from utils import conformance_clause, flat_documentation
1+
from .SyntaxBuildableWrappers import SyntaxBuildableChild, SyntaxBuildableNode, SyntaxBuildableType
2+
from .utils import conformance_clause, flat_documentation

build-script.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
#!/usr/bin/env python
2-
3-
4-
from __future__ import absolute_import, print_function, unicode_literals
1+
#!/usr/bin/env python3
52

63
import argparse
74
import os
@@ -519,7 +516,7 @@ def find_lit_test_helper_exec(toolchain, build_dir, release):
519516
swiftpm_call.extend(["--show-bin-path"])
520517

521518
bin_dir = subprocess.check_output(swiftpm_call)
522-
return os.path.join(bin_dir.strip(), "lit-test-helper")
519+
return os.path.join(bin_dir.strip().decode('utf-8'), "lit-test-helper")
523520

524521

525522
def run_lit_tests(toolchain, build_dir, release, filecheck_exec, verbose):

0 commit comments

Comments
 (0)