Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > logging module - restricted mode error

Reply
Thread Tools

logging module - restricted mode error

 
 
Paul Rudin
Guest
Posts: n/a
 
      10-16-2007

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?

 
Reply With Quote
 
 
 
 
Vinay Sajip
Guest
Posts: n/a
 
      10-20-2007
On 16 Oct, 04:14, Paul Rudin <paul.nos...@rudin.co.uk> 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_...@sjsoft.com%3E

Vinay Sajip

 
Reply With Quote
 
 
 
 
Paul Rudin
Guest
Posts: n/a
 
      10-21-2007
Vinay Sajip <> writes:

> On 16 Oct, 04:14, Paul Rudin <paul.nos...@rudin.co.uk> 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_...@sjsoft.com%3E
>


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?
 
Reply With Quote
 
Vinay Sajip
Guest
Posts: n/a
 
      10-21-2007
On 21 Oct, 07:50, Paul Rudin <paul.nos...@rudin.co.uk> 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_...@sjsoft.com%3E

>
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Logging to a file and closing it again properly (logging module) Christoph Haas Python 1 06-14-2006 08:47 AM
Logging to a file and closing it again properly (logging module) Christoph Haas Python 0 06-12-2006 09:58 PM
restricted mode (2.4.2) Wojciech Pawlikowski Python 0 02-17-2006 08:53 AM
Sharing between multiple interpreters and restricted mode gabriel.becedillas@gmail.com Python 0 01-04-2006 05:28 PM
Using python for writing models: How to run models in restricted python mode? vinjvinj Python 15 11-10-2005 09:57 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57