IronLanguages / main

Work for this repo has moved to https://github.com/IronLanguages/ironpython2
1.16k stars 347 forks source link

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

Open ironpythonbot opened 9 years ago

ironpythonbot commented 9 years ago

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 commented 9 years ago

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

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

slozier commented 8 years ago

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