久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='l9J5O'><tr id='l9J5O'><dt id='l9J5O'><q id='l9J5O'><span id='l9J5O'><b id='l9J5O'><form id='l9J5O'><ins id='l9J5O'></ins><ul id='l9J5O'></ul><sub id='l9J5O'></sub></form><legend id='l9J5O'></legend><bdo id='l9J5O'><pre id='l9J5O'><center id='l9J5O'></center></pre></bdo></b><th id='l9J5O'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='l9J5O'><tfoot id='l9J5O'></tfoot><dl id='l9J5O'><fieldset id='l9J5O'></fieldset></dl></div>

<small id='l9J5O'></small><noframes id='l9J5O'>

<tfoot id='l9J5O'></tfoot>
  • <legend id='l9J5O'><style id='l9J5O'><dir id='l9J5O'><q id='l9J5O'></q></dir></style></legend>

        <bdo id='l9J5O'></bdo><ul id='l9J5O'></ul>

      1. 為什么 python 的 eval 有長度限制?

        Why is there a length limit to python#39;s eval?(為什么 python 的 eval 有長度限制?)

            <tbody id='nVA7X'></tbody>
        1. <legend id='nVA7X'><style id='nVA7X'><dir id='nVA7X'><q id='nVA7X'></q></dir></style></legend>

            • <tfoot id='nVA7X'></tfoot>

              <small id='nVA7X'></small><noframes id='nVA7X'>

              <i id='nVA7X'><tr id='nVA7X'><dt id='nVA7X'><q id='nVA7X'><span id='nVA7X'><b id='nVA7X'><form id='nVA7X'><ins id='nVA7X'></ins><ul id='nVA7X'></ul><sub id='nVA7X'></sub></form><legend id='nVA7X'></legend><bdo id='nVA7X'><pre id='nVA7X'><center id='nVA7X'></center></pre></bdo></b><th id='nVA7X'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='nVA7X'><tfoot id='nVA7X'></tfoot><dl id='nVA7X'><fieldset id='nVA7X'></fieldset></dl></div>

                • <bdo id='nVA7X'></bdo><ul id='nVA7X'></ul>
                  本文介紹了為什么 python 的 eval 有長度限制?的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我并不主張這將是一個(gè)好主意,但我發(fā)現(xiàn)您可以通過在足夠大的輸入字符串上運(yùn)行 eval 來使 Python 崩潰(檢查 2.7 和 3.2):

                  I'm not advocating that this would ever be a good idea, but I've found that you can crash Python (2.7 and 3.2 checked) by running eval on a large enough input string:

                  def kill_python(N):
                      S = '+'.join((str(n) for n in xrange(N)))
                      return eval(S)
                  

                  在我的電腦上 S 可以很好地生成,但是對于大約 N>74900 的值,Python 將失敗并出現(xiàn) Segmentation fault (core dumped).解釋器可以處理的字符串(或解析樹)的長度是否有限制?

                  On my computer S can be generated just fine, but for values of approximately N>74900, Python will fail with Segmentation fault (core dumped). Is there a limit to the length of string (or parse tree) that the interpreter can handle?

                  注意:我不需要這樣做,對我來說這是一個(gè)更深層次的問題,反映出我對盒子里發(fā)生的事情一無所知.我想了解為什么 Python 在這里失敗了,而且是災(zāi)難性的(為什么不拋出異常?)

                  Note: I don't need to do this, to me this is a deeper question reflecting my ignorance of what goes on inside the box. I'd like to understand why Python fails here, and so catastrophically (why not throw an exception?)

                  推薦答案

                  這個(gè)問題是由 CPython 編譯器中的堆棧溢出引起的.重現(xiàn)相同問題的簡單方法是

                  This issue is caused by a stack overflow in the CPython compiler. An easy way to reproduce the same issue is

                  >>> code = compile("1" + "+1" * 1000000, "", "eval")
                  Segmentation fault
                  

                  這證明段錯(cuò)誤發(fā)生在編譯階段,而不是評估期間.(當(dāng)然這個(gè)用gdb也很容易確認(rèn).)

                  which proves that the segfault is happening at the compile stage, not during evaluation. (Of course this is also easy to confirm with gdb.)

                  [旁注:對于較小的表達(dá)式,編譯器無論如何都會(huì)在此處應(yīng)用常量折疊,因此在代碼執(zhí)行期間唯一發(fā)生的事情就是加載結(jié)果:

                  [Side note: For smaller expressions, the compiler would apply constant folding here anyway, so the only thing happening during the execution of the code is to load the result:

                  >>> code = compile("1" + "+1" * 1000, "", "eval")
                  >>> eval(code)
                  1001
                  >>> dis.dis(code)
                    1           0 LOAD_CONST            1000 (1001)
                                3 RETURN_VALUE        
                  

                  旁注結(jié)束.]

                  此問題是已知缺陷.Python 開發(fā)人員在 目錄 Lib/test/crashes 的源代碼分發(fā).與此問題對應(yīng)的是 Lib/測試/crashers/compiler_recursion.py.

                  This issue is a known defect. The Python developers collected several ways to crash the Python interpreter in the directory Lib/test/crashers of the source distribution. The one corresponding to this issue is Lib/test/crashers/compiler_recursion.py.

                  這篇關(guān)于為什么 python 的 eval 有長度限制?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數(shù)綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動(dòng)后進(jìn)度躍升至 100%)
                  How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標(biāo)簽設(shè)置在固定位置,以便當(dāng)我向左或向右滾動(dòng)時(shí),yaxis 刻度標(biāo)簽應(yīng)該可見
                  `QImage` constructor has unknown keyword `data`(`QImage` 構(gòu)造函數(shù)有未知關(guān)鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時(shí)顯示進(jìn)度條?)

                      <bdo id='PBy53'></bdo><ul id='PBy53'></ul>
                      <tfoot id='PBy53'></tfoot>

                    • <legend id='PBy53'><style id='PBy53'><dir id='PBy53'><q id='PBy53'></q></dir></style></legend>
                              <tbody id='PBy53'></tbody>

                            <small id='PBy53'></small><noframes id='PBy53'>

                            <i id='PBy53'><tr id='PBy53'><dt id='PBy53'><q id='PBy53'><span id='PBy53'><b id='PBy53'><form id='PBy53'><ins id='PBy53'></ins><ul id='PBy53'></ul><sub id='PBy53'></sub></form><legend id='PBy53'></legend><bdo id='PBy53'><pre id='PBy53'><center id='PBy53'></center></pre></bdo></b><th id='PBy53'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='PBy53'><tfoot id='PBy53'></tfoot><dl id='PBy53'><fieldset id='PBy53'></fieldset></dl></div>

                          • 主站蜘蛛池模板: 日本精品在线观看 | 亚洲一区中文 | 亚洲一区二区三区桃乃木香奈 | 亚洲网站免费看 | 成人亚洲网站 | 三区在线 | 久久久久久国产精品免费免费男同 | av一级毛片| 国产精品伦一区二区三级视频 | 国产aⅴ | 国产精品一区二区三级 | 日本精品在线播放 | 国产精品伦一区二区三级视频 | 亚洲精选一区二区 | 伊人色综合久久天天五月婷 | 国产视频中文字幕 | 国产高清视频在线 | 亚洲欧洲一区 | 久久久999免费视频 999久久久久久久久6666 | 日韩欧美国产精品一区二区 | 久草网址 | 9191av| 日本在线黄色 | 一区二区三区久久 | 一区二区成人 | 国产精品日韩欧美一区二区 | 国产精品久久久久久吹潮 | 久久久久网站 | 成人1区| 精品国产一区二区三区久久影院 | 在线成人 | 偷拍自拍第一页 | 国产中文字幕在线观看 | 亚洲成人av在线播放 | 中文字幕人成乱码在线观看 | 欧美一区二区在线观看视频 | 亚洲精品视频在线观看视频 | 国产在线精品一区二区三区 | 在线观看亚洲欧美 | 高清视频一区 | 欧美www在线 |