@@ -1687,7 +1687,16 @@ def call_set(self, tx: "InstructionTranslator", *args, **kwargs):
1687
1687
assert not kwargs
1688
1688
if not args :
1689
1689
return SetVariable ([], mutation_type = ValueMutationNew ())
1690
- assert len (args ) == 1
1690
+ if len (args ) != 1 :
1691
+ raise_observed_exception (
1692
+ TypeError ,
1693
+ tx ,
1694
+ args = [
1695
+ ConstantVariable .create (
1696
+ f"set() takes 1 positional argument but { len (args )} were given"
1697
+ )
1698
+ ],
1699
+ )
1691
1700
arg = args [0 ]
1692
1701
if isinstance (arg , variables .SetVariable ):
1693
1702
return arg .clone (mutation_type = ValueMutationNew ())
@@ -1703,35 +1712,36 @@ def call_set(self, tx: "InstructionTranslator", *args, **kwargs):
1703
1712
if isinstance (out , SetVariable ):
1704
1713
return out
1705
1714
return BuiltinVariable (set ).call_set (tx , out )
1706
- unimplemented_v2 (
1707
- gb_type = "failed to construct builtin set()" ,
1708
- context = f"set(): { args } { kwargs } " ,
1709
- explanation = "Unable to call builtin set() with provided arguments." ,
1710
- hints = [
1711
- * graph_break_hints .USER_ERROR ,
1712
- * graph_break_hints .SUPPORTABLE ,
1713
- ],
1715
+ raise_observed_exception (
1716
+ TypeError ,
1717
+ tx ,
1718
+ args = [ConstantVariable .create ("failed to construct builtin set()" )],
1714
1719
)
1715
1720
1716
1721
def call_frozenset (self , tx : "InstructionTranslator" , * args , ** kwargs ):
1717
1722
assert not kwargs
1718
1723
if not args :
1719
1724
return FrozensetVariable ([])
1720
- assert len (args ) == 1
1725
+ if len (args ) != 1 :
1726
+ raise_observed_exception (
1727
+ TypeError ,
1728
+ tx ,
1729
+ args = [
1730
+ ConstantVariable .create (
1731
+ f"frozenset() takes 1 positional argument but { len (args )} were given"
1732
+ )
1733
+ ],
1734
+ )
1721
1735
arg = args [0 ]
1722
1736
if isinstance (arg , variables .FrozensetVariable ):
1723
1737
return FrozensetVariable ([x .vt for x in arg .set_items ])
1724
1738
elif arg .has_unpack_var_sequence (tx ):
1725
1739
items = arg .unpack_var_sequence (tx )
1726
1740
return FrozensetVariable (items )
1727
- unimplemented_v2 (
1728
- gb_type = "failed to construct builtin frozenset()" ,
1729
- context = f"frozenset(): { args } { kwargs } " ,
1730
- explanation = "Unable to call builtin frozenset() with provided arguments." ,
1731
- hints = [
1732
- * graph_break_hints .USER_ERROR ,
1733
- * graph_break_hints .SUPPORTABLE ,
1734
- ],
1741
+ raise_observed_exception (
1742
+ TypeError ,
1743
+ tx ,
1744
+ args = [ConstantVariable .create ("failed to construct builtin frozenset()" )],
1735
1745
)
1736
1746
1737
1747
def call_zip (self , tx : "InstructionTranslator" , * args , ** kwargs ):
0 commit comments