This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2006年10月17日 04:04 by ldeller, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| datetime-import.patch | ldeller, 2006年10月17日 04:04 | patch to Modules/datetimemodule.c | review | |
| Messages (4) | |||
|---|---|---|---|
| msg51262 - (view) | Author: lplatypus (ldeller) * | Date: 2006年10月17日 04:04 | |
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.
|
|||
| msg51263 - (view) | Author: Ziga Seilnacht (zseil) * (Python committer) | Date: 2007年03月06日 18:39 | |
I don't think that this is a good solution; datetime is not the only module that does an import in such a way (even some parts of typeobject.c are doing imports). Note that some of the functions in time module that datetime is calling are actually implemented in Python and are also imported. Your patch also introduces a memory leak (the time module is never decrefed) and is missing tests. |
|||
| msg107412 - (view) | Author: Alexander Belopolsky (belopolsky) * (Python committer) | Date: 2010年06月09日 20:06 | |
I would like to remove datetime module dependency on time module altogether. For example getting timestamp as a float and later break it into sec/usec just to satisfy time module API looks rather inefficient. |
|||
| msg108604 - (view) | Author: Alexander Belopolsky (belopolsky) * (Python committer) | Date: 2010年06月25日 15:12 | |
See issue9079. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:20 | admin | set | github: 44136 |
| 2012年08月23日 04:19:35 | belopolsky | set | status: open -> closed resolution: out of date |
| 2010年06月25日 15:12:40 | belopolsky | set | dependencies:
+ Make gettimeofday available in time module messages: + msg108604 |
| 2010年06月09日 20:06:19 | belopolsky | set | assignee: belopolsky messages: + msg107412 nosy: + belopolsky |
| 2010年02月16日 04:29:15 | eric.araujo | set | nosy:
+ eric.araujo |
| 2009年03月30日 07:20:34 | ajaksu2 | set | priority: normal -> low type: behavior stage: test needed |
| 2006年10月17日 04:04:01 | ldeller | create | |