Issue 28315: incorrect "in ?" output in 'divide' example at "Defining Clean-up Actions" in tutorial (original) (raw)

Created on 2016-09-30 00:17 by viorel, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue28315.patch Mariatta,2016-09-30 02:55 review
all_rst_patch_default.diff jaysinh.shukla,2016-10-05 12:04 rst patch for `default` branch review
v_2_7_conflict_files.diff jaysinh.shukla,2016-10-05 12:05 rst patch for `2.7` branch for rejected files from `default` patch review
Pull Requests
URL Status Linked Edit
PR 1372 merged jaysinh.shukla,2017-05-02 07:00
PR 1445 merged Mariatta,2017-05-04 01:08
PR 1446 merged Mariatta,2017-05-04 01:08
PR 1447 merged Mariatta,2017-05-04 01:47
Messages (19)
msg277731 - (view) Author: Viorel Tabara (viorel) Date: 2016-09-30 00:17
At https://docs.python.org/3.5/tutorial/errors.html#defining-clean-up-actions when I'm running the "divide('2', '1')" example I get: File "", line 1, in instead of the documentation output of: File "", line 1, in ? The same message is included with the 2.7 tutorial. To wit: $ python3 Python 3.5.2 (default, Sep 14 2016, 11:28:32) [GCC 6.2.1 20160901 (Red Hat 6.2.1-1)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> def divide(x, y): ... try: ... result = x / y ... except ZeroDivisionError: ... print('division by zero!') ... else: ... print('result is', result) ... finally: ... print('executing finally clause') ... >>> divide(2, 1) result is 2.0 executing finally clause >>> divide(2, 0) division by zero! executing finally clause >>> divide('2', '1') executing finally clause Traceback (most recent call last): File "", line 1, in File "", line 3, in divide TypeError: unsupported operand type(s) for /: 'str' and 'str' $ python2 Python 2.7.12 (default, Sep 2 2016, 15:40:50) [GCC 6.2.1 20160901 (Red Hat 6.2.1-1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def divide(x, y): ... result = x / y KeyboardInterrupt >>> def divide(x, y): ... try: ... result = x / y ... except ZeroDivisionError: ... print('division by zero!') ... else: ... print('result is', result) ... finally: ... print('executing finally clause') ... >>> divide(2, 1) ('result is', 2) executing finally clause >>> divide(2, 0) division by zero! executing finally clause >>> divide('2', '1') executing finally clause Traceback (most recent call last): File "", line 1, in File "", line 3, in divide TypeError: unsupported operand type(s) for /: 'str' and 'str' Nice tutorial by the way ;) Thanks!
msg277733 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2016-09-30 00:35
Thanks for the report. I agree, it should be instead of ? I'll work on a patch for this :)
msg277734 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2016-09-30 02:55
Updated the documentation to use instead of ? I also went through other examples in the page and fixed those too.
msg277770 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-09-30 19:51
Pushed to all 4 versions in ce57a74b5223, 1bead1f0260f, c729a62d4ec5, and 89cc2a6b64aa, but I gave issue # as 28815 instead of 28315. Thanks for the clean patch for 3.5. It mostly worked for 2.7, which also had an additional item not in 3.5. The only other file in /Doc with 'in ?' is Doc/includes/test.py, which is mostly a doctest docstring. The test obviously have not been run for years and the directory puzzles me, so I left it alone.
msg278021 - (view) Author: Jaysinh shukla (jaysinh.shukla) * Date: 2016-10-04 09:00
According to this email, conversation with Terry, https://mail.python.org/mailman/private/core-mentorship/2016-October/003662.html adding patch for `Doc/library/ctypes.rst`
msg278022 - (view) Author: Jaysinh shukla (jaysinh.shukla) * Date: 2016-10-04 09:06
@Treyy: I have uploaded patches according to your comment at Core mentorship here (https://mail.python.org/mailman/private/core-mentorship/2016-October/003662.html) `Since I applied the patch, I can say in in this particular case, re-open, preferably with one or more patches. I intended to include all changes needed, at least for .rst files, and grepped with IDLE's re-based grep, but missed most of what you listed. I probably started in the wrong directory. But exclude 1. the .rej files, which are not tracked, and which you should delete. 2. the old 'What's New' files, where 'in ?' is likely correct. 3. the includes/text/py files, for reasons given in the issue. 4. the other .py files, like test_generators.py, at least initially, until it is determined why they are not failing if incorrect. Left are *.rst. At least some of the code should be run to verify that the proposed changes are correct. I would not mind a separate patch for ctypes.rst, which has half the hits. If you only reopen and do not do a patch, please copy these comments into the issue.` Please change the status of issue to `open` from `close`. Thanks!
msg278093 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-10-04 23:13
Jaysinh, unless a patch for 3.5 does not cleanly apply to 3.6, or the patch must be different in 3.6*, no 3.6 patch is needed. Ditto for 3.7/default. Mariatta's patch merged forward without problem. *In this case, 'must be different' would be because there are different code examples. The same is true for 2.7 if the 3.x patch applies cleanly there (though this is less common there). Mariatta's patch also applied to 2.7, though as I reported, I found one more change for 2.7. So when you revise in response to comments, one of each patch is enough unless you know more are needed, in which case say so. If there are problems forward-merging the other_rst patch, please report first before preparing a 3.6 patch. If there were a problem with just one of the files, I would prpbably want a 3.6 patch just for the one file. I discovered a deeper problem. In spite of the doctest annotations, the doctests is not run on the ctypes doc and at least one of the tracebacks is wrong. >>> windll.kernel32.GetModuleHandleA() # doctest: +WINDOWS Traceback (most recent call last): File "", line 1, in ? ValueError: Procedure probably called with not enough arguments (4 bytes missing) >>> windll.kernel32.GetModuleHandleA(0, 0) # doctest: +WINDOWS Traceback (most recent call last): File "", line 1, in ? ValueError: Procedure probably called with too many arguments (4 bytes in excess) whereas, on Win10, 3.5 >>> from ctypes import * >>> windll.kernel32.GetModuleHandleA() 0 >>> windll.kernel32.GetModuleHandleA(0, 0) 480968704 However, when I ran make doctest, these did not show up, but they were not run. I will worry about this as a separate issue. >>> windll.kernel32.GetModuleHandleA() 477822976 >>> windll.kernel32.GetModuleHandleA(0, 0) 477822976
msg278120 - (view) Author: Jaysinh shukla (jaysinh.shukla) * Date: 2016-10-05 12:17
Hello Terry, According to your instructions I had uploaded two patch files. The file named `all_rst_patch_default.diff` is applicable for version `default`, `3.5`, `3.6` and for most files of `2.7`. The file named `v_2_7_conflict_files.diff` is a correct patch of all rejected files. I have unlinked previous patch files. Please guide me if I had done mistake at any stage. Many Thanks!
msg278253 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2016-10-07 16:30
Hi Jaysinh, I reviewed your changes, they look good to me. I can't approve it, so it would still be good for a core dev here to take another pass. Thanks :)
msg292333 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2017-04-26 11:09
@Mariatta I believe you can do this now?
msg292672 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-05-01 16:30
Jaysinh, are you up for preparing a PR based on you patch? Start with the master branch. Thanks.
msg292714 - (view) Author: Jaysinh shukla (jaysinh.shukla) * Date: 2017-05-02 05:16
Thanks Mariatta for reminding. Please expect a Github PR from my side in next 2 days.
msg292925 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-05-03 16:46
New changeset 8856940cf2e82cb17db2b684cd5732fe658605ca by Mariatta (UltimateCoder) in branch 'master': bpo-28315: Improve code examples in docs (GH-1372) https://github.com/python/cpython/commit/8856940cf2e82cb17db2b684cd5732fe658605ca
msg292937 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-05-03 20:23
Mariatta, please continue with this and assign to yourself. I now have IDLE PRs to review and apply.
msg292938 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-05-03 20:30
For sure :) Thanks Terry.
msg292951 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-05-04 01:41
New changeset 5274faf5e360f74690ffb735e919cdba5fdbdf1c by Mariatta in branch '3.5': [3.5] bpo-28315: Improve code examples in docs (GH-1372) (#1446) https://github.com/python/cpython/commit/5274faf5e360f74690ffb735e919cdba5fdbdf1c
msg292952 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-05-04 01:41
New changeset af71364c3f0e9cd6cb9d83194315af0ee3c783d2 by Mariatta in branch '3.6': [3.6] bpo-28315: Improve code examples in docs (GH-1372) (#1445) https://github.com/python/cpython/commit/af71364c3f0e9cd6cb9d83194315af0ee3c783d2
msg292953 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-05-04 01:54
New changeset e1b02ff58883c68d3a5e549aa33c6dd94f915bd6 by Mariatta in branch '2.7': [2.7] bpo-28315: Improve code examples in docs (GH-1372) (#1447) https://github.com/python/cpython/commit/e1b02ff58883c68d3a5e549aa33c6dd94f915bd6
msg292954 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-05-04 01:56
We can finally close this. Thanks everyone :)
History
Date User Action Args
2022-04-11 14:58:37 admin set github: 72502
2017-05-04 01:56:16 Mariatta set status: open -> closedmessages: + stage: backport needed -> resolved
2017-05-04 01:54:30 Mariatta set messages: +
2017-05-04 01:47:49 Mariatta set pull_requests: + <pull%5Frequest1545>
2017-05-04 01:41:22 Mariatta set messages: +
2017-05-04 01:41:14 Mariatta set messages: +
2017-05-04 01:08:30 Mariatta set pull_requests: + <pull%5Frequest1544>
2017-05-04 01:08:19 Mariatta set pull_requests: + <pull%5Frequest1543>
2017-05-03 20:30:08 Mariatta set assignee: Mariattamessages: +
2017-05-03 20:23:28 terry.reedy set assignee: terry.reedy -> (no value)messages: +
2017-05-03 16:47:55 Mariatta set stage: resolved -> backport needed
2017-05-03 16:46:47 Mariatta set messages: +
2017-05-02 07:00:53 jaysinh.shukla set pull_requests: + <pull%5Frequest1480>
2017-05-02 05:16:06 jaysinh.shukla set messages: +
2017-05-01 16:30:08 Mariatta set messages: +
2017-04-26 11:09:11 cheryl.sabella set nosy: + cheryl.sabellamessages: +
2016-10-07 16:30:07 Mariatta set messages: +
2016-10-05 12:17:19 jaysinh.shukla set messages: +
2016-10-05 12:09:06 jaysinh.shukla set files: - other_rst_version_3_6.diff
2016-10-05 12:09:01 jaysinh.shukla set files: - other_rst_version_3_5.diff
2016-10-05 12:08:54 jaysinh.shukla set files: - other_rst_version_2_7.diff
2016-10-05 12:08:48 jaysinh.shukla set files: - other_rst_default.diff
2016-10-05 12:08:12 jaysinh.shukla set files: - Doc_library_ctypes_rst_version_3_6.diff
2016-10-05 12:08:07 jaysinh.shukla set files: - Doc_library_ctypes_rst_version_3_5.diff
2016-10-05 12:08:02 jaysinh.shukla set files: - Doc_library_ctypes_rst_version_2_7.diff
2016-10-05 12:07:55 jaysinh.shukla set files: - Doc_library_ctypes_rst_default.diff
2016-10-05 12:05:54 jaysinh.shukla set files: + v_2_7_conflict_files.diff
2016-10-05 12:04:46 jaysinh.shukla set files: + all_rst_patch_default.diff
2016-10-04 23:13:29 terry.reedy set messages: +
2016-10-04 15:25:32 terry.reedy set status: closed -> open
2016-10-04 09:06:16 jaysinh.shukla set messages: +
2016-10-04 09:04:09 jaysinh.shukla set files: + other_rst_version_3_6.diff
2016-10-04 09:04:01 jaysinh.shukla set files: + other_rst_version_3_5.diff
2016-10-04 09:03:54 jaysinh.shukla set files: + other_rst_version_2_7.diff
2016-10-04 09:03:35 jaysinh.shukla set files: + other_rst_default.diff
2016-10-04 09:03:03 jaysinh.shukla set files: + Doc_library_ctypes_rst_version_3_6.diff
2016-10-04 09:02:21 jaysinh.shukla set files: + Doc_library_ctypes_rst_version_3_5.diff
2016-10-04 09:02:05 jaysinh.shukla set hgrepos: - hgrepo357
2016-10-04 09:02:01 jaysinh.shukla set hgrepos: - hgrepo358
2016-10-04 09:01:53 jaysinh.shukla set files: + Doc_library_ctypes_rst_version_2_7.diffhgrepos: + hgrepo358
2016-10-04 09:00:41 jaysinh.shukla set files: + Doc_library_ctypes_rst_default.diffhgrepos: + hgrepo357messages: +
2016-10-04 08:55:53 jaysinh.shukla set nosy: + jaysinh.shukla
2016-09-30 19:51:29 terry.reedy set status: open -> closedresolution: fixedmessages: + stage: commit review -> resolved
2016-09-30 19:07:08 terry.reedy set assignee: docs@python -> terry.reedystage: commit reviewnosy: + terry.reedyversions: + Python 3.6, Python 3.7
2016-09-30 02:55:12 Mariatta set files: + issue28315.patchkeywords: + patchmessages: +
2016-09-30 00:35:42 Mariatta set messages: +
2016-09-30 00:24:39 Mariatta set nosy: + Mariatta
2016-09-30 00:17:25 viorel create