Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Modify Python scripts to run on Python 2 and 3 #90

Closed
wants to merge 3 commits into from
Closed

[WIP] Modify Python scripts to run on Python 2 and 3 #90

wants to merge 3 commits into from

Conversation

alexwlchan
Copy link
Contributor

Some systems use Python 3 as their default interpreter (e.g. #83).

This is a collection of fixes that should get these scripts much closer to running on both Python 2 and 3. Obtained by running the six module over every .py file in the repo, and going through the proposed changes by hand.

There are probably still a few gotchas that will break in Python 3 – but this gets substantially closer to a fully working set.

@gribozavr gribozavr self-assigned this Dec 3, 2015
@gribozavr
Copy link
Contributor

I'll do a test build on OS X and Linux before merging. Assigning to myself.

@alexwlchan
Copy link
Contributor Author

@gribozavr Thanks; I haven’t had a chance to set up a build system yet.

@gribozavr
Copy link
Contributor

@alexwlchan Sorry, but the OS X build failed when it tried to run gyb:

[18/543] Generating UnicodeExtendedGraphemeClusters.cpp from UnicodeExtendedGraphemeClusters.cpp.gyb with ptr size = 8
...
Traceback (most recent call last):
  File "<src>/swift/utils/gyb", line 3, in <module>
    gyb.main()
  File "<src>/swift/utils/gyb.py", line 1061, in main
    ast = parseTemplate(args.file.name, args.file.read())
  File "<src>/swift/utils/gyb.py", line 930, in parseTemplate
    return Block(ParseContext(filename, text))
  File "<src>/swift/utils/gyb.py", line 586, in __init__
    self.children.append(Node(context))
  File "<src>/swift/utils/gyb.py", line 602, in __init__
    context.nextToken()
  File "<src>/swift/utils/gyb.py", line 519, in nextToken
    for kind in self.tokens:
  File "<src>/swift/utils/gyb.py", line 497, in tokenGenerator
    if codeStartsWithDedentKeyword(sourceLines):
  File "<src>/swift/utils/gyb.py", line 357, in codeStartsWithDedentKeyword
    in tokenize.generate_tokens(sourceLines.__iter__().__next__):
AttributeError: 'listiterator' object has no attribute '__next__'

@alexwlchan
Copy link
Contributor Author

@gribozavr Sorry, that’s probably not surprising. I should have tested it first. I’ll get myself a build system and keep trying. I’ll ping you when it’s done.

  • Python 2 on OS X
  • Python 3 on OS X
  • Python 2 on Ubuntu
  • Python 3 on Ubuntu

@alexwlchan alexwlchan changed the title Modify Python scripts to run on Python 2 and 3 [WIP] Modify Python scripts to run on Python 2 and 3 Dec 3, 2015
@Mitame
Copy link
Contributor

Mitame commented Dec 3, 2015

@alexwlchan: As a suggestion, you could create two gyb.py scripts (seeing as that seems to be the one failing), one with python2 modification and one with python3 modifications. Then decide which one to import and run from gyb or build-script or whichever one actually runs/imports it. It's not ideal, but i think it would be neater than having loads of inline checks deciding between next() and __next__().

@gribozavr
Copy link
Contributor

@Mitame Please don't duplicate the whole script. If we need compatibility wrappers for certain APIs, we can declare them in the script itself.

@Mitame
Copy link
Contributor

Mitame commented Dec 3, 2015

@gribozavr: I wasn't going to, it was, as i said, a suggestion.

@Mitame
Copy link
Contributor

Mitame commented Dec 3, 2015

Also, gyb.py currently fails it's own tests with these commits with python2 utils/gyb.py --test and python3 utils/gyb.py --test. Also, a possible fix might be this https://github.com/Mitame/swift/tree/python-fixeshttps://github.com/Mitame/swift/tree/python-fixes though i haven't been able to test it because none of my systems have enough RAM to finish the build... aparently 8GB+8GB swap is not enough. I also apologise for all the whitespace changes in that. My editor when kinda crazy on it, but it was only meant as a reference anyway. It still doesn't pass gyb.py --test but it might work for final build.

@alexwlchan
Copy link
Contributor Author

@Mitame I think I can do without separate scripts here. It’s a fairly small difference, and easy to fix. The only difference is the method names:

  • In Python 2, to get the next item of an iterator, you’d call foo.next().
  • In Python 3, this was helpfully renamed to foo.__next__(); see PEP 3114.

But there’s a Python builtin next(), which can be called as next(foo), and will choose the correct method to call based on your Python version.

I should have been a bit more careful when running six.

I’m running an Ubuntu build now to see if I can hit the problem above; then I’ll drop in the fix and make sure I’ve really fixed it. Then onwards – there are probably more edge cases that I’ve missed.

@Mitame
Copy link
Contributor

Mitame commented Dec 3, 2015

I was cosidering next() though i wasn't sure whether it would return the .__next__ or .next function or it's return value when run. In my commit, i just made it detect which python version was running and decide in line which method to use to make the iterator. Again, i can't test due to lack of RAM but it might work if next() doesn't work as expected.

@gribozavr
Copy link
Contributor

@Mitame For the RAM issue, please build with build-script -R in release mode, then you wouldn't be building all the debug info that causes the linker to consume a lot of RAM. Alternatively, after you hit the RAM issue, you can go into the build directory, and run ninja -j 1 to continue building in single-core mode. Once you get past the issue, continue with build-script.

@Mitame
Copy link
Contributor

Mitame commented Dec 3, 2015

@gribozavr That info would be nice in the Readme if it's not already there. Also, the issue seems to arise when it gets to the linking part. When resuming it, it has ~80 things left if that helps at all.

@Mitame
Copy link
Contributor

Mitame commented Dec 3, 2015

Traceback (most recent call last):
  File "<src>/swift/utils/gyb", line 3, in <module>
    gyb.main()
  File "<src>/swift/utils/gyb.py", line 1068, in main
    args.target.write(executeTemplate(ast, args.line_directive, **bindings))
  File "<src>/swift/utils/gyb.py", line 971, in executeTemplate
    ast.execute(executionContext)
  File "<src>/swift/utils/gyb.py", line 590, in execute
    x.execute(context)
  File "<src>/swift/utils/gyb.py", line 666, in execute
    result = eval(self.code, context.localBindings)
  File "<src>/swift/lib/Basic/UnicodeExtendedGraphemeClusters.cpp.gyb", line 22, in <module>
    from GYBUnicodeDataUtils import *
  File "<src>/swift/utils/GYBUnicodeDataUtils.py", line 532
    code_point = ('\U%(cp)08x' % { 'cp': code_point }).decode('unicode_escape')

Another error running the build in python3

RLovelett added a commit to RLovelett/swift-aur that referenced this pull request Dec 4, 2015
@alexwlchan
Copy link
Contributor Author

@dmshynk Thanks, looks good. I’ll get those merged into my branch ASAP. I’ve still broken Python 2 support in a few places, so I want to get that checked first before I squash and we get this merged.

@RLovelett
Copy link
Contributor

@alexwlchan I'm not a Python expert but I'm pretty sure this has to do with Python 3 because if I use Python 2 I don't get the error.

Anyways when I run $ swift/utils/build-script --preset=buildbot_linux_1510 installable_package=/tmp/swift.tar.gz install_destdir=/tmp/swift-install with Python 3 as the interpreter I get the following error:

Traceback (most recent call last):
  File "/home/ryan/Source/swift/src/swift/utils/build-script", line 755, in <module>
    sys.exit(main())
  File "/home/ryan/Source/swift/src/swift/utils/build-script", line 749, in main
    return main_preset()
  File "/home/ryan/Source/swift/src/swift/utils/build-script", line 77, in main_preset
    args.preset_substitutions, args.preset_file_names, args.preset)
  File "/home/ryan/Source/swift/src/swift/utils/SwiftBuildSupport.py", line 170, in get_preset_options
    config = _load_preset_files_impl(preset_file_names, substitutions)
  File "/home/ryan/Source/swift/src/swift/utils/SwiftBuildSupport.py", line 124, in _load_preset_files_impl
    if config.read(preset_file_names) == []:
  File "/usr/lib/python3.5/configparser.py", line 697, in read
    self._read(fp, filename)
  File "/usr/lib/python3.5/configparser.py", line 1064, in _read
    lineno)
