22// The .NET Foundation licenses this file to you under the Apache 2.0 License.
33// See the LICENSE file in the project root for more information.
44
5+ #nullable enable
6+
57using System ;
68using System . Collections . Generic ;
79using System . Diagnostics ;
@@ -102,7 +104,7 @@ private static PythonSignalState MakePosixSignalState(PythonContext context) {
102104
103105The default handler for SIGINT installed by Python.
104106It raises KeyboardInterrupt." ) ]
105- public static object default_int_handlerImpl ( int signalnum , TraceBackFrame frame ) {
107+ public static object default_int_handlerImpl ( int signalnum , TraceBackFrame ? frame ) {
106108 throw new KeyboardInterruptException ( "" ) ;
107109 }
108110
@@ -113,12 +115,12 @@ public static object default_int_handlerImpl(int signalnum, TraceBackFrame frame
113115SIG_DFL -- if the default action for the signal is in effect
114116None -- if an unknown handler is in effect
115117anything else -- the callable Python object used as a handler" ) ]
116- public static object getsignal ( CodeContext /*!*/ context , int signalnum ) {
118+ public static object ? getsignal ( CodeContext /*!*/ context , int signalnum ) {
117119 lock ( GetPythonSignalState ( context ) . PySignalToPyHandler ) {
118120 //Negative Scenarios
119121 if ( signalnum < 1 || signalnum > 22 ) {
120122 throw PythonOps . ValueError ( "signal number out of range" ) ;
121- } else if ( GetPythonSignalState ( context ) . PySignalToPyHandler . TryGetValue ( signalnum , out object value ) ) {
123+ } else if ( GetPythonSignalState ( context ) . PySignalToPyHandler . TryGetValue ( signalnum , out object ? value ) ) {
122124 //Default
123125 return value ;
124126 } else {
@@ -138,7 +140,7 @@ public static object getsignal(CodeContext/*!*/ context, int signalnum) {
138140*** IMPORTANT NOTICE ***
139141A signal handler function is called with two arguments:
140142the first is the signal number, the second is the interrupted stack frame." ) ]
141- public static object signal ( CodeContext /*!*/ context , int sig , object action ) {
143+ public static object ? signal ( CodeContext /*!*/ context , int sig , object ? action ) {
142144 //Negative scenarios - sig
143145 if ( sig < 1 || sig >= NSIG ) {
144146 throw PythonOps . ValueError ( "signal number out of range" ) ;
@@ -157,7 +159,7 @@ public static object signal(CodeContext/*!*/ context, int sig, object action) {
157159 //no-op
158160 } else {
159161 //Must match the signature of PySignalHandler
160- PythonFunction result = action as PythonFunction ;
162+ PythonFunction ? result = action as PythonFunction ;
161163 if ( result == null ) {
162164 //It could still be something like a type that implements __call__
163165 if ( ! PythonOps . IsCallable ( context , action ) ) {
@@ -166,7 +168,7 @@ public static object signal(CodeContext/*!*/ context, int sig, object action) {
166168 }
167169 }
168170
169- object last_handler = null ;
171+ object ? last_handler = null ;
170172 lock ( GetPythonSignalState ( context ) . PySignalToPyHandler ) {
171173 //CPython returns the previous handler for the signal
172174 last_handler = getsignal ( context , sig ) ;
@@ -225,7 +227,7 @@ public PythonSignalState(PythonContext pc) {
225227 private static readonly int [ ] _PySupportedSignals = { SIGABRT , SIGBREAK , SIGFPE , SIGILL , SIGINT , SIGSEGV , SIGTERM , 6 } ;
226228
227229 //Signature of Python functions that signal.signal(...) expects to be given
228- private delegate object PySignalHandler ( int signalnum , TraceBackFrame frame ) ;
230+ private delegate object PySignalHandler ( int signalnum , TraceBackFrame ? frame ) ;
229231 }
230232}
231233
0 commit comments