473,659 Members | 2,690 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

logging module - restricted mode error


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?

Oct 16 '07 #1
3 2634
On 16 Oct, 04:14, Paul Rudin <paul.nos...@ru din.co.ukwrote:
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

Oct 20 '07 #2
Vinay Sajip <vi*********@ya hoo.co.ukwrites :
On 16 Oct, 04:14, Paul Rudin <paul.nos...@ru din.co.ukwrote:
>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?
Oct 21 '07 #3
On 21 Oct, 07:50, Paul Rudin <paul.nos...@ru din.co.ukwrote:
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.__dic t__) and this raises the error. But in that,
it's no different to lots of other stdlib and third party modules.

Vinay

Oct 21 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
11262
by: j vickroy | last post by:
Hello, I'm trying to understand the behavior of the Python 2.3 logging module (MS Windows 2k) with regard to RotatingFileHandler. The following script illustrates a puzzling problem. What is wrong with this script? Thanks, -- jv
6
10872
by: Ville Vainio | last post by:
Just posting this for the sake of google: Like everyone else, I figured it's time to start using the 'logging' module. I typically want to dump "info" level (and up) log information to screen, and "debug" level (and up) to a log file for in-depth analysis. This is for scripts, so date/time/severity information is not wanted. I assumed such a simple use case would have an example in the docs (py 2.4), but no luck.
2
1738
by: rh0dium | last post by:
Hi all, So I have a slice of code which calls other python code. I have started to take a real liking to the logging module, but I want to extend this into the called python code. I have no idea how to pass the handle from the calling code into the modules.. So basically here is what I do.. -- Main Program --
23
2210
by: Rotem | last post by:
Hi, while working on something in my current project I have made several improvements to the logging package in Python, two of them are worth mentioning: 1. addition of a logging record field %(function)s, which results in the name of the entity which logged the record. My version even deduces the class name in the case which the logger is a bound method, and assuming the name of the "self" variable is indeed "self".
3
1842
by: sj | last post by:
Suppose the following are part of a long file and executed: logging.basicConfig(stream = sys.stderr, level=logging.INFO) logging.info("%d %d", 1, 2, 3) # buggy Python prints the traceback of the error as follows: Traceback (most recent call last): File ".../local/lib/python2.4/logging/__init__.py", line 706, in emit msg = self.format(record)
0
1856
by: robert | last post by:
As more and more python packages are starting to use the bloomy (Java-ish) 'logging' module in a mood of responsibility and as I am not overly happy with the current "thickener" style of usage, I want to put this comment and a alternative most simple default framework for discussion. Maybe there are more Python users which like to see that imported (managed) logging issue more down-to-earth and flexible ? ... Vinay Sajip wrote: >...
7
8564
by: flupke | last post by:
Hi, i'm getting errors with the log module concerning RotatingFileHandler. I'm using Python 2.4.3 on Windows XP SP2. This used to work in previous python versions but since i upgraded to 2.4.3 i get these errors: Traceback (most recent call last): File "C:\Python24\lib\logging\handlers.py", line 71, in emit if self.shouldRollover(record):
3
1604
by: seb | last post by:
Hi, I am writing to a file some basic information using the logging module. It is working but in the log file some line are printed several time. I had put some print debugging messages in the logging function (so they appear on the consile) and they are called once only. Obviously there is some understantding of the logging module that I am missing. My simple logging program (see below) is called by several processes. In this way I...
3
11533
by: Chris Shenton | last post by:
I am setting up handlers to log DEBUG and above to a rotating file and ERROR and above to console. But if any of my code calls a logger (e.g., logging.error("foo")) before I setup my handlers, the logging system will create a default logger that *also* emits logs, which I can't seem to get rid of. Is there a way I can suppress the creation of this default logger, or remove it when I 'm setting up my handlers? Thanks. Sample code:
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8525
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2750
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.