configparser.DuplicateSectionError: While reading from '/home/ryan/Source/swift/src/swift/utils/build-presets.ini' [line 179]: section 'preset: buildbot,tools=RA,stdlib=DA' already exists

I know effectively nothing about Python but I will see if I can't track down what is causing this and how to fix it.

@alexwlchan
Copy link
Contributor Author

@RLovelett So this error gets raised when the parser finds the same section more than once in the config file. In this case, the section if preset: buildbot,tools=RA,stdlib=DA, which occurs on lines 56 and 179 of utils/build-presets.ini (at commit 7d3292b).

Fix is either to rearrange the config file, or run the parser in non-strict mode. I’ll try to include a fix.

@alexwlchan
Copy link
Contributor Author

(I’m quite busy this weekend, so only have sporadic moments to dig into build problems. Hoping to get passing builds on Pythons 2 and 3 by the end of next week. I think I’ve squashed most of the bugs.)

@RLovelett
Copy link
Contributor

Thanks for the pointer. I've come up with this patch:

From e25b9a954d2c0c34777a789b84f0565bf5528d6a Mon Sep 17 00:00:00 2001
From: Ryan Lovelett <ryan@lovelett.me>
Date: Sat, 5 Dec 2015 15:00:50 -0500
Subject: [PATCH 12/12] Allow parsing of old style on Python 3

