Skip to content

Commit 2e62cac

Browse files
committed
Implement more warnings
1 parent c0af6eb commit 2e62cac

File tree

13 files changed

+570
-220
lines changed

13 files changed

+570
-220
lines changed

.cspell.dict/python-more.txt

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
abiflags
22
abstractmethods
3+
addcompare
34
aenter
45
aexit
56
aiter
7+
altzone
68
anext
79
anextawaitable
810
annotationlib
@@ -24,6 +26,7 @@ breakpointhook
2426
cformat
2527
chunksize
2628
classcell
29+
classmethods
2730
closefd
2831
closesocket
2932
codepoint
@@ -32,6 +35,8 @@ codesize
3235
contextvar
3336
cpython
3437
cratio
38+
ctype
39+
ctypes
3540
dealloc
3641
debugbuild
3742
decompressor
@@ -74,6 +79,8 @@ fstring
7479
fstrings
7580
ftruncate
7681
genexpr
82+
genexpressions
83+
getargs
7784
getattro
7885
getcodesize
7986
getdefaultencoding
@@ -83,14 +90,17 @@ getformat
8390
getframe
8491
getframemodulename
8592
getnewargs
93+
getopt
8694
getpip
8795
getrandom
8896
getrecursionlimit
8997
getrefcount
9098
getsizeof
9199
getswitchinterval
100+
getweakref
92101
getweakrefcount
93102
getweakrefs
103+
getweakrefs
94104
getwindowsversion
95105
gmtoff
96106
groupdict
@@ -103,8 +113,12 @@ idxs
103113
impls
104114
indexgroup
105115
infj
116+
inittab
117+
Inittab
106118
instancecheck
107119
instanceof
120+
interpchannels
121+
interpqueues
108122
irepeat
109123
isabstractmethod
110124
isbytes
@@ -129,6 +143,7 @@ listcomp
129143
longrange
130144
lvalue
131145
mappingproxy
146+
markupbase
132147
maskpri
133148
maxdigits
134149
MAXGROUPS
@@ -144,6 +159,7 @@ mformat
144159
mro
145160
mros
146161
multiarch
162+
mymodule
147163
namereplace
148164
nanj
149165
nbytes
@@ -156,6 +172,7 @@ nlocals
156172
NOARGS
157173
nonbytes
158174
Nonprintable
175+
onceregistry
159176
origname
160177
ospath
161178
pendingcr
@@ -170,7 +187,10 @@ profilefunc
170187
pycache
171188
pycodecs
172189
pycs
190+
pydatetime
173191
pyexpat
192+
pyio
193+
pymain
174194
PYTHONAPI
175195
PYTHONBREAKPOINT
176196
PYTHONDEBUG
@@ -220,10 +240,13 @@ scproxy
220240
seennl
221241
setattro
222242
setcomp
243+
setprofileallthreads
223244
setrecursionlimit
224245
setswitchinterval
246+
settraceallthreads
225247
showwarnmsg
226248
signum
249+
sitebuiltins
227250
slotnames
228251
STACKLESS
229252
stacklevel
@@ -232,14 +255,17 @@ startpos
232255
subclassable
233256
subclasscheck
234257
subclasshook
258+
subclassing
235259
suboffset
236260
suboffsets
237261
SUBPATTERN
262+
subpatterns
238263
sumprod
239264
surrogateescape
240265
surrogatepass
241266
sysconf
242267
sysconfigdata
268+
sysdict
243269
sysvars
244270
teedata
245271
thisclass
@@ -266,35 +292,10 @@ warnopts
266292
weaklist
267293
weakproxy
268294
weakrefs
295+
weakrefset
269296
winver
270297
withdata
271298
xmlcharrefreplace
272299
xoptions
273300
xopts
274301
yieldfrom
275-
addcompare
276-
altzone
277-
classmethods
278-
ctype
279-
ctypes
280-
genexpressions
281-
getargs
282-
getopt
283-
getweakref
284-
getweakrefs
285-
inittab
286-
Inittab
287-
interpchannels
288-
interpqueues
289-
markupbase
290-
mymodule
291-
pydatetime
292-
pyio
293-
pymain
294-
setprofileallthreads
295-
settraceallthreads
296-
sitebuiltins
297-
subclassing
298-
subpatterns
299-
sysdict
300-
weakrefset

Lib/test/test_site.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,6 @@ def test_lazy_imports(self):
591591

592592
class StartupImportTests(unittest.TestCase):
593593

594-
@unittest.expectedFailure # TODO: RUSTPYTHON
595594
@support.requires_subprocess()
596595
def test_startup_imports(self):
597596
# Get sys.path in isolated mode (python3 -I)

