Closed TwoUnderscorez closed 2 years ago
@slozier Is that better?
@slozier Sorry, I don't quite understand how this is a breaking change. If you would point me in the right direction I might be able to make it a non-breaking change.
@TwoUnderscorez I meant having ConsoleInputStream.Instance
go from a field to a property is technically a binary breaking change (for example if assembly A uses a field from assembly B and you replace B with B' which contains a property instead, then A is broken). I don't think I'm really worried about breaking anyone with this particular scenario since the only consumer is in the same assembly - but it is a public type so it's not impossible...
An alternative approach would be to leave ConsoleInputStream.Instance
as a field and change the constructor to not throw:
private ConsoleInputStream() {
try {
_input = Console.OpenStandardInput();
} catch (PlatformNotSupportedException) {
_input = Stream.Null;
}
}
@slozier I could do that, but I would have to leave the catch block in ShareIO.InitializeInput
because
_inputEncoding = Console.InputEncoding;
_inputReader = Console.In;
also throw PlatformNotSupportedException
(maybe only one of them), which I personally think is kind of ugly. Would you like me to do what you've suggested or merge as is currently?
@TwoUnderscorez I think the PNSE try/catch you have in InitializeInput
is fine, but I'd change the ConsoleInputStream
to what I suggested instead.
Thanks for the PR!
When trying to use IronPython3 from a Blazor web-assembly application,
Microsoft.Scripting.Runtime.SharedIO
throws an exception when trying to setupstdin
, which is understandable, because there is none.All I did is catch the exception and set the stream to
Stream.Null
.