GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-35105: Document that CPython accepts "invalid" identifiers by Windsooon · Pull Request #11263 · python/cpython

Conversation

@Windsooon

@Windsooon Windsooon commented Dec 20, 2018 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

https://bugs.python.org/issue35105

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Dec 20, 2018
@bedevere-bot bedevere-bot added docs Documentation in the Doc dir awaiting review labels Dec 20, 2018
@Windsooon
Windsooon force-pushed the bpo-35105 branch from b03e752 to a0e8550 Compare December 20, 2018 13:59
@terryjreedy
terryjreedy requested a review from vstinner December 20, 2018 21:30
terryjreedy
terryjreedy requested changes Dec 20, 2018
View reviewed changes

@terryjreedy terryjreedy left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That you for proposing something specific to chew on. I think spelling, grammar, and content all need tweaking.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/functions.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented Dec 20, 2018

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added awaiting changes and removed awaiting review labels Dec 20, 2018
@zhangyangyu

zhangyangyu commented Dec 21, 2018

Copy link
Copy Markdown
Member

Do we really need to mention this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zhangyangyu
zhangyangyu requested a review from rhettinger December 21, 2018 03:37
@terryjreedy

terryjreedy commented Dec 21, 2018

Copy link
Copy Markdown
Member

That discussion is on the issue.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rhettinger
rhettinger requested changes Dec 24, 2018
View reviewed changes

@rhettinger rhettinger left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can mark this as an implementation detail for setattr(). The details are downstream and determined by the target object, not by setattr itself.

Suggested wording:

Note, setattr() attempts to update the object with the given attr/value pair.
Whether this succeeds and what its affect is is determined by the target object.
If an object's class defines `__slots__`, the attribute may not be writeable.
If an object's class defines property with a setter method, the *setattr()*
will trigger the setter method which may or may not actually write the attribute.
For objects that have a regular dictionary (which is the typical case), the
*setattr()* call can make any string keyed update allowed by the dictionary
including keys that aren't valid identifiers -- for example setattr(a, '1', 'one')
will be the equivalent of vars()['1'] ='one'.

