Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'yet.': 0.04; 'classes,': 0.05; 'float': 0.07; 'bytes,': 0.09; 'exit': 0.09; 'function,': 0.09; 'restart': 0.09; 'throws': 0.09; 'type,': 0.09; 'python': 0.11; 'backtrace,': 0.16; 'frame,': 0.16; 'indirectly': 0.16; 'mode,': 0.16; 'old-style': 0.16; 'set,': 0.16; 'subject:Clearing': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'wed,': 0.18; 'thu,': 0.19; 'code,': 0.22; 'email addr:gmail.com>': 0.22; 'to:name:python-list@python.org': 0.22; "haven't": 0.24; "i've": 0.25; '>': 0.26; 'class.': 0.26; 'define': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'raise': 0.29; 'errors': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'that.': 0.31; 'breaking': 0.31; 'bunch': 0.31; "d'aprano": 0.31; 'int,': 0.31; 'restricted': 0.31; 'steven': 0.31; 'class': 0.32; 'there.': 0.32; 'received:209.85.212': 0.32; 'entirely': 0.33; 'skip:_ 10': 0.34; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'object,': 0.36; 'possible': 0.36; 'received:209': 0.37; 'easiest': 0.38; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'experts': 0.60; 'break': 0.61; 'here': 0.66; 'removal': 0.74; 'discovered': 0.83; 'dict,': 0.84; 'played': 0.84; 'recover': 0.91 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=JpGfqqgR5eLKddtXP4IeBlibYBhEEhzGNayoqHTxO1k=; b=FoudN9mPzTYwo+h59Tq/4hrwcqZ+NNnrlq1/xABImS8VZJye42ADpQBr2k9V3WfHSv /t1cKgqIFeCSs+9yVDo3JmEfLgu/AtKbm5hAYqq2/QnTvcJopmmRmmp3cpVuW1m3BBTl ICBryMi/bpMkDuRG48DxjzhYxtogLUsE3c7C0uKfOUa70GJR8CfLDPadH5PdlSi6tKtI B4mi22uyCDY6ObMZ4PHu5EUZ40GJ+fPc1RVIQvt3I1QlgTMycCFYLqyDp+AQT5wxVqJA p0Ki8hNQWofWTlE7TrmxAGk9vWyzd/+mhiJUEi7FJP9krAANIPxwgYd6vFwlpSt4jlHy qr4g== X-Gm-Message-State: ALoCoQl4X51SAAqeBRpFnuvRDO2mCQDRScpb82Dol0S601iJYwSz4alK0x7PtUCmvpsfV++TtKlf X-Received: by 10.180.95.35 with SMTP id dh3mr15984084wib.24.1412183334078; Wed, 01 Oct 2014 10:08:54 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <542c2527$0$13013$c3e8da3$5496439d@news.astraweb.com> From: Chris Kaynor Date: Wed, 1 Oct 2014 10:08:34 -0700 Subject: Re: Clearing globals in CPython To: "python-list@python.org" Content-Type: multipart/alternative; boundary=f46d04447e1dfc66c605045f8d4d X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 68 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1412183342 news.xs4all.nl 2885 [2001:888:2000:d::a6]:40167 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78559 --f46d04447e1dfc66c605045f8d4d Content-Type: text/plain; charset=UTF-8 On Wed, Oct 1, 2014 at 9:14 AM, Chris Angelico wrote: > On Thu, Oct 2, 2014 at 2:00 AM, Steven D'Aprano > wrote: > > Obviously the easiest way to recover is to exit the current session and > > restart it, but as a challenge, can we recover from this state? > > Oooh interesting. This is kinda like breaking out of a sandbox, and I > know there are people here who are experts at that. However... I'm not > entirely sure how to get a backtrace, when you don't have any built-in > exceptions! In Python 2, I can define an old-style class and raise > that. However, with the removal of __builtins__, Python throws a bunch > of errors about restricted mode, so I'm really not sure where to go > from there. > I've played with it a bit, and I haven't found any way to break it yet. I have discovered that you cannot directly declare classes, although you can access the type built-in (indirectly) so it might be possible to indirectly declare a class. It is also possible to access the types of many of the built-ins (str, bytes, dict, set, type, object, frame, function, code, generator, int, float at a minimum). Note that I've been playing with Python 3.4.1. --f46d04447e1dfc66c605045f8d4d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On W= ed, Oct 1, 2014 at 9:14 AM, Chris Angelico <rosuav@gmail.com>= wrote:
On Thu, Oct 2, 2014 at 2:00 AM= , Steven D'Aprano
<steve+comp.la= ng.python@pearwood.info> wrote:
> Obviously the easiest way to recover is to exit the current session an= d
> restart it, but as a challenge, can we recover from this state?

Oooh interesting. This is kinda like breaking out of a sandbox, and = I
know there are people here who are experts at that. However... I'm not<= br> entirely sure how to get a backtrace, when you don't have any built-in<= br> exceptions! In Python 2, I can define an old-style class and raise
that. However, with the removal of __builtins__, Python throws a bunch
of errors about restricted mode, so I'm really not sure where to go
from there.

I've played with it a b= it, and I haven't =C2=A0found any way to break it yet.

I have discovered that you cannot directly declare classes, althou= gh you can access the type built-in (indirectly) so it might be possible to= indirectly declare a class.

It is also possible t= o access the types of many of the built-ins (str, bytes, dict, set, type, o= bject, frame, function, code, generator, int, float at a minimum).

Note that I've been playing with Python 3.4.1.
--f46d04447e1dfc66c605045f8d4d--