---
 utils/SwiftBuildSupport.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utils/SwiftBuildSupport.py b/utils/SwiftBuildSupport.py
index 5631d3b..7048924 100644
--- a/utils/SwiftBuildSupport.py
+++ b/utils/SwiftBuildSupport.py
@@ -120,7 +120,7 @@ def check_output(args, print_command=False, verbose=False):


 def _load_preset_files_impl(preset_file_names, substitutions={}):
-    config = ConfigParser.SafeConfigParser(substitutions, allow_no_value=True)
+    config = ConfigParser.SafeConfigParser(substitutions, allow_no_value=True, strict=False)
     if config.read(preset_file_names) == []:
         print_with_argv0(
             "preset file not found (tried " + str(preset_file_names) + ")")
--
2.6.3

Unfortunately, it doesn't work on Python 2 (it fails with TypeError: __init__() got an unexpected keyword argument 'strict') and I know nothing of Python to even begin to know what the most idiomatic way of conditionally applying based on the version.

@RLovelett
Copy link
Contributor

@alexwlchan I've actually found another approach which was just to stream line the section declarations. I've submitted a stand-alone patch, #248, because it should be able to work on both 2 and 3. In case, it were to be merged before this one.

@alexwlchan
Copy link
Contributor Author

I've spent a bit more time looking at this. Still failing on Python 3, at these few lines in GYBUnicodeDataUtils.py:

code_point = 0x200b
code_point = ('\U%(cp)08x' % { 'cp': code_point }).decode('unicode_escape')
as_UTF8_bytes = code_point.encode('utf8')
as_UTF8_escaped = ''.join(['\\x%(byte)02x' % { 'byte': ord(byte) } for byte in as_UTF8_bytes])

Specifically, I'm struggling to come up with an implementation that produces identical results on
Python 2 and Python 3.

I'll continue to chip away at this, but any suggestions gratefully appreciated.

I've also rebased against the latest master to keep up with the latest fixes.


@dmshynk - I can't get your proposed patch for this to work. I get this error:

Python 3.4.3+ (default, Oct 14 2015, 16:03:50)
[GCC 5.2.1 20151010] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> code_point=0x200b
>>> code_point = (b'\U{cp}08x'.format(cp=code_point)).decode('unicode_escape')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'bytes' object has no attribute 'format'

Any ideas?

@alexwlchan
Copy link
Contributor Author

Rebased to resolve merge conflicts.

@gribozavr
Copy link
Contributor

@alexwlchan I'm getting two test failures on OS X:

FAIL: Swift :: stdlib/Set.swift (7302 of 7672)
******************** TEST 'Swift :: stdlib/Set.swift' FAILED ********************
Script:
--
rm -rf <src>/build/Ninja-ReleaseAssert/swift-macosx-x86_64/validation-test-macosx-x86_64/stdlib/Output/Set.swift.tmp
mkdir -p <src>/build/Ninja-ReleaseAssert/swift-macosx-x86_64/validation-test-macosx-x86_64/stdlib/Output/Set.swift.tmp
<src>/swift/validation-test/stdlib/../../utils/gyb <src>/swift/validation-test/stdlib/Set.swift -o <src>/build/Ninja-ReleaseAssert/swift-macosx-x86_64/validation-test-macosx-x86_64/stdlib/Output/Set.swift.tmp/main.swift
xcrun --toolchain XcodeDefault --sdk macosx  clang++ -arch x86_64 -mmacosx-version-min=10.9 -fmodules-cache-path='/var/folders/ts/nf0skrh1301drfvsp44xvrbm0000gn/T/swift-testsuite-clang-module-cacheBTSzbK' -fobjc-arc <src>/swift/validation-test/stdlib/Inputs/SlurpFastEnumeration/SlurpFastEnumeration.m -c -o <src>/build/Ninja-ReleaseAssert/swift-macosx-x86_64/validation-test-macosx-x86_64/stdlib/Output/Set.swift.tmp/SlurpFastEnumeration.o
<src>/swift/validation-test/stdlib/../../utils/line-directive <src>/build/Ninja-ReleaseAssert/swift-macosx-x86_64/validation-test-macosx-x86_64/stdlib/Output/Set.swift.tmp/main.swift -- xcrun --toolchain XcodeDefault --sdk macosx  <src>/build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swiftc -target x86_64-apple-macosx10.9  -module-cache-path '/var/folders/ts/nf0skrh1301drfvsp44xvrbm0000gn/T/swift-testsuite-clang-module-cacheBTSzbK' -F /Applications/Xcode7.2/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/../../../Developer/Library/Frameworks -Xlinker -rpath -Xlinker /Applications/Xcode7.2/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/../../../Developer/Library/Frameworks    <src>/swift/validation-test/stdlib/Inputs/DictionaryKeyValueTypes.swift <src>/build/Ninja-ReleaseAssert/swift-macosx-x86_64/validation-test-macosx-x86_64/stdlib/Output/Set.swift.tmp/main.swift -I <src>/swift/validation-test/stdlib/Inputs/SlurpFastEnumeration/ -Xlinker <src>/build/Ninja-ReleaseAssert/swift-macosx-x86_64/validation-test-macosx-x86_64/stdlib/Output/Set.swift.tmp/SlurpFastEnumeration.o -o <src>/build/Ninja-ReleaseAssert/swift-macosx-x86_64/validation-test-macosx-x86_64/stdlib/Output/Set.swift.tmp/Set -Xfrontend -disable-access-control
<src>/swift/validation-test/stdlib/../../utils/line-directive <src>/build/Ninja-ReleaseAssert/swift-macosx-x86_64/validation-test-macosx-x86_64/stdlib/Output/Set.swift.tmp/main.swift --  <src>/build/Ninja-ReleaseAssert/swift-macosx-x86_64/validation-test-macosx-x86_64/stdlib/Output/Set.swift.tmp/Set
--
Exit Code: 1