This issue has little to do with setattr() and is more related to the fact that instance dictionaries can hold any valid key. In a way, it is no different than a user writing a.__dict__['1'] = 'one'. That has always been allowed and the __dict__ attribute is documented as writeable, so a user is also allowed to write `a.dict = {'1': 'one'}.

In short, we can talk about this in the setattr() docs but it isn't really a setattr() issue. Also, the behavior is effectively guaranteed by the other things users are allowed to do, so there is no merit in marking this as an implementation detail. Non-identifier keys can make it into an instance dictionary via multiple paths that are guaranteed to work.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@terryjreedy

terryjreedy commented Dec 24, 2018

Copy link
Copy Markdown
Member

I agree with Raymond's revision. Note that it would replace the entire proposed addition, including the impl-detail directive. By adding more 'meat', it makes an addition more worthwhile.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Windsooon
bpo-35105: Document that CPython accepts invalid identifiers
f47c3de
@Windsooon
Windsooon force-pushed the bpo-35105 branch from a0e8550 to f47c3de Compare January 26, 2019 02:57
csabella
csabella requested changes May 29, 2019
View reviewed changes

@csabella csabella left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole note needs to be indented for proper alignment.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
csabella
csabella reviewed May 29, 2019
View reviewed changes
Comment thread Doc/library/functions.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

csabella
csabella reviewed May 29, 2019
View reviewed changes
Comment thread Doc/library/functions.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

csabella
csabella reviewed May 29, 2019
View reviewed changes
Comment thread Doc/library/functions.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

csabella
csabella reviewed May 29, 2019
View reviewed changes
Comment thread Doc/library/functions.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@JulienPalard

JulienPalard commented Sep 11, 2019

Copy link
Copy Markdown
Member

Hi @Windsooon thanks for this PR! Would you have some time to integrate Cheryl comments?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JulienPalard JulienPalard added the skip news label Sep 11, 2019
@Windsooon
fix docs format depend on review
7185897
@Windsooon

Windsooon commented Sep 11, 2019

Copy link
Copy Markdown
Contributor Author

I just updated it. Thank you @csabella

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JulienPalard
JulienPalard requested changes Sep 12, 2019
View reviewed changes

@JulienPalard JulienPalard left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nits (all can be accepted right from github).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/functions.rst

.. note::

setattr() attempts to update the object with the given attr/value pair.

@JulienPalard JulienPalard Sep 12, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setattr() attempts to update the object with the given attr/value pair.
``setattr()`` attempts to update the object with the given attr/value pair.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/functions.rst

setattr() attempts to update the object with the given attr/value pair.
Whether this succeeds and the effect it has determined by the target object.
If an object's class defines `__slots__`, the attribute may not be writeable.

@JulienPalard JulienPalard Sep 12, 2019

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If an object's class defines `__slots__`, the attribute may not be writeable.
If an object's class defines ``__slots__``, the attribute may not be writeable.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/functions.rst
For objects that have a regular dictionary (which is the typical case), the
*setattr()* call can make any string keyed update allowed by the dictionary
including keys that aren't valid identifiers -- for example ``setattr(a, '1', 'one')``
will be the equivalent of ``vars()['1'] ='one'``.

@JulienPalard JulienPalard Sep 12, 2019

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
will be the equivalent of ``vars()['1'] ='one'``.
will be the equivalent of ``vars()['1'] = 'one'``.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@csabella

csabella commented Jan 12, 2020

Copy link
Copy Markdown
Contributor

@Windsooon, please address the review comments from Julien. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AlexWaygood

AlexWaygood commented Apr 17, 2022

Copy link
Copy Markdown
Member

Changes were requested on this PR by a core dev over two years ago, but have not been applied. There is also now a merge conflict. I am therefore closing this PR.

@Windsooon, if you're still interested in working on this, feel free to open a new PR. Alternatively, ping me, and I'll happily reopen the PR. Thanks! 🙂

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AlexWaygood AlexWaygood closed this Apr 17, 2022
@Windsooon

Windsooon commented Apr 21, 2022

Copy link
Copy Markdown
Contributor Author

@AlexWaygood I'm so sorry for missing the notification from CPython, I will catch up in a few weeks.

AlexWaygood reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AlexWaygood

AlexWaygood commented Apr 21, 2022

Copy link
Copy Markdown
Member

@Windsooon no worries!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AlexWaygood AlexWaygood reopened this Apr 21, 2022
@ezio-melotti ezio-melotti removed the CLA signed label Jul 13, 2022
slateny
slateny reviewed Oct 11, 2022
View reviewed changes
Comment thread Doc/library/functions.rst

.. note::

setattr() attempts to update the object with the given attr/value pair.

@slateny slateny Oct 10, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(in addition to the above)

Suggested change
setattr() attempts to update the object with the given attr/value pair.
setattr() attempts to update the object with the given attribute/value pair.

or

Suggested change
setattr() attempts to update the object with the given attr/value pair.
setattr() attempts to update the object with the given attribute-value pair.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/functions.rst
.. note::

setattr() attempts to update the object with the given attr/value pair.
Whether this succeeds and the effect it has determined by the target object.

@slateny slateny Oct 10, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Whether this succeeds and the effect it has determined by the target object.
Whether this succeeds and the effect it has is determined by the target object.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/functions.rst
setattr() attempts to update the object with the given attr/value pair.
Whether this succeeds and the effect it has determined by the target object.
If an object's class defines `__slots__`, the attribute may not be writeable.
If an object's class defines :class:`property` with a setter method, the *setattr()*

@slateny slateny Oct 11, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*setattr()* -> `setattr()` here and below (I think * is commonly used for parameters)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/functions.rst
will trigger the setter method which may or may not actually write the attribute.
For objects that have a regular dictionary (which is the typical case), the
*setattr()* call can make any string keyed update allowed by the dictionary
including keys that aren't valid identifiers -- for example ``setattr(a, '1', 'one')``

@slateny slateny Oct 11, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you happen to have an example of this behavior? I'm not quite following what it's doing (how a turns into vars())

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/functions.rst
If an object's class defines :class:`property` with a setter method, the *setattr()*
will trigger the setter method which may or may not actually write the attribute.
For objects that have a regular dictionary (which is the typical case), the
*setattr()* call can make any string keyed update allowed by the dictionary

@slateny slateny Oct 11, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*setattr()* call can make any string keyed update allowed by the dictionary
*setattr()* call can make any string-keyed update allowed by the dictionary

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@AlexWaygood

AlexWaygood commented Oct 11, 2022

Copy link
Copy Markdown
Member

I think this PR has now been superseded by #96454

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AlexWaygood AlexWaygood closed this Oct 11, 2022
@vstinner vstinner mentioned this pull request Oct 11, 2022
Document that CPython accepts "invalid" identifiers #79286
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@terryjreedy terryjreedy terryjreedy requested changes
@csabella csabella csabella requested changes
@slateny slateny slateny left review comments
@JulienPalard JulienPalard JulienPalard requested changes
@rhettinger rhettinger rhettinger requested changes
@vstinner vstinner Awaiting requested review from vstinner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting changes docs Documentation in the Doc dir skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

11 participants

@Windsooon @bedevere-bot @zhangyangyu @terryjreedy @JulienPalard @csabella @AlexWaygood @rhettinger @slateny @the-knights-who-say-ni @ezio-melotti
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.