Title: Wrong conversion of division to old_div · Issue #434 · PythonCharmers/python-future · GitHub
Open Graph Title: Wrong conversion of division to old_div · Issue #434 · PythonCharmers/python-future
X Title: Wrong conversion of division to old_div · Issue #434 · PythonCharmers/python-future
Description: Example code The following code contains an old style division. (x / 2 * 3.0) The expected result The result running the above code with arbitrary values assigned to x should be the following, where the parentheses explicitly show the or...
Open Graph Description: Example code The following code contains an old style division. (x / 2 * 3.0) The expected result The result running the above code with arbitrary values assigned to x should be the following, wher...
X Description: Example code The following code contains an old style division. (x / 2 * 3.0) The expected result The result running the above code with arbitrary values assigned to x should be the following, wher...
Opengraph URL: https://github.com/PythonCharmers/python-future/issues/434
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Wrong conversion of division to old_div","articleBody":"Example code\r\n===========\r\nThe following code contains an old style division. \r\n```python\r\n(x / 2 * 3.0)\r\n```\r\n\r\nThe expected result\r\n================\r\nThe result running the above code with arbitrary values assigned to x should be the following, where the parentheses explicitly show the order of the operations `(x / 2) * 3.0`. Or written in another order the result should be evaluated as `x * (3.0 / 2)`.\r\n\r\nThe issue\r\n========\r\nOnce we run `futurize` on the code above, an `old_div` gets inserted by the `fix_division_safe` fixture. However as one can see in the diff below, the function gets called with a wrong order of arguments.\r\n```bash\r\n$ futurize --stage2 src/example.py\r\nRefactoringTool: Refactored src/example.py\r\n--- src/example.py (original)\r\n+++ src/example.py (refactored)\r\n@@ -1 +1,3 @@\r\n-(x / 2 * 3.0)\r\n+from __future__ import division\r\n+from past.utils import old_div\r\n+(old_div(x, 2 * 3.0))\r\nRefactoringTool: Files that need to be modified:\r\nRefactoringTool: src/example.py\r\n```\r\n\r\nExpected conversion\r\n=================\r\nAs already stated in the section 'expected result' the correct conversion should have been: `(old_div(x, 2) * 3.0)`","author":{"url":"https://github.com/wagnerpeer","@type":"Person","name":"wagnerpeer"},"datePublished":"2019-01-30T19:08:31.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":12},"url":"https://github.com/434/python-future/issues/434"}
| 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:a3fbf397-065b-31ad-c99c-2824f117cf8d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BD5E:A74F2:86FE42:B459A2:696979F6 |
| html-safe-nonce | f1ca57fdc21eac8fd0fff5718985395ab9c9dbe97a0fa578d5ee408898d17682 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDVFOkE3NEYyOjg2RkU0MjpCNDU5QTI6Njk2OTc5RjYiLCJ2aXNpdG9yX2lkIjoiNTg2OTQ2MzQ5MDU2NzY5ODkzNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 92e878a75b342d2be0ecd769849cd768f97e4e2b57f6dc9e44dba5f2a26766b4 |
| hovercard-subject-tag | issue:404919203 |
| 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/PythonCharmers/python-future/434/issue_layout |
| twitter:image | https://opengraph.githubassets.com/42bc93633bc412883f14a8f06e74e34d4d6fce67c17282c521360f219643f896/PythonCharmers/python-future/issues/434 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/42bc93633bc412883f14a8f06e74e34d4d6fce67c17282c521360f219643f896/PythonCharmers/python-future/issues/434 |
| og:image:alt | Example code The following code contains an old style division. (x / 2 * 3.0) The expected result The result running the above code with arbitrary values assigned to x should be the following, wher... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wagnerpeer |
| hostname | github.com |
| expected-hostname | github.com |
| None | c6f193beb8ff08443adc07685d75302ab8aaf0a135f6e251c3ff3112c8deb881 |
| turbo-cache-control | no-preview |
| go-import | github.com/PythonCharmers/python-future git https://github.com/PythonCharmers/python-future.git |
| octolytics-dimension-user_id | 3365815 |
| octolytics-dimension-user_login | PythonCharmers |
| octolytics-dimension-repository_id | 11403699 |
| octolytics-dimension-repository_nwo | PythonCharmers/python-future |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 11403699 |
| octolytics-dimension-repository_network_root_nwo | PythonCharmers/python-future |
| 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 | 212e3e3d3298bf5b313830edfd2399e869f7ea76 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width