Command Output (stdout):
--
<src>/swift/validation-test/stdlib/Inputs/DictionaryKeyValueTypes.swift:618:40: warning: closure parameter prior to parameters with default arguments will not be treated as a trailing closure
  a: NSArray, _ fe: NSFastEnumeration, _ sink: (AnyObject) -> Void,
                                       ^
<src>/swift/validation-test/stdlib/Inputs/DictionaryKeyValueTypes.swift:660:45: warning: closure parameter prior to parameters with default arguments will not be treated as a trailing closure
  d: NSDictionary, _ fe: NSFastEnumeration, _ sink: (AnyObjectTuple2) -> Void,
                                            ^
<src>/swift/validation-test/stdlib/Inputs/DictionaryKeyValueTypes.swift:980:38: warning: closure parameter prior to parameters with default arguments will not be treated as a trailing closure
  s: NSSet, _ fe: NSFastEnumeration, _ sink: (AnyObject) -> Void,
                                     ^
[ RUN      ] Set.sizeof
[       OK ] Set.sizeof
[ RUN      ] Set.COW.Smoke
[       OK ] Set.COW.Smoke
[ RUN      ] Set.COW.Fast.IndexesDontAffectUniquenessCheck
[       OK ] Set.COW.Fast.IndexesDontAffectUniquenessCheck
[ RUN      ] Set.COW.Slow.IndexesDontAffectUniquenessCheck
[       OK ] Set.COW.Slow.IndexesDontAffectUniquenessCheck
[ RUN      ] Set.COW.Fast.SubscriptWithIndexDoesNotReallocate
[       OK ] Set.COW.Fast.SubscriptWithIndexDoesNotReallocate
[ RUN      ] Set.COW.Slow.SubscriptWithIndexDoesNotReallocate
[       OK ] Set.COW.Slow.SubscriptWithIndexDoesNotReallocate
[ RUN      ] Set.COW.Fast.ContainsDoesNotReallocate
[       OK ] Set.COW.Fast.ContainsDoesNotReallocate
[ RUN      ] Set.COW.Slow.ContainsDoesNotReallocate
[       OK ] Set.COW.Slow.ContainsDoesNotReallocate
[ RUN      ] Set.COW.Fast.InsertDoesNotReallocate
[       OK ] Set.COW.Fast.InsertDoesNotReallocate
[ RUN      ] Set.COW.Slow.InsertDoesNotReallocate
[       OK ] Set.COW.Slow.InsertDoesNotReallocate
[ RUN      ] Set.COW.Fast.IndexForMemberDoesNotReallocate
[       OK ] Set.COW.Fast.IndexForMemberDoesNotReallocate
[ RUN      ] Set.COW.Slow.IndexForMemberDoesNotReallocate
[       OK ] Set.COW.Slow.IndexForMemberDoesNotReallocate
[ RUN      ] Set.COW.Fast.RemoveAtIndexDoesNotReallocate
[       OK ] Set.COW.Fast.RemoveAtIndexDoesNotReallocate
[ RUN      ] Set.COW.Slow.RemoveAtIndexDoesNotReallocate
[       OK ] Set.COW.Slow.RemoveAtIndexDoesNotReallocate
[ RUN      ] Set.COW.Fast.RemoveDoesNotReallocate
[       OK ] Set.COW.Fast.RemoveDoesNotReallocate
[ RUN      ] Set.COW.Slow.RemoveDoesNotReallocate
[       OK ] Set.COW.Slow.RemoveDoesNotReallocate
[ RUN      ] Set.COW.Fast.UnionInPlaceSmallSetDoesNotReallocate
[       OK ] Set.COW.Fast.UnionInPlaceSmallSetDoesNotReallocate
[ RUN      ] Set.COW.Fast.RemoveAllDoesNotReallocate
[       OK ] Set.COW.Fast.RemoveAllDoesNotReallocate
[ RUN      ] Set.COW.Slow.RemoveAllDoesNotReallocate
[       OK ] Set.COW.Slow.RemoveAllDoesNotReallocate
[ RUN      ] Set.COW.Fast.FirstDoesNotReallocate
[       OK ] Set.COW.Fast.FirstDoesNotReallocate
[ RUN      ] Set.COW.Fast.CountDoesNotReallocate
[       OK ] Set.COW.Fast.CountDoesNotReallocate
[ RUN      ] Set.COW.Slow.FirstDoesNotReallocate
[       OK ] Set.COW.Slow.FirstDoesNotReallocate
[ RUN      ] Set.COW.Slow.CountDoesNotReallocate
[       OK ] Set.COW.Slow.CountDoesNotReallocate
[ RUN      ] Set.COW.Fast.GenerateDoesNotReallocate
[       OK ] Set.COW.Fast.GenerateDoesNotReallocate
[ RUN      ] Set.COW.Slow.GenerateDoesNotReallocate
[       OK ] Set.COW.Slow.GenerateDoesNotReallocate
[ RUN      ] Set.COW.Fast.EqualityTestDoesNotReallocate
[       OK ] Set.COW.Fast.EqualityTestDoesNotReallocate
[ RUN      ] Set.COW.Slow.EqualityTestDoesNotReallocate
[       OK ] Set.COW.Slow.EqualityTestDoesNotReallocate
[ RUN      ] Set.deleteChainCollision
[       OK ] Set.deleteChainCollision
[ RUN      ] Set.deleteChainNoCollision
[       OK ] Set.deleteChainNoCollision
[ RUN      ] Set.deleteChainCollision2
[       OK ] Set.deleteChainCollision2
[ RUN      ] Set.deleteChainCollisionRandomized
out>>> time is 1450014840
out>>> chose parameters: collisionChains=6 chainLength=0
[       OK ] Set.deleteChainCollisionRandomized
[ RUN      ] Set.BridgedFromObjC.Verbatim.SetIsCopied
[       OK ] Set.BridgedFromObjC.Verbatim.SetIsCopied
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.SetIsCopied
[       OK ] Set.BridgedFromObjC.Nonverbatim.SetIsCopied
[ RUN      ] Set.BridgedFromObjC.Verbatim.NSSetIsRetained
[       OK ] Set.BridgedFromObjC.Verbatim.NSSetIsRetained
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.NSSetIsCopied
[       OK ] Set.BridgedFromObjC.Nonverbatim.NSSetIsCopied
[ RUN      ] Set.BridgedFromObjC.Verbatim.ImmutableSetIsRetained
[       OK ] Set.BridgedFromObjC.Verbatim.ImmutableSetIsRetained
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.ImmutableSetIsCopied
[       OK ] Set.BridgedFromObjC.Nonverbatim.ImmutableSetIsCopied
[ RUN      ] Set.BridgedFromObjC.Verbatim.IndexForMember
[       OK ] Set.BridgedFromObjC.Verbatim.IndexForMember
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.IndexForMember
[       OK ] Set.BridgedFromObjC.Nonverbatim.IndexForMember
[ RUN      ] Set.BridgedFromObjC.Verbatim.Insert
[       OK ] Set.BridgedFromObjC.Verbatim.Insert
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.Insert
[       OK ] Set.BridgedFromObjC.Nonverbatim.Insert
[ RUN      ] Set.BridgedFromObjC.Verbatim.SubscriptWithIndex
[       OK ] Set.BridgedFromObjC.Verbatim.SubscriptWithIndex
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.SubscriptWithIndex
[       OK ] Set.BridgedFromObjC.Nonverbatim.SubscriptWithIndex
[ RUN      ] Set.BridgedFromObjC.Verbatim.SubscriptWithIndex_Empty
[       OK ] Set.BridgedFromObjC.Verbatim.SubscriptWithIndex_Empty
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.SubscriptWithIndex_Empty
[       OK ] Set.BridgedFromObjC.Nonverbatim.SubscriptWithIndex_Empty
[ RUN      ] Set.BridgedFromObjC.Verbatim.Contains
[       OK ] Set.BridgedFromObjC.Verbatim.Contains
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.Contains
[       OK ] Set.BridgedFromObjC.Nonverbatim.Contains
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.SubscriptWithMember
[       OK ] Set.BridgedFromObjC.Nonverbatim.SubscriptWithMember
[ RUN      ] Set.BridgedFromObjC.Verbatim.RemoveAtIndex
[       OK ] Set.BridgedFromObjC.Verbatim.RemoveAtIndex
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.RemoveAtIndex
[       OK ] Set.BridgedFromObjC.Nonverbatim.RemoveAtIndex
[ RUN      ] Set.BridgedFromObjC.Verbatim.Remove
[       OK ] Set.BridgedFromObjC.Verbatim.Remove
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.Remove
[       OK ] Set.BridgedFromObjC.Nonverbatim.Remove
[ RUN      ] Set.BridgedFromObjC.Verbatim.RemoveAll
[       OK ] Set.BridgedFromObjC.Verbatim.RemoveAll
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.RemoveAll
[       OK ] Set.BridgedFromObjC.Nonverbatim.RemoveAll
[ RUN      ] Set.BridgedFromObjC.Verbatim.Count
[       OK ] Set.BridgedFromObjC.Verbatim.Count
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.Count
[       OK ] Set.BridgedFromObjC.Nonverbatim.Count
[ RUN      ] Set.BridgedFromObjC.Verbatim.Generate
[       OK ] Set.BridgedFromObjC.Verbatim.Generate
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.Generate
[       OK ] Set.BridgedFromObjC.Nonverbatim.Generate
[ RUN      ] Set.BridgedFromObjC.Verbatim.Generate_Empty
[       OK ] Set.BridgedFromObjC.Verbatim.Generate_Empty
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.Generate_Empty
[       OK ] Set.BridgedFromObjC.Nonverbatim.Generate_Empty
[ RUN      ] Set.BridgedFromObjC.Verbatim.Generate_Huge
[       OK ] Set.BridgedFromObjC.Verbatim.Generate_Huge
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.Generate_Huge
[       OK ] Set.BridgedFromObjC.Nonverbatim.Generate_Huge
[ RUN      ] Set.BridgedFromObjC.Verbatim.EqualityTest_Empty
[       OK ] Set.BridgedFromObjC.Verbatim.EqualityTest_Empty
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.EqualityTest_Empty
[       OK ] Set.BridgedFromObjC.Nonverbatim.EqualityTest_Empty
[ RUN      ] Set.BridgedFromObjC.Verbatim.EqualityTest_Small
[       OK ] Set.BridgedFromObjC.Verbatim.EqualityTest_Small
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.EqualityTest_Small
[       OK ] Set.BridgedFromObjC.Nonverbatim.EqualityTest_Small
[ RUN      ] Set.BridgedFromObjC.Verbatim.ArrayOfSets
[       OK ] Set.BridgedFromObjC.Verbatim.ArrayOfSets
[ RUN      ] Set.BridgedFromObjC.Nonverbatim.ArrayOfSets
[       OK ] Set.BridgedFromObjC.Nonverbatim.ArrayOfSets
[ RUN      ] Set.BridgedToObjC.Verbatim.Count
[       OK ] Set.BridgedToObjC.Verbatim.Count
[ RUN      ] Set.BridgedToObjC.Verbatim.Contains
[       OK ] Set.BridgedToObjC.Verbatim.Contains
[ RUN      ] Set.BridgingRoundtrip
[       OK ] Set.BridgingRoundtrip
[ RUN      ] Set.BridgedToObjC.Verbatim.ObjectEnumerator.FastEnumeration.UseFromSwift
[       OK ] Set.BridgedToObjC.Verbatim.ObjectEnumerator.FastEnumeration.UseFromSwift
[ RUN      ] Set.BridgedToObjC.Verbatim.ObjectEnumerator.FastEnumeration.UseFromObjC
[       OK ] Set.BridgedToObjC.Verbatim.ObjectEnumerator.FastEnumeration.UseFromObjC
[ RUN      ] Set.BridgedToObjC.Verbatim.ObjectEnumerator.FastEnumeration_Empty
[       OK ] Set.BridgedToObjC.Verbatim.ObjectEnumerator.FastEnumeration_Empty
[ RUN      ] Set.BridgedToObjC.Custom.ObjectEnumerator.FastEnumeration.UseFromObjC
[       OK ] Set.BridgedToObjC.Custom.ObjectEnumerator.FastEnumeration.UseFromObjC
[ RUN      ] Set.BridgedToObjC.Custom.ObjectEnumerator.FastEnumeration.UseFromSwift
[       OK ] Set.BridgedToObjC.Custom.ObjectEnumerator.FastEnumeration.UseFromSwift
[ RUN      ] Set.BridgedToObjC.Verbatim.FastEnumeration.UseFromSwift
[       OK ] Set.BridgedToObjC.Verbatim.FastEnumeration.UseFromSwift
[ RUN      ] Set.BridgedToObjC.Verbatim.FastEnumeration.UseFromObjC
[       OK ] Set.BridgedToObjC.Verbatim.FastEnumeration.UseFromObjC
[ RUN      ] Set.BridgedToObjC.Verbatim.FastEnumeration_Empty
[       OK ] Set.BridgedToObjC.Verbatim.FastEnumeration_Empty
[ RUN      ] Set.BridgedToObjC.Custom.FastEnumeration.UseFromSwift
[       OK ] Set.BridgedToObjC.Custom.FastEnumeration.UseFromSwift
[ RUN      ] Set.BridgedToObjC.Custom.FastEnumeration.UseFromObjC
[       OK ] Set.BridgedToObjC.Custom.FastEnumeration.UseFromObjC
[ RUN      ] Set.BridgedToObjC.Custom.FastEnumeration_Empty
[       OK ] Set.BridgedToObjC.Custom.FastEnumeration_Empty
[ RUN      ] Set.BridgedToObjC.Count
[       OK ] Set.BridgedToObjC.Count
[ RUN      ] Set.BridgedToObjC.ObjectEnumerator.NextObject
[       OK ] Set.BridgedToObjC.ObjectEnumerator.NextObject
[ RUN      ] Set.BridgedToObjC.ObjectEnumerator.NextObject.Empty
[       OK ] Set.BridgedToObjC.ObjectEnumerator.NextObject.Empty
[ RUN      ] Set.BridgedToObjC.MemberTypesCustomBridged
[       OK ] Set.BridgedToObjC.MemberTypesCustomBridged
[ RUN      ] Set.BridgingRoundTrip
[       OK ] Set.BridgingRoundTrip
[ RUN      ] Set.NSSetToSetConversion
[       OK ] Set.NSSetToSetConversion
[ RUN      ] Set.SetToNSSetConversion
[       OK ] Set.SetToNSSetConversion
[ RUN      ] Set.SetUpcastEntryPoint
[       OK ] Set.SetUpcastEntryPoint
[ RUN      ] Set.SetUpcast
[       OK ] Set.SetUpcast
[ RUN      ] Set.SetUpcastBridgedEntryPoint
[       OK ] Set.SetUpcastBridgedEntryPoint
[ RUN      ] Set.SetUpcastBridged
[       OK ] Set.SetUpcastBridged
[ RUN      ] Set.SetDowncastEntryPoint
[       OK ] Set.SetDowncastEntryPoint
[ RUN      ] Set.SetDowncast
[       OK ] Set.SetDowncast
[ RUN      ] Set.SetDowncastConditionalEntryPoint
[       OK ] Set.SetDowncastConditionalEntryPoint
[ RUN      ] Set.SetDowncastConditional
[       OK ] Set.SetDowncastConditional
[ RUN      ] Set.SetBridgeFromObjectiveCEntryPoint
[       OK ] Set.SetBridgeFromObjectiveCEntryPoint
[ RUN      ] Set.SetBridgeFromObjectiveC
[       OK ] Set.SetBridgeFromObjectiveC
[ RUN      ] Set.SetBridgeFromObjectiveCConditionalEntryPoint
[       OK ] Set.SetBridgeFromObjectiveCConditionalEntryPoint
[ RUN      ] Set.SetBridgeFromObjectiveCConditional
[       OK ] Set.SetBridgeFromObjectiveCConditional
[ RUN      ] Set.init(SequenceType:)
[       OK ] Set.init(SequenceType:)
[ RUN      ] Set.init(arrayLiteral:)
[       OK ] Set.init(arrayLiteral:)
[ RUN      ] Set.isSubsetOf.Set.Set
[       OK ] Set.isSubsetOf.Set.Set

