[Patches] [ python-Patches-1578643 ] various datetime methods fail in restricted mode
SourceForge.net
noreply at sourceforge.net
Tue Oct 17 06:04:01 CEST 2006
Patches item #1578643, was opened at 2006-10-17 14:04
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1578643&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Submitted By: lplatypus (ldeller)
Assigned to: Nobody/Anonymous (nobody)
Summary: various datetime methods fail in restricted mode
Initial Comment:
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.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1578643&group_id=5470
More information about the Patches
mailing list