logging module - restricted mode error

Discussion in 'Python' started by Paul Rudin, Oct 16, 2007.

  1. Paul Rudin

    Paul Rudin Guest

    I'm occasionally seeing tracebacks like this:

    Traceback (most recent call last):
    File "logging/__init__.py", line 744, in emit
    File "logging/__init__.py", line 630, in format
    File "logging/__init__.py", line 421, in format
    RuntimeError: instance.__dict__ not accessible in restricted mode

    I'm not sure what it means. Googling leads me to
    <http://docs.python.org/lib/restricted.html> but that says that those
    modules were disabled in 2.3 and I'm running 2.5.1. In any case I'm
    not using them (although it could be that one of the 3rd party modules
    I'm using does something.)

    Could someone please explain what this error means?
     
    Paul Rudin, Oct 16, 2007
    #1
    1. Advertising

  2. Paul Rudin

    Vinay Sajip Guest

    On 16 Oct, 04:14, Paul Rudin <> wrote:
    > I'm occasionally seeing tracebacks like this:
    >
    > Traceback (most recent call last):
    > File "logging/__init__.py", line 744, in emit
    > File "logging/__init__.py", line 630, in format
    > File "logging/__init__.py", line 421, in format
    > RuntimeError: instance.__dict__ not accessible in restricted mode
    >
    > I'm not sure what it means. Googling leads me to
    > <http://docs.python.org/lib/restricted.html> but that says that those
    > modules were disabled in 2.3 and I'm running 2.5.1. In any case I'm
    > not using them (although it could be that one of the 3rd party modules
    > I'm using does something.)
    >
    > Could someone please explain what this error means?


    Can you say a little bit more about the execution environment? For
    example, are you running under mod_python? If so, which version?

    When googling, did you search for the exact text of the error message?
    For example, did you see the following post?

    http://mail-archives.apache.org/mod_mbox/httpd-python-dev/200404.mbox/<>

    Vinay Sajip
     
    Vinay Sajip, Oct 20, 2007
    #2
    1. Advertising

  3. Paul Rudin

    Paul Rudin Guest

    Vinay Sajip <> writes:

    > On 16 Oct, 04:14, Paul Rudin <> wrote:
    >> I'm occasionally seeing tracebacks like this:
    >>
    >> Traceback (most recent call last):
    >> File "logging/__init__.py", line 744, in emit
    >> File "logging/__init__.py", line 630, in format
    >> File "logging/__init__.py", line 421, in format
    >> RuntimeError: instance.__dict__ not accessible in restricted mode
    >>
    >> I'm not sure what it means. Googling leads me to
    >> <http://docs.python.org/lib/restricted.html> but that says that those
    >> modules were disabled in 2.3 and I'm running 2.5.1. In any case I'm
    >> not using them (although it could be that one of the 3rd party modules
    >> I'm using does something.)
    >>
    >> Could someone please explain what this error means?

    >
    > Can you say a little bit more about the execution environment? For
    > example, are you running under mod_python? If so, which version?


    I'm not running under mod_python - but this is using cherrypy. I also
    do some passing of pickled objects between two python processes, which
    I guess could be relevant.

    >
    > When googling, did you search for the exact text of the error message?
    > For example, did you see the following post?
    >
    > http://mail-archives.apache.org/mod_mbox/httpd-python-dev/200404.mbox/<>
    >


    I hadn't noticed that particularly, but I'm still a little unclear as
    to what's going on. That thread dates from 3 years ago and it seems to
    imply that mod python is using restricted mode (in the sense of the
    the rexec module), which won't run in 2.5 will it?

    One parts that says:

    "Restricted mode is a strange beast, in that there isn't really
    anything like a "restricted mode" flag, but it looks at a pointer
    somwhere (don't remember now), and if it's not what is expected, it
    concludes that it's in restricted mode. So this behaviour is
    actually a sign of a bug where an object is created in one
    subinterpreter but is running in another... These bugs can be hard
    to track down."

    What exactly is meant by a subinterpreter? Python running in a
    subprocess?
     
    Paul Rudin, Oct 21, 2007
    #3
  4. Paul Rudin

    Vinay Sajip Guest

    On 21 Oct, 07:50, Paul Rudin <> wrote:
    > > Can you say a little bit more about the execution environment? For
    > > example, are you running under mod_python? If so, which version?

    >
    > I'm not running under mod_python - but this is using cherrypy. I also
    > do some passing of pickled objects between two python processes, which
    > I guess could be relevant.
    >
    > > When googling, did you search for the exact text of the error message?
    > > For example, did you see the following post?

    >
    > > http://mail-archives.apache.org/mod_mbox/httpd-python-dev/200404.mbox/<>

    >
    > I hadn't noticed that particularly, but I'm still a little unclear as
    > to what's going on. That thread dates from 3 years ago and it seems to
    > imply that mod python is using restricted mode (in the sense of the
    > the rexec module), which won't run in 2.5 will it?
    >
    > One parts that says:
    >
    > "Restricted mode is a strange beast, in that there isn't really
    > anything like a "restricted mode" flag, but it looks at a pointer
    > somwhere (don't remember now), and if it's not what is expected, it
    > concludes that it's in restricted mode. So this behaviour is
    > actually a sign of a bug where an object is created in one
    > subinterpreter but is running in another... These bugs can be hard
    > to track down."
    >
    > What exactly is meant by a subinterpreter? Python running in a
    > subprocess?


    I'm no mod_python expert: I just wondered whether you might be hitting
    the same problem. The way I read it, the "restricted mode" referred to
    in that post is not in the rexec sense, but based on some more obscure
    heuristic to do with multiple interpreters. Anyway: I don't think it's
    specifically a logging problem, except that logging does introspect
    (look at LogRecord.__dict__) and this raises the error. But in that,
    it's no different to lots of other stdlib and third party modules.

    Vinay
     
    Vinay Sajip, Oct 21, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vinjvinj
    Replies:
    15
    Views:
    585
    Jeremy Sanders
    Nov 10, 2005
  2. Replies:
    0
    Views:
    266
  3. Wojciech Pawlikowski

    restricted mode (2.4.2)

    Wojciech Pawlikowski, Feb 17, 2006, in forum: Python
    Replies:
    0
    Views:
    408
    Wojciech Pawlikowski
    Feb 17, 2006
  4. Dmitri Fedoruk
    Replies:
    4
    Views:
    705
    Dmitri Fedoruk
    Sep 14, 2007
  5. Robin Becker

    restricted mode???

    Robin Becker, Nov 4, 2009, in forum: Python
    Replies:
    3
    Views:
    708
    Robin Becker
    Nov 5, 2009
Loading...

Share This Page