--
Command Output (stderr):
--
Traceback (most recent call last):
  File "<src>/swift/validation-test/stdlib/../../utils/line-directive", line 86, in <module>
    run()
  File "<src>/swift/validation-test/stdlib/../../utils/line-directive", line 69, in run
    line = command.stdout.readline().decode()
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 17: ordinal not in range(128)

--

********************
FAIL: Swift :: stdlib/UnicodeTrieGenerator.gyb (7380 of 7672)
******************** TEST 'Swift :: stdlib/UnicodeTrieGenerator.gyb' FAILED ********************
Script:
--
rm -rf <src>/build/Ninja-ReleaseAssert/swift-macosx-x86_64/validation-test-macosx-x86_64/stdlib/Output/UnicodeTrieGenerator.gyb.tmp && mkdir -p <src>/build/Ninja-ReleaseAssert/swift-macosx-x86_64/validation-test-macosx-x86_64/stdlib/Output/UnicodeTrieGenerator.gyb.tmp && <src>/swift/validation-test/stdlib/../../utils/gyb <src>/swift/validation-test/stdlib/UnicodeTrieGenerator.gyb | FileCheck <src>/swift/validation-test/stdlib/UnicodeTrieGenerator.gyb
--
Exit Code: 2

Command Output (stderr):
--
Traceback (most recent call last):
  File "<src>/swift/validation-test/stdlib/../../utils/gyb", line 3, in <module>
    gyb.main()
  File "<src>/swift/utils/gyb.py", line 1074, in main
    ast = parseTemplate(args.file.name, args.file.read())
  File "<src>/swift/utils/gyb.py", line 943, in parseTemplate
    return Block(ParseContext(filename, text))
  File "<src>/swift/utils/gyb.py", line 599, in __init__
    self.children.append(Node(context))
  File "<src>/swift/utils/gyb.py", line 671, in __init__
    self.code = compile(source, context.filename, evalExec)
  File "<src>/swift/validation-test/stdlib/UnicodeTrieGenerator.gyb", line 56
    print 'PerfectlyCompressableProperty'
                                        ^
