@@ -774,6 +774,45 @@ def test_legacy_converters(self):
774
774
module , function = block .signatures
775
775
self .assertIsInstance ((function .parameters ['path' ]).converter , clinic .str_converter )
776
776
777
+ def test_legacy_converters_non_string_constant_annotation (self ):
778
+ expected_failure_message = """\
779
+ Error on line 0:
780
+ Annotations must be either a name, a function call, or a string.
781
+ """
782
+
783
+ s = self .parse_function_should_fail ('module os\n os.access\n path: 42' )
784
+ self .assertEqual (s , expected_failure_message )
785
+
786
+ s = self .parse_function_should_fail ('module os\n os.access\n path: 42.42' )
787
+ self .assertEqual (s , expected_failure_message )
788
+
789
+ s = self .parse_function_should_fail ('module os\n os.access\n path: 42j' )
790
+ self .assertEqual (s , expected_failure_message )
791
+
792
+ s = self .parse_function_should_fail ('module os\n os.access\n path: b"42"' )
793
+ self .assertEqual (s , expected_failure_message )
794
+
795
+ def test_other_bizarre_things_in_annotations_fail (self ):
796
+ expected_failure_message = """\
797
+ Error on line 0:
798
+ Annotations must be either a name, a function call, or a string.
799
+ """
800
+
801
+ s = self .parse_function_should_fail (
802
+ 'module os\n os.access\n path: {"some": "dictionary"}'
803
+ )
804
+ self .assertEqual (s , expected_failure_message )
805
+
806
+ s = self .parse_function_should_fail (
807
+ 'module os\n os.access\n path: ["list", "of", "strings"]'
808
+ )
809
+ self .assertEqual (s , expected_failure_message )
810
+
811
+ s = self .parse_function_should_fail (
812
+ 'module os\n os.access\n path: (x for x in range(42))'
813
+ )
814
+ self .assertEqual (s , expected_failure_message )
815
+
777
816
def test_unused_param (self ):
778
817
block = self .parse ("""
779
818
module foo
0 commit comments