Lib/test/test_warnings/__init__.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,6 @@ class CWarnTests(WarnTests, unittest.TestCase):
807807

808808
# As an early adopter, we sanity check the
809809
# test.import_helper.import_fresh_module utility function
810-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: 'function' object has unexpected attribute '__code__'
811810
def test_accelerated(self):
812811
self.assertIsNot(original_warnings, self.module)
813812
self.assertNotHasAttr(self.module.warn, '__code__')
@@ -1012,7 +1011,6 @@ def test_showwarning_missing(self):
10121011
result = stream.getvalue()
10131012
self.assertIn(text, result)
10141013

1015-
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError: module 'warnings' has no attribute '_showwarnmsg'. Did you mean: 'showwarning'?
10161014
def test_showwarnmsg_missing(self):
10171015
# Test that _showwarnmsg() missing is okay.
10181016
text = 'del _showwarnmsg test'
@@ -1458,15 +1456,13 @@ class PyCatchWarningTests(CatchWarningTests, unittest.TestCase):
14581456

14591457
class EnvironmentVariableTests(BaseTest):
14601458

1461-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: b'[]' != b"['ignore::DeprecationWarning']"
14621459
def test_single_warning(self):
14631460
rc, stdout, stderr = assert_python_ok("-c",
14641461
"import sys; sys.stdout.write(str(sys.warnoptions))",
14651462
PYTHONWARNINGS="ignore::DeprecationWarning",
14661463
PYTHONDEVMODE="")
14671464
self.assertEqual(stdout, b"['ignore::DeprecationWarning']")
14681465