SyntaxError: invalid syntax
FileCheck error: '-' is empty.

--

@modocache
Copy link
Contributor

This is great work! Thanks!! 💯

Would it make sense to split this pull request up? It would be easier to review and merge the changes if they were made in smaller chunks.

Similar changes also need to be applied to utils/cmpcodesize.

@@ -61,7 +61,7 @@ def __init__(self, obj):
self._obj = conf.lib.sourcekitd_request_dictionary_create(
POINTER(c_void_p)(), POINTER(c_void_p)(), 0)
self._as_parameter_ = self._obj
for k,v in obj.iteritems():
for k,v in obj.items():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Splitting hairs, but: you put a space in between k,v in your changes to utils/GYBUnicodeDataUtils.py. Why not place a space in between these two as well, to promote consistency?

@alexwlchan
Copy link
Contributor Author

@modocache Indeed, it’s become a bit unwieldy, and I‘ve let my fork fall behind. Rather than try to tidy this up, I’m going to break it up into smaller PRs and refer back to this one.

@gribozavr
Copy link
Contributor

@alexwlchan Would you mind resolving the conflicts and squashing into one commit?

Python 3 made a number of changes to dicts and map/range/filter to be
more efficient -- rather than returning a list, by default they use a
memory-efficient iterator.  This meant some methods were renamed, and
sometimes we really do need a list.

