# # -*- coding: utf-8 -*- # # Copyright (c) 2014 by Anselm Kruis # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # from __future__ import absolute_import, print_function, unicode_literals, division import threading import sys def save_frame(): global a_frame a_frame = sys._getframe() # Create a frame on a dead thread t = threading.Thread(target=save_frame) t.start() t.join() # no cause an access violation in PyFrame_IsRestricted(f) # PyFrame_IsRestricted is a macro: # #define PyFrame_IsRestricted(f) \ # ((f)->f_builtins != (f)->f_tstate->interp->builtins) # # *((f)->f_tstate) is no longer valid. It depends on the content of the memory, # if (f)->f_tstate->interp causes an access violation. I use a debug build on windows, # to get reliable access violation. f_restricted = a_frame.f_restricted print("No crash, restricted=", f_restricted)