Skip to content

Comments

Fix various formatting bugs in errors#1998

Merged
slozier merged 6 commits intoIronLanguages:mainfrom
slozier:errors_format
Feb 22, 2026
Merged

Fix various formatting bugs in errors#1998
slozier merged 6 commits intoIronLanguages:mainfrom
slozier:errors_format

Conversation

@slozier
Copy link
Contributor

@slozier slozier commented Feb 20, 2026

The PythonOps.*Error methods were all passing their arguments to string.Format which can result in string.Format raising an exception based on user inputs.

For example, the following all fail with the wrong exception:

ImportError(**{"{0}": 1})
int("{0}")
System.DayOfWeek["{0}"]

Changes:

  • Fixed some invalid format/args combinations.
  • Turn on analyzers that detect invalid string formatting when using the PythonOps methods.
  • Adds internal overloads taking a single message argument which avoids the call to string.Format. Note that the overloads are internal to avoid breaking some typeof(PythonOps).GetMethod calls.<
  • Deprecate WindowsError and IOError in favour of using OSError directly.

@slozier slozier merged commit 2cd61c5 into IronLanguages:main Feb 22, 2026
37 of 38 checks passed
@slozier slozier deleted the errors_format branch February 22, 2026 02:28
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.

1 participant