This commit (i) gets all the method names right and (ii) adds explicit
casting to lists in cases where it really is needed.
@alexwlchan
Copy link
Contributor Author

@gribozavr Rebased against master and tidied up the commit history, so hopefully it’s a bit easier to review now. Pretty sure it’s still broken on Python 3 – I think there are some string subtleties that the automated conversion tools won’t pick up – but I think this time it should still be working on Python 2.

I don’t have time to do a test right now; I’ll try to do one later.

@gribozavr
Copy link
Contributor

@akyrtzi How do I test tools/SourceKit/bindings/python/sourcekitd/capi.py ?

@gribozavr
Copy link
Contributor

@alexwlchan I have been reviewing your patch, and I think that in order to make progress it would be better to handle it slightly differently.

For example, I don't know how to test all Python scripts (like the SourceKit Python bindings). The easiest thing to do would be to split the pull request into multiple:

  • The first PR would update the Python scripts that are on the critical path to get build-script -RT passing.
  • Other pull requests update the rest of the Python scripts, one PR per script.

It would be really easy to review and test the first PR because all scripts are exercised during the build. Other PRs will be reviewed in a distributed fashion by the people who wrote them or use them, so they should be able to verify that the change does not break them.

I'm sorry for the back-and-forth here, but I'm concerned about breaking scripts that I don't use or even don't know how to use.

