logging module - restricted mode error

P

Paul Rudin

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

Vinay Sajip

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/<[email protected]>

Vinay Sajip
 
P

Paul Rudin

Vinay Sajip said:
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/<[email protected]>

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

Vinay Sajip

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.



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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top