Message51262
| Author |
ldeller |
| Recipients |
| Date |
2006年10月17日.04:04:01 |
| SpamBayes Score |
| Marked as misclassified |
| Message-id |
| In-reply-to |
| Content |
The following methods fail in restricted execution
mode, because they try to import the time module:
datetime.datetime.strftime
datetime.datetime.strptime
datetime.datetime.timetuple
datetime.datetime.utctimetuple
datetime.time.time
datetime.date.timetuple
Example of the problem:
>>> import datetime
>>> script = 'print dt; print dt.strftime("x")'
>>> exec script in {'dt':datetime.datetime(2006,1,1)}
2006年01月01日 00:00:00
x
>>> exec script in
{'dt':datetime.datetime(2006,1,1),'__builtins__':{}}
2006年01月01日 00:00:00
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<string>", line 1, in ?
KeyError: '__import__'
The attached adjusts the datetime module so that the
time module is imported in the initialisation of the
datetime module. This allows these methods to be used
in restricted execution mode.
If the time module is not available, then the datetime
module will not be importable either after this patch.
Previously the datetime module would be importable but
the methods listed above would raise exceptions. If
this situation is worth considering then I can adjust
the patch accordingly. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2007年08月23日 15:55:06 | admin | link | issue1578643 messages |
| 2007年08月23日 15:55:06 | admin | create |
|