@alexwlchan
Copy link
Contributor Author

@gribozavr That sounds sensible. I’m going to close this PR, and then reopen other PRs as you suggest. I didn’t realise quite how large a change this would be when I started.

@alexwlchan alexwlchan closed this Dec 20, 2015
@gribozavr
Copy link
Contributor

Thanks @alexwlchan!

@akyrtzi
Copy link
Contributor

akyrtzi commented Dec 23, 2015

@akyrtzi How do I test tools/SourceKit/bindings/python/sourcekitd/capi.py ?
@gribozavr This was experimental, it has no tests and no-one depends on it AFAIK. I'm not sure it still works. If someone wants to enhance it I recommend using python nose tests, like the libclang python tests: http://llvm.org/svn/llvm-project/cfe/trunk/bindings/python/tests/cindex/

@modocache
Copy link
Contributor

Thanks, @akyrtzi, good to know!

DougGregor added a commit to DougGregor/swift that referenced this pull request Apr 20, 2017
…swiftlang#90, swiftlang#91.

Address ABI FIXME swiftlang#68 by using same-type constraints directly on an
associated type to describe the requirements on the Indices associated
type of the Collection protocol. ABI FIXMEs swiftlang#89, swiftlang#90, swiftlang#91 are all in
StdlibUnittest, and provoke warnings once swiftlang#68 is fixed, but it's nice
to clear them out.

Fixes SR-2121.
dabelknap pushed a commit to dabelknap/swift that referenced this pull request Aug 2, 2018
dabelknap pushed a commit to dabelknap/swift that referenced this pull request Sep 17, 2018
maldahleh pushed a commit to maldahleh/swift that referenced this pull request Oct 26, 2020
freak4pc pushed a commit to freak4pc/swift that referenced this pull request Sep 28, 2022
…precommitcheck

Rename check to project_precommit_check.
freak4pc pushed a commit to freak4pc/swift that referenced this pull request Sep 28, 2022
DougGregor pushed a commit to DougGregor/swift that referenced this pull request Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants