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

Use the improved submodule handling #42081

Merged
merged 5 commits into from
May 26, 2017

Conversation

ishitatsuyuki
Copy link
Contributor

@ishitatsuyuki ishitatsuyuki commented May 18, 2017

r? @alexcrichton

That was a crap...

Updating submodules
Traceback (most recent call last):
  File "./x.py", line 20, in <module>
    bootstrap.main()
  File "/home/ishitatsuyuki/Documents/rust/src/bootstrap/bootstrap.py", line 684, in main
    bootstrap()
  File "/home/ishitatsuyuki/Documents/rust/src/bootstrap/bootstrap.py", line 662, in bootstrap
    rb.update_submodules()
  File "/home/ishitatsuyuki/Documents/rust/src/bootstrap/bootstrap.py", line 566, in update_submodules
    path = line[1:].split(' ')[1]
TypeError: a bytes-like object is required, not 'str'

Maybe we need to confirm the compatibility of git options, such as git config or git -C (I believe they existed long before, though). This is tested locally.

@ghost
Copy link

ghost commented May 18, 2017

Just a quick feedback on that: git -C isn't that old, RHEL6 doesn't handle it for example.

@ishitatsuyuki
Copy link
Contributor Author

If possible, can you also check for any Python 2 incompatibilities?

@alexcrichton
Copy link
Member

r? @aidanhs

Mind taking a look at this? I think you know more about submodules than I

@alexcrichton alexcrichton added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 18, 2017
@kennytm
Copy link
Member

kennytm commented May 19, 2017

@ishitatsuyuki The Python 2/3 thing is the same as #42085? (fixed in #42089)

@ishitatsuyuki
Copy link
Contributor Author

I have rebased the things. This should supersede #42089, if it was possible to gain approval.

... sorry for the redundant formatting, I couldn't keep up without my auto formatter.

# submodule path
submodules = [s.split()[1] for s in subprocess.check_output(
["git", "config", "--file", os.path.join(
self.rust_root, ".gitmodules"), "--get-regexp", "path"]).splitlines()]
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately we probably do actually need to do the defaultencoding dance even here, doesn't windows sometimes use two-byte unicode encodings? Which would mean checking for b"llvm" wouldn't work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so. The command line uses the current code page, which IIRC is ASCII compat. Minding trying out that?

Copy link
Member

Choose a reason for hiding this comment

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

You are indeed correct.

That said, I feel like being consistent with the rest of the file (which uses defaultencoding) is probably worthwhile. Indeed, two reviewers of this PR have already been confused by imagined possible problems!

@bors
Copy link
Contributor

bors commented May 19, 2017

