@@ -145,9 +145,18 @@ def freeze_support(self):
145145 '''Check whether this is a fake forked process in a frozen executable.
146146 If so then run code specified by commandline and exit.
147147 '''
148- if self .get_start_method () == 'spawn' and getattr (sys , 'frozen' , False ):
149- from .spawn import freeze_support
150- freeze_support ()
148+ if not getattr (sys , 'frozen' , False ):
149+ return
150+
151+ # GH-135726: allow_none=True prevents this "get" call from setting the
152+ # default context as the selected one as a side-effect.
153+ method = self .get_start_method (allow_none = True ) \
154+ or _default_context .get_start_method (allow_none = True )
155+ if method != "spawn" :
156+ return
157+
158+ from .spawn import freeze_support
159+ freeze_support ()
151160
152161 def get_logger (self ):
153162 '''Return package logger -- if it does not already exist then
@@ -266,17 +275,6 @@ def get_all_start_methods(self):
266275 )
267276 return start_method_names
268277
269- def freeze_support (self ):
270- '''Check whether this is a fake forked process in a frozen executable.
271- If so then run code specified by commandline and exit.
272- '''
273- start_method = self .get_start_method (allow_none = True )
274- if start_method is None :
275- start_method = self ._default_context .get_start_method ()
276- if start_method == 'spawn' and getattr (sys , 'frozen' , False ):
277- from .spawn import freeze_support
278- freeze_support ()
279-
280278
281279#
282280# Context types for fixed start method
0 commit comments