Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue17660

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:mock.patch could whitelist builtins to not need create=True
Type:behaviorStage:resolved
Components:Library (Lib)Versions:Python 3.5
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: michael.foordNosy List: berker.peksag, eric.araujo, kushal.das, michael.foord, pitrou, python-dev
Priority:normalKeywords:easy, patch

Created on2013-04-08 10:48 bymichael.foord, last changed2022-04-11 14:57 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
issue17660.patchkushal.das,2013-04-08 13:26initial patchreview
issue17660_v3.patchkushal.das,2014-04-14 17:07Updated patch with builtins module.review
Messages (11)
msg186290 -(view)Author: Michael Foord (michael.foord)*(Python committer)Date: 2013-04-08 10:48
When patching builtin names (e.g. open) in a specific namespace you need to specify "create=True" or patch will refuse to create a name that doesn't exist.patch could whitelist the builtin names, when the patch target is a module object, to not require the "create=True".
msg186291 -(view)Author: Kushal Das (kushal.das)*(Python committer)Date: 2013-04-08 10:52
Working on this.
msg186301 -(view)Author: Kushal Das (kushal.das)*(Python committer)Date: 2013-04-08 13:26
Initial patchset along with documentation and tests update.
msg186323 -(view)Author: Antoine Pitrou (pitrou)*(Python committer)Date: 2013-04-08 18:17
To be honest this proposal sounds like a quirk more than a feature to me. If you only special-case builtins, people will have to remember that special case and it will make the API more complicated.
msg186347 -(view)Author: Michael Foord (michael.foord)*(Python committer)Date: 2013-04-08 21:02
I don't think that's a particular issue. In general you only need to use "create=True" if a name is *not* available in a namespace. Builtin names are odd in that you can use them in a namespace even though they don't exist there - so you have to *remember* to use "create=True" even though the name *is* available. So this issue is about fixing that quirk.
msg215917 -(view)Author: Éric Araujo (eric.araujo)*(Python committer)Date: 2014-04-11 06:21
Reviewed on Rietveld.
msg216113 -(view)Author: Kushal Das (kushal.das)*(Python committer)Date: 2014-04-14 17:07
Updated patch with builtins module.
msg216201 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2014-04-14 20:25
New changesete457de60028c by Michael Foord in branch 'default':Closesissue 17660. You no longer need to explicitly pass create=True when patching builtin names.http://hg.python.org/cpython/rev/e457de60028c
msg216360 -(view)Author: Berker Peksag (berker.peksag)*(Python committer)Date: 2014-04-15 18:52
+    .. note::I think using a note directive is not necessary here. Also it looks a bit ugly :)https://dl.dropboxusercontent.com/u/166024/issue17660.png+        .. versionchanged:: 3.5+           If you are patching builtins in a module then you don't+           need to pass `create=True`, it will be added by default.
msg216364 -(view)Author: Michael Foord (michael.foord)*(Python committer)Date: 2014-04-15 19:26
Personally I don't think it looks ugly and that it is a point worth calling out. Other opinions welcomed.
msg216366 -(view)Author: Éric Araujo (eric.araujo)*(Python committer)Date: 2014-04-15 19:28
I noticed this in the commit; I don’t think the rendered output is really ugly, but the markup does look strange, as it’s two nested note(-like) directives.
History
DateUserActionArgs
2022-04-11 14:57:44adminsetgithub: 61860
2014-04-15 19:28:37eric.araujosetmessages: +msg216366
2014-04-15 19:26:09michael.foordsetmessages: +msg216364
2014-04-15 18:52:49berker.peksagsetnosy: +berker.peksag
messages: +msg216360
2014-04-14 20:25:31python-devsetstatus: open -> closed

nosy: +python-dev
messages: +msg216201

resolution: fixed
stage: patch review -> resolved
2014-04-14 17:53:49eric.araujosetversions: + Python 3.5, - Python 3.4
2014-04-14 17:07:41kushal.dassetfiles: +issue17660_v3.patch

messages: +msg216113
versions: + Python 3.4, - Python 3.5
2014-04-11 06:21:00eric.araujosetversions: + Python 3.5, - Python 3.4
nosy: +eric.araujo

messages: +msg215917

stage: needs patch -> patch review
2013-04-08 21:02:08michael.foordsetmessages: +msg186347
2013-04-08 18:17:07pitrousetnosy: +pitrou
messages: +msg186323
2013-04-08 13:26:19kushal.dassetfiles: +issue17660.patch
keywords: +patch
messages: +msg186301
2013-04-08 10:52:24kushal.dassetnosy: +kushal.das
messages: +msg186291
2013-04-08 10:48:09michael.foordcreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp