main icon indicating copy to clipboard operation
main copied to clipboard

it is different for the implement __new__ against Ironpython and Cpython.

Open ironpythonbot opened this issue 10 years ago • 2 comments

E:\IronPyTestFor2.5\ironpythonCompatableFor2.5\ironpythonCompatableFor2.5\25\L ib

^Z
E:\IronPyTestFor2.5\ironpythonCompatableFor2.5\ironpythonCompatableFor2.5\25\L ib
ipy
IronPython console: IronPython 2.0A5 (2.0.11011.00) on .NET 2.0.50727.1318
Copyright (c) Microsoft Corporation. All rights reserved.

from types import ModuleType as M
m = M.new(M)
str(m)
";";
hasattr(m, "; ** name ** ";)
True
dir(m)
[]
m. ** name **
'?'

E:\IronPyTestFor2.5\ironpythonCompatableFor2.5\ironpythonCompatableFor2.5\25\L ib
python
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win
32
Type ";help";, ";copyright";, ";credits"; or ";license"; for more information.
from types import ModuleType as M
m = M.new(M)
str(m)
";";
hasattr(m, "; ** name ** ";)
False
dir(m)
Traceback (most recent call last):
File ";";, line 1, in
TypeError: module. ** dict ** is not a dictionary
m. ** name **
Traceback (most recent call last):
File ";";, line 1, in
AttributeError: 'module' object has no attribute ' ** name ** '

Work Item Details

Original CodePlex Issue: Issue 23824 Status: Active Reason Closed: Unassigned Assigned to: Unassigned Reported on: Jul 27, 2009 at 11:57 PM Reported by: dfugate Updated on: Feb 22, 2013 at 2:12 AM Updated by: jdhardy Custom value: Reported internally at Microsoft. Test: test_descr.py CreatedDate: 11/9/2007 NewInternalID: 409634 OldInternalID: 320139 AreaPath: IronPython

ironpythonbot avatar Dec 09 '14 17:12 ironpythonbot

On 2009-08-15 07:17:48 UTC, dinov commented:

This is all correct except we create dict by default currently.

ironpythonbot avatar Dec 09 '14 17:12 ironpythonbot

As stated in the comment above it works except for dict:

from types import ModuleType as M
m = M.__new__(M)
assert str(m) == "<module '?' (built-in)>"
assert not hasattr(m, "__name__")
assert m.__dict__ is None
try:
    dir(m)
    assert False
except SystemError:
    pass

slozier avatar Nov 03 '16 01:11 slozier