Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita19c780

Browse files
committed
Fix host splitting
The second parameter to `str.split()` is the maximum number of splitsto do, which means the list will have at most that many plus oneelements.For strings which have more than 2 dots this causes an unintendedValueError.For example:```>>> host, vdc, _ = 'host-1.vdc.env'.split('.', 3)>>> host, vdc, _ = 'host-1.vdc.env.computers.gov.uk'.split('.', 3)Traceback (most recent call last): File "<stdin>", line 1, in <module>ValueError: too many values to unpack>>> host, vdc, _ = 'host-1.vdc.env.computers.gov.uk'.split('.', 2)```
1 parent58ca6cb commita19c780

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎fabfile.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def fetch(self):
9696

9797
forhostinself.hosts:
9898
try:
99-
name,vdc,_=host.split('.',3)
99+
name,vdc,_=host.split('.',2)
100100
exceptValueError:
101101
warn("discarding badly formatted hostname '{0}'".format(host))
102102
continue

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp