Skip to content

Commit 743ff73

Browse files
committed
Rollup merge of rust-lang#45117 - johnthagen:fix-str-raise, r=alexcrichton
Fix raising a bare str as an exception in configure.py Raising a bare `str` has been [deprecated since Python 2.5](https://docs.python.org/2/whatsnew/2.5.html#pep-352-exceptions-as-new-style-classes). On Python 2.7 it produces the following error: ``` TypeError: exceptions must be old-style classes or derived from BaseException, not str ``` For maximum compatibility with Python 2.7 and 3.x, we wrap the error message in `RuntimeError` which derives from `Exception`.
2 parents 4c99211 + dee517a commit 743ff73

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/bootstrap/configure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def to_toml(value):
360360
elif isinstance(value, str):
361361
return "'" + value + "'"
362362
else:
363-
raise 'no toml'
363+
raise RuntimeError('no toml')
364364

365365
def configure_section(lines, config):
366366
for key in config:

0 commit comments

Comments
 (0)