☔ The latest upstream changes (presumably #42105) made this pull request unmergeable. Please resolve the merge conflicts.

@ishitatsuyuki
Copy link
Contributor Author

Rebase made with the theirs strategy option.

submodules = [module for module in submodules
if not ((module.endswith(b"llvm") and
(self.get_toml('llvm-config') or self.get_mk('CFG_LLVM_ROOT'))) or
(module.endswith(b"jemalloc") and
Copy link
Member

Choose a reason for hiding this comment

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

I'm fairly certain that using b"..." will break Python 3 compatibility, see #42089.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

... what if I tell you that I happily ran it on my Arch laptop which has Py3?

Copy link
Member

Choose a reason for hiding this comment

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

Hm, odd. Not sure why it was changed in that PR then. Never mind me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems that the original PR decoded the pipe output which is in system default encoding, and can vary on Windows. However, I'm quite sure that all code pages are ASCII compat, which doesn't pose a problem if you're dealing with pure English paths. (want some emoji there? :P)

Copy link
Member

Choose a reason for hiding this comment

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

The original PR took didn't decode at all, which was the problem - it took a bytestring of submodules and tried split it with a string, which isn't allowed. The followup PR made sure the bytestring was converted to a string like all the other outputs from commands in the file, so now using bytestrings would be incorrect. This PR goes back to not decoding command output, so bytestrings are correct again.

@aidanhs
Copy link
Member

aidanhs commented May 20, 2017

Tested on Centos 6, r=me after moving from bytestrings to defaultencoding for consistency (if you happen to undo the autoformat diff noise at the same time then that'd also be fantastic).

@ishitatsuyuki
Copy link
Contributor Author

@aidanhs I'm not sure if getdefaultencoding() is a good idea. It's almost constant ('ascii' for 2, 'utf8' for 3), and isn't so useful for Windows.

@aidanhs
Copy link
Member

aidanhs commented May 22, 2017

My logic is simply that it's ideal if this file is consistent. Since the rest of the file uses getdefaultencoding at all entry points of text into the script and then works exclusively with unicode strings, why not do the same here? The issue with the previous PR was caused by a mixing of byte and unicode strings - making sure everything is always unicode helps avoid potential problems.

@ishitatsuyuki
Copy link
Contributor Author

Roughly tested on both Arch and CentOS 6.

@aidanhs
Copy link
Member

aidanhs commented May 22, 2017

Great! Thanks very much for bearing with me @ishitatsuyuki :)

@bors r+

@bors
Copy link
Contributor

bors commented May 22, 2017

📌 Commit d34aaa1 has been approved by aidanhs

frewsxcv added a commit to frewsxcv/rust that referenced this pull request May 23, 2017
…idanhs

Use the improved submodule handling

r? @alexcrichton

That was a crap...
```
Updating submodules
Traceback (most recent call last):
  File "./x.py", line 20, in <module>
    bootstrap.main()
  File "/home/ishitatsuyuki/Documents/rust/src/bootstrap/bootstrap.py", line 684, in main
    bootstrap()
  File "/home/ishitatsuyuki/Documents/rust/src/bootstrap/bootstrap.py", line 662, in bootstrap
    rb.update_submodules()
  File "/home/ishitatsuyuki/Documents/rust/src/bootstrap/bootstrap.py", line 566, in update_submodules
    path = line[1:].split(' ')[1]
TypeError: a bytes-like object is required, not 'str'
```

Maybe we need to confirm the compatibility of git options, such as `git config` or `git -C` (I believe they existed long before, though). This is tested locally.
@arielb1 arielb1 added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 23, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this pull request May 24, 2017
…idanhs

Use the improved submodule handling

r? @alexcrichton

That was a crap...
```
Updating submodules
Traceback (most recent call last):
  File "./x.py", line 20, in <module>
    bootstrap.main()
  File "/home/ishitatsuyuki/Documents/rust/src/bootstrap/bootstrap.py", line 684, in main
    bootstrap()
  File "/home/ishitatsuyuki/Documents/rust/src/bootstrap/bootstrap.py", line 662, in bootstrap
    rb.update_submodules()
  File "/home/ishitatsuyuki/Documents/rust/src/bootstrap/bootstrap.py", line 566, in update_submodules
    path = line[1:].split(' ')[1]
TypeError: a bytes-like object is required, not 'str'
```

Maybe we need to confirm the compatibility of git options, such as `git config` or `git -C` (I believe they existed long before, though). This is tested locally.
@bors
Copy link
Contributor

bors commented May 25, 2017

☔ The latest upstream changes (presumably #42212) made this pull request unmergeable. Please resolve the merge conflicts.

@ishitatsuyuki
Copy link
Contributor Author

Rebased. Didn't tested on CentOS yet, but I believe it should be fine. Works fine on Arch with both Python 2/3.

@ishitatsuyuki
Copy link
Contributor Author

Review please. Basically I think this is tested and reviewed enough and it's fine to r+ as I only did a rebase.

@aidanhs
Copy link
Member

aidanhs commented May 26, 2017

@bors r+

@bors
Copy link
Contributor

bors commented May 26, 2017

📌 Commit 15c26c9 has been approved by aidanhs

@bors
Copy link
Contributor

bors commented May 26, 2017

⌛ Testing commit 15c26c9 with merge 5579677...

bors added a commit that referenced this pull request May 26, 2017
Use the improved submodule handling

r? @alexcrichton

That was a crap...
```
Updating submodules
Traceback (most recent call last):
  File "./x.py", line 20, in <module>
    bootstrap.main()
  File "/home/ishitatsuyuki/Documents/rust/src/bootstrap/bootstrap.py", line 684, in main
    bootstrap()
  File "/home/ishitatsuyuki/Documents/rust/src/bootstrap/bootstrap.py", line 662, in bootstrap
    rb.update_submodules()
  File "/home/ishitatsuyuki/Documents/rust/src/bootstrap/bootstrap.py", line 566, in update_submodules
    path = line[1:].split(' ')[1]
TypeError: a bytes-like object is required, not 'str'
```

Maybe we need to confirm the compatibility of git options, such as `git config` or `git -C` (I believe they existed long before, though). This is tested locally.
@bors
Copy link
Contributor

bors commented May 26, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: aidanhs
Pushing 5579677 to master...

@bors bors merged commit 15c26c9 into rust-lang:master May 26, 2017
@ishitatsuyuki ishitatsuyuki deleted the submodule-better branch July 15, 2018 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants