Title: Inconsistent behaviors for Parser().parsestr(t).keys() in email.parser · Issue #4936 · RustPython/RustPython · GitHub
Open Graph Title: Inconsistent behaviors for Parser().parsestr(t).keys() in email.parser · Issue #4936 · RustPython/RustPython
X Title: Inconsistent behaviors for Parser().parsestr(t).keys() in email.parser · Issue #4936 · RustPython/RustPython
Description: The following code first sets the value of the variable maxsize to 8. The code then constructs a sample email message string t, consisting of multiple header fields and their values. The Parser class is then used to parse this message st...
Open Graph Description: The following code first sets the value of the variable maxsize to 8. The code then constructs a sample email message string t, consisting of multiple header fields and their values. The Parser cla...
X Description: The following code first sets the value of the variable maxsize to 8. The code then constructs a sample email message string t, consisting of multiple header fields and their values. The Parser cla...
Opengraph URL: https://github.com/RustPython/RustPython/issues/4936
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inconsistent behaviors for Parser().parsestr(t).keys() in email.parser","articleBody":"The following code first sets the value of the variable maxsize to 8. The code then constructs a sample email message string t, consisting of multiple header fields and their values. The Parser class is then used to parse this message string into an email message object. The keys() method of this object is called to retrieve the list of header field names, which is then printed to the console. The output of this case is ['From', 'Foo'] on RustPython, while it is ['From', 'Foo', 'Bar'] on CPython. \r\n\r\nMoreover, if we set the maxsize as 8192, i.e., maxsize = 8192, CPython can still work normally, RustPython reports a ValueError.\r\n\r\ntest.py\r\n```\r\nfrom email.parser import Parser\r\nmaxsize = 8\r\nt = 'From: \u003ce@example.com\u003e\\nFoo: '\r\nt += 'x' * ((-len(t) - 1) % maxsize) + '\\rBar: '\r\nt += 'y' * ((-len(t) - 1) % maxsize) + '\\x85Baz: '\r\nt += 'z' * ((-len(t) - 1) % maxsize) + '\\n\\n'\r\nprint(Parser().parsestr(t).keys())\r\n\r\n```\r\nBehaviors on CPython 3.8.0,3.9.0,3.11.3:\r\n['From', 'Foo', 'Bar'] \r\n\r\nBehaviors on RustPython 0.2.0:\r\n['From', 'Foo'] \r\n\r\nAfter setting the maxsize as 8192, the behavior on RustPython 0.2.0 is as follows:\r\n```\r\nTraceback (most recent call last):\r\n File \"/home/xxm/Desktop/RustPython/test.py\", line 586, in \u003cmodule\u003e\r\n print(Parser().parsestr(t).keys())\r\n File \"/home/xxm/.cargo/git/checkouts/rustpython-f8ef4d934ac33cd8/0284059/pylib/Lib/email/parser.py\", line 68, in parsestr\r\n return self.parse(StringIO(text), headersonly=headersonly)\r\n File \"/home/xxm/.cargo/git/checkouts/rustpython-f8ef4d934ac33cd8/0284059/pylib/Lib/email/parser.py\", line 54, in parse\r\n data = fp.read(8192)\r\nValueError: Error Retrieving Value\r\n```\r\nEnvironment:\r\nUbuntu 18.04\r\nRustPython 0.2.0 [0284059](https://github.com/RustPython/RustPython/commit/02840593bc56ae416ba2646166628f1712d6cf43)\r\nCPython 3.8.0, 3.9.0, 3.11.3","author":{"url":"https://github.com/xiaxinmeng","@type":"Person","name":"xiaxinmeng"},"datePublished":"2023-04-28T05:53:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/4936/RustPython/issues/4936"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9cfd33ad-9888-142c-f915-cc4b6d35f039 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8A62:1A456E:986D69:CCFB20:6A62A18E |
| html-safe-nonce | 96004e8b5480325409c42e3a59d752f5c7e5a91257b469e6c4d4d86d96f4d666 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTYyOjFBNDU2RTo5ODZENjk6Q0NGQjIwOjZBNjJBMThFIiwidmlzaXRvcl9pZCI6IjEyMzgyOTgzMTM3MDU1NjI1MTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3904f444055b538b2a22b70037eff8793af6d7851acfaf8c6dcc131abcb44a2e |
| hovercard-subject-tag | issue:1687943018 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/RustPython/RustPython/4936/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4da227c211ac40867ea1174f980e319fdab60f1a1654e40094e1361e531bcb15/RustPython/RustPython/issues/4936 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4da227c211ac40867ea1174f980e319fdab60f1a1654e40094e1361e531bcb15/RustPython/RustPython/issues/4936 |
| og:image:alt | The following code first sets the value of the variable maxsize to 8. The code then constructs a sample email message string t, consisting of multiple header fields and their values. The Parser cla... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | xiaxinmeng |
| hostname | github.com |
| expected-hostname | github.com |
| None | a6443033349a18134b517627f043d4a59a5110337b879810c7229c2c7e28eda0 |
| turbo-cache-control | no-preview |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d6c6cacbe32d3ddfd1796fbd1a39b8fb47b87daf |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width