diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-11-28 08:52:05 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-11-28 08:52:05 (GMT) |
commit | 214678e44bf7773c0ed9c3684818354001d8f9ca (patch) | |
tree | 822f4fdac4d8bd11c300b98dcb7b6a701aa37aae | |
parent | d070b2ddbb300cb9c25efcef453154fabc99bcde (diff) | |
download | cpython-214678e44bf7773c0ed9c3684818354001d8f9ca.zip cpython-214678e44bf7773c0ed9c3684818354001d8f9ca.tar.gz cpython-214678e44bf7773c0ed9c3684818354001d8f9ca.tar.bz2 |
Issue #12844: More than 255 arguments can now be passed to a function.
-rw-r--r-- | Doc/whatsnew/3.7.rst | 2 | ||||
-rw-r--r-- | Lib/test/test_syntax.py | 130 | ||||
-rw-r--r-- | Misc/NEWS | 2 | ||||
-rw-r--r-- | Python/ast.c | 5 |
4 files changed, 71 insertions, 68 deletions
diff --git a/Doc/whatsnew/3.7.rst b/Doc/whatsnew/3.7.rst index 0f6ebc4..d306d40 100644 --- a/Doc/whatsnew/3.7.rst +++ b/Doc/whatsnew/3.7.rst @@ -75,6 +75,8 @@ New Features Other Language Changes ====================== +* More than 255 arguments can now be passed to a function. + (Contributed by Serhiy Storchaka in :issue:`12844`.) New Modules diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index 80e36fd..6364266 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -139,69 +139,73 @@ SyntaxError: Generator expression must be parenthesized if not sole argument >>> f((x for x in L), 1) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] ->>> f(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, -... i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, -... i23, i24, i25, i26, i27, i28, i29, i30, i31, i32, i33, -... i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, -... i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, -... i56, i57, i58, i59, i60, i61, i62, i63, i64, i65, i66, -... i67, i68, i69, i70, i71, i72, i73, i74, i75, i76, i77, -... i78, i79, i80, i81, i82, i83, i84, i85, i86, i87, i88, -... i89, i90, i91, i92, i93, i94, i95, i96, i97, i98, i99, -... i100, i101, i102, i103, i104, i105, i106, i107, i108, -... i109, i110, i111, i112, i113, i114, i115, i116, i117, -... i118, i119, i120, i121, i122, i123, i124, i125, i126, -... i127, i128, i129, i130, i131, i132, i133, i134, i135, -... i136, i137, i138, i139, i140, i141, i142, i143, i144, -... i145, i146, i147, i148, i149, i150, i151, i152, i153, -... i154, i155, i156, i157, i158, i159, i160, i161, i162, -... i163, i164, i165, i166, i167, i168, i169, i170, i171, -... i172, i173, i174, i175, i176, i177, i178, i179, i180, -... i181, i182, i183, i184, i185, i186, i187, i188, i189, -... i190, i191, i192, i193, i194, i195, i196, i197, i198, -... i199, i200, i201, i202, i203, i204, i205, i206, i207, -... i208, i209, i210, i211, i212, i213, i214, i215, i216, -... i217, i218, i219, i220, i221, i222, i223, i224, i225, -... i226, i227, i228, i229, i230, i231, i232, i233, i234, -... i235, i236, i237, i238, i239, i240, i241, i242, i243, -... i244, i245, i246, i247, i248, i249, i250, i251, i252, -... i253, i254, i255) -Traceback (most recent call last): -SyntaxError: more than 255 arguments - -The actual error cases counts positional arguments, keyword arguments, -and generator expression arguments separately. This test combines the -three. - ->>> f(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, -... i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, -... i23, i24, i25, i26, i27, i28, i29, i30, i31, i32, i33, -... i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, -... i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, -... i56, i57, i58, i59, i60, i61, i62, i63, i64, i65, i66, -... i67, i68, i69, i70, i71, i72, i73, i74, i75, i76, i77, -... i78, i79, i80, i81, i82, i83, i84, i85, i86, i87, i88, -... i89, i90, i91, i92, i93, i94, i95, i96, i97, i98, i99, -... i100, i101, i102, i103, i104, i105, i106, i107, i108, -... i109, i110, i111, i112, i113, i114, i115, i116, i117, -... i118, i119, i120, i121, i122, i123, i124, i125, i126, -... i127, i128, i129, i130, i131, i132, i133, i134, i135, -... i136, i137, i138, i139, i140, i141, i142, i143, i144, -... i145, i146, i147, i148, i149, i150, i151, i152, i153, -... i154, i155, i156, i157, i158, i159, i160, i161, i162, -... i163, i164, i165, i166, i167, i168, i169, i170, i171, -... i172, i173, i174, i175, i176, i177, i178, i179, i180, -... i181, i182, i183, i184, i185, i186, i187, i188, i189, -... i190, i191, i192, i193, i194, i195, i196, i197, i198, -... i199, i200, i201, i202, i203, i204, i205, i206, i207, -... i208, i209, i210, i211, i212, i213, i214, i215, i216, -... i217, i218, i219, i220, i221, i222, i223, i224, i225, -... i226, i227, i228, i229, i230, i231, i232, i233, i234, -... i235, i236, i237, i238, i239, i240, i241, i242, i243, -... (x for x in i244), i245, i246, i247, i248, i249, i250, i251, -... i252=1, i253=1, i254=1, i255=1) -Traceback (most recent call last): -SyntaxError: more than 255 arguments +>>> def g(*args, **kwargs): +... print(args, sorted(kwargs.items())) +>>> g(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, +... 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, +... 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, +... 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, +... 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, +... 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, +... 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, +... 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, +... 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, +... 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, +... 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, +... 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, +... 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, +... 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, +... 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, +... 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, +... 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, +... 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, +... 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, +... 290, 291, 292, 293, 294, 295, 296, 297, 298, 299) # doctest: +ELLIPSIS +(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ..., 297, 298, 299) [] + +>>> g(a000=0, a001=1, a002=2, a003=3, a004=4, a005=5, a006=6, a007=7, a008=8, +... a009=9, a010=10, a011=11, a012=12, a013=13, a014=14, a015=15, a016=16, +... a017=17, a018=18, a019=19, a020=20, a021=21, a022=22, a023=23, a024=24, +... a025=25, a026=26, a027=27, a028=28, a029=29, a030=30, a031=31, a032=32, +... a033=33, a034=34, a035=35, a036=36, a037=37, a038=38, a039=39, a040=40, +... a041=41, a042=42, a043=43, a044=44, a045=45, a046=46, a047=47, a048=48, +... a049=49, a050=50, a051=51, a052=52, a053=53, a054=54, a055=55, a056=56, +... a057=57, a058=58, a059=59, a060=60, a061=61, a062=62, a063=63, a064=64, +... a065=65, a066=66, a067=67, a068=68, a069=69, a070=70, a071=71, a072=72, +... a073=73, a074=74, a075=75, a076=76, a077=77, a078=78, a079=79, a080=80, +... a081=81, a082=82, a083=83, a084=84, a085=85, a086=86, a087=87, a088=88, +... a089=89, a090=90, a091=91, a092=92, a093=93, a094=94, a095=95, a096=96, +... a097=97, a098=98, a099=99, a100=100, a101=101, a102=102, a103=103, +... a104=104, a105=105, a106=106, a107=107, a108=108, a109=109, a110=110, +... a111=111, a112=112, a113=113, a114=114, a115=115, a116=116, a117=117, +... a118=118, a119=119, a120=120, a121=121, a122=122, a123=123, a124=124, +... a125=125, a126=126, a127=127, a128=128, a129=129, a130=130, a131=131, +... a132=132, a133=133, a134=134, a135=135, a136=136, a137=137, a138=138, +... a139=139, a140=140, a141=141, a142=142, a143=143, a144=144, a145=145, +... a146=146, a147=147, a148=148, a149=149, a150=150, a151=151, a152=152, +... a153=153, a154=154, a155=155, a156=156, a157=157, a158=158, a159=159, +... a160=160, a161=161, a162=162, a163=163, a164=164, a165=165, a166=166, +... a167=167, a168=168, a169=169, a170=170, a171=171, a172=172, a173=173, +... a174=174, a175=175, a176=176, a177=177, a178=178, a179=179, a180=180, +... a181=181, a182=182, a183=183, a184=184, a185=185, a186=186, a187=187, +... a188=188, a189=189, a190=190, a191=191, a192=192, a193=193, a194=194, +... a195=195, a196=196, a197=197, a198=198, a199=199, a200=200, a201=201, +... a202=202, a203=203, a204=204, a205=205, a206=206, a207=207, a208=208, +... a209=209, a210=210, a211=211, a212=212, a213=213, a214=214, a215=215, +... a216=216, a217=217, a218=218, a219=219, a220=220, a221=221, a222=222, +... a223=223, a224=224, a225=225, a226=226, a227=227, a228=228, a229=229, +... a230=230, a231=231, a232=232, a233=233, a234=234, a235=235, a236=236, +... a237=237, a238=238, a239=239, a240=240, a241=241, a242=242, a243=243, +... a244=244, a245=245, a246=246, a247=247, a248=248, a249=249, a250=250, +... a251=251, a252=252, a253=253, a254=254, a255=255, a256=256, a257=257, +... a258=258, a259=259, a260=260, a261=261, a262=262, a263=263, a264=264, +... a265=265, a266=266, a267=267, a268=268, a269=269, a270=270, a271=271, +... a272=272, a273=273, a274=274, a275=275, a276=276, a277=277, a278=278, +... a279=279, a280=280, a281=281, a282=282, a283=283, a284=284, a285=285, +... a286=286, a287=287, a288=288, a289=289, a290=290, a291=291, a292=292, +... a293=293, a294=294, a295=295, a296=296, a297=297, a298=298, a299=299) +... # doctest: +ELLIPSIS +() [('a000', 0), ('a001', 1), ('a002', 2), ..., ('a298', 298), ('a299', 299)] >>> f(lambda x: x[0] = 3) Traceback (most recent call last): @@ -10,6 +10,8 @@ What's New in Python 3.7.0 alpha 1 Core and Builtins ----------------- +- Issue #12844: More than 255 arguments can now be passed to a function. + - Issue #28782: Fix a bug in the implementation ``yield from`` when checking if the next instruction is YIELD_FROM. Regression introduced by WORDCODE (issue #26647). diff --git a/Python/ast.c b/Python/ast.c index 82f4529..e6786d4 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -2738,11 +2738,6 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func) return NULL; } - if (nargs + nkeywords + ngens > 255) { - ast_error(c, n, "more than 255 arguments"); - return NULL; - } - args = _Py_asdl_seq_new(nargs + ngens, c->c_arena); if (!args) return NULL; |