1469-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: b'[]' != b"['ignore::DeprecationWarning', 'ignore::UnicodeWarning']"
14701466
def test_comma_separated_warnings(self):
14711467
rc, stdout, stderr = assert_python_ok("-c",
14721468
"import sys; sys.stdout.write(str(sys.warnoptions))",
@@ -1475,7 +1471,6 @@ def test_comma_separated_warnings(self):
14751471
self.assertEqual(stdout,
14761472
b"['ignore::DeprecationWarning', 'ignore::UnicodeWarning']")
14771473

1478-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: b"['ignore::UnicodeWarning']" != b"['ignore::DeprecationWarning', 'ignore::UnicodeWarning']"
14791474
@force_not_colorized
14801475
def test_envvar_and_command_line(self):
14811476
rc, stdout, stderr = assert_python_ok("-Wignore::UnicodeWarning", "-c",
@@ -1535,7 +1530,6 @@ def test_default_filter_configuration(self):
15351530
self.assertEqual(stdout_lines, expected_output)
15361531

15371532

1538-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: b'[]' != b"['ignore:DeprecationWarning\xc3\xa6']"
15391533
@unittest.skipUnless(sys.getfilesystemencoding() != 'ascii',
15401534
'requires non-ascii filesystemencoding')
15411535
def test_nonascii(self):
@@ -1550,10 +1544,6 @@ def test_nonascii(self):
15501544
class CEnvironmentVariableTests(EnvironmentVariableTests, unittest.TestCase):
15511545
module = c_warnings
15521546

1553-
@unittest.expectedFailure # TODO: RUSTPYTHON; Lists differ
1554-
def test_default_filter_configuration(self):
1555-
return super().test_default_filter_configuration()
1556-
15571547
class PyEnvironmentVariableTests(EnvironmentVariableTests, unittest.TestCase):
15581548
module = py_warnings
15591549

@@ -1851,7 +1841,6 @@ def h(x):
18511841
self.assertEqual(len(overloads), 2)
18521842
self.assertEqual(overloads[0].__deprecated__, "no more ints")
18531843

1854-
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
18551844
def test_class(self):
18561845
@deprecated("A will go away soon")
18571846
class A:
@@ -1863,7 +1852,6 @@ class A:
18631852
with self.assertRaises(TypeError):
18641853
A(42)
18651854

1866-
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
18671855
def test_class_with_init(self):
18681856
@deprecated("HasInit will go away soon")
18691857
class HasInit:
@@ -1874,7 +1862,6 @@ def __init__(self, x):
18741862
instance = HasInit(42)
18751863
self.assertEqual(instance.x, 42)
18761864

1877-
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
18781865
def test_class_with_new(self):
18791866
has_new_called = False
18801867

@@ -1893,7 +1880,6 @@ def __init__(self, x) -> None:
18931880
self.assertEqual(instance.x, 42)
18941881
self.assertTrue(has_new_called)
18951882

1896-
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
18971883
def test_class_with_inherited_new(self):
18981884
new_base_called = False
18991885

@@ -1915,7 +1901,6 @@ class HasInheritedNew(NewBase):
19151901
self.assertEqual(instance.x, 42)
19161902
self.assertTrue(new_base_called)
19171903

1918-
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
19191904
def test_class_with_new_but_no_init(self):
19201905
new_called = False
19211906

@@ -1933,7 +1918,6 @@ def __new__(cls, x):
19331918
self.assertEqual(instance.x, 42)
19341919
self.assertTrue(new_called)
19351920

1936-
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
19371921
def test_mixin_class(self):
19381922
@deprecated("Mixin will go away soon")
19391923
class Mixin:
@@ -1950,7 +1934,6 @@ class Child(Base, Mixin):
19501934
instance = Child(42)
19511935
self.assertEqual(instance.a, 42)
19521936

1953-
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
19541937
def test_do_not_shadow_user_arguments(self):
19551938
new_called = False
19561939
new_called_cls = None
@@ -1970,7 +1953,6 @@ class Foo(metaclass=MyMeta, cls='haha'):
19701953
self.assertTrue(new_called)
19711954
self.assertEqual(new_called_cls, 'haha')
19721955

1973-
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
19741956
def test_existing_init_subclass(self):
19751957
@deprecated("C will go away soon")
19761958
class C:
@@ -1987,7 +1969,6 @@ class D(C):
19871969
self.assertTrue(D.inited)
19881970
self.assertIsInstance(D(), D) # no deprecation
19891971

1990-
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
19911972
def test_existing_init_subclass_in_base(self):
19921973
class Base:
19931974
def __init_subclass__(cls, x) -> None:
@@ -2008,7 +1989,6 @@ class D(C, x=3):
20081989

20091990
self.assertEqual(D.inited, 3)
20101991

2011-
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
20121992
def test_existing_init_subclass_in_sibling_base(self):
20131993
@deprecated("A will go away soon")
20141994
class A:
@@ -2028,7 +2008,6 @@ class D(B, A, x=42):
20282008
pass
20292009
self.assertEqual(D.inited, 42)
20302010

2031-
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
20322011
def test_init_subclass_has_correct_cls(self):
20332012
init_subclass_saw = None
20342013

@@ -2046,7 +2025,6 @@ class C(Base):
20462025

20472026
self.assertIs(init_subclass_saw, C)
20482027

2049-
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
20502028
def test_init_subclass_with_explicit_classmethod(self):
20512029
init_subclass_saw = None
20522030

@@ -2065,7 +2043,6 @@ class C(Base):
20652043

20662044
self.assertIs(init_subclass_saw, C)
20672045

2068-
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
20692046
def test_function(self):
20702047
@deprecated("b will go away soon")
20712048
def b():
@@ -2074,7 +2051,6 @@ def b():
20742051
with self.assertWarnsRegex(DeprecationWarning, "b will go away soon"):
20752052
b()
20762053

2077-
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
20782054
def test_method(self):
20792055
class Capybara:
20802056
@deprecated("x will go away soon")
@@ -2085,7 +2061,6 @@ def x(self):
20852061
with self.assertWarnsRegex(DeprecationWarning, "x will go away soon"):
20862062
instance.x()
20872063

2088-
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
20892064
def test_property(self):
20902065
class Capybara:
20912066
@property
@@ -2113,7 +2088,6 @@ def no_more_setting(self, value):
21132088
with self.assertWarnsRegex(DeprecationWarning, "no more setting"):
21142089
instance.no_more_setting = 42
21152090

2116-
@unittest.expectedFailure # TODO: RUSTPYTHON; RuntimeWarning not triggered
21172091
def test_category(self):
21182092
@deprecated("c will go away soon", category=RuntimeWarning)
21192093
def c():

crates/stdlib/src/_asyncio.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,10 +1014,12 @@ pub(crate) mod _asyncio {
10141014
// Warn about deprecated (type, val, tb) signature
10151015
if exc_val.is_present() || exc_tb.is_present() {
10161016
warn::warn(
1017-
vm.ctx.new_str(
1018-
"the (type, val, tb) signature of throw() is deprecated, \
1017+
vm.ctx
1018+
.new_str(
1019+
"the (type, val, tb) signature of throw() is deprecated, \
10191020
use throw(val) instead",
1020-
),
1021+
)
1022+
.into(),
10211023
Some(vm.ctx.exceptions.deprecation_warning.to_owned()),
10221024
1,
10231025
None,

crates/stdlib/src/socket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2144,7 +2144,7 @@ mod _socket {
21442144
laddr
21452145
);
21462146
let _ = crate::vm::warn::warn(
2147-
vm.ctx.new_str(msg),
2147+
vm.ctx.new_str(msg).into(),
21482148
Some(vm.ctx.exceptions.resource_warning.to_owned()),
21492149
1,
21502150
None,

0 commit comments

Comments
 (0)