Skip to content

Commit 9de4a3a

Browse files
authored
Fix class __doc__ type (#1602)
1 parent e84a1ef commit 9de4a3a

File tree

3 files changed

+40
-20
lines changed

3 files changed

+40
-20
lines changed

Src/IronPython/Compiler/Ast/ClassDefinition.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ private Microsoft.Scripting.Ast.LightExpression<Func<CodeContext, CodeContext>>
299299
MSAst.Expression? docStmt = null;
300300
string? doc = GetDocumentation(Body);
301301
if (doc is not null) {
302-
docStmt = SetLocalName("__doc__", Ast.Constant(doc, typeof(object)));
302+
docStmt = SetLocalName("__doc__", Ast.Constant(doc, typeof(string)));
303303
}
304304

305305
// Create the body

Tests/test_regressions.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -824,24 +824,6 @@ class SomeOtherError(SomeError, IOError):
824824
except SomeOtherError:
825825
pass
826826

827-
828-
@unittest.skipIf(is_netcoreapp, 'no clr.CompileModules')
829-
@skipUnlessIronPython()
830-
def test_gh1357(self):
831-
filename = os.path.join(self.temporary_dir, 'gh1357_%d.py' % os.getpid())
832-
dll = os.path.join(self.temporary_dir, "test_%d.dll" % os.getpid())
833-
with open(filename, 'w') as f:
834-
f.write('{(1,): None}')
835-
836-
import clr
837-
try:
838-
clr.CompileModules(dll, filename)
839-
except:
840-
Fail('Failed to compile the specified file')
841-
finally:
842-
os.unlink(filename)
843-
os.unlink(dll)
844-
845827
@skipUnlessIronPython()
846828
def test_gh1435(self):
847829
import clr

Tests/test_regressions_compiled.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,49 @@
66
Test issues related to compiled code.
77
"""
88

9-
from iptest import IronPythonTestCase, run_test
9+
import os
10+
import unittest
11+
12+
from iptest import IronPythonTestCase, is_netcoreapp, skipUnlessIronPython, run_test
1013

1114
class RegressionCompiledTest(IronPythonTestCase):
1215
def test_gh_ipy2_563(self):
1316
"""https://github.com/IronLanguages/ironpython2/issues/563"""
1417
eval('3.14')
1518

19+
@unittest.skipIf(is_netcoreapp, 'no clr.CompileModules')
20+
@skipUnlessIronPython()
21+
def test_gh1357(self):
22+
filename = os.path.join(self.temporary_dir, 'gh1357_%d.py' % os.getpid())
23+
dll = os.path.join(self.temporary_dir, "test_%d.dll" % os.getpid())
24+
with open(filename, 'w') as f:
25+
f.write('{(1,): None}')
26+
27+
import clr
28+
try:
29+
clr.CompileModules(dll, filename)
30+
except:
31+
Fail('Failed to compile the specified file')
32+
finally:
33+
os.unlink(filename)
34+
os.unlink(dll)
35+
36+
@unittest.skipIf(is_netcoreapp, 'no clr.CompileModules')
37+
@skipUnlessIronPython()
38+
def test_ipy3_gh1601(self):
39+
filename = os.path.join(self.temporary_dir, 'test_ipy3_gh1601_%d.py' % os.getpid())
40+
dll = os.path.join(self.temporary_dir, "test_ipy3_gh1601_%d.dll" % os.getpid())
41+
with open(filename, 'w') as f:
42+
f.write('class MyClass:\n')
43+
f.write(' """description"""\n')
44+
45+
import clr
46+
try:
47+
clr.CompileModules(dll, filename)
48+
except:
49+
Fail('Failed to compile the specified file')
50+
finally:
51+
os.unlink(filename)
52+
os.unlink(dll)
53+
1654
run_test(__name__)

0 commit comments

Comments
 (0)