FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-40366: Remove support for passing obsolete flags into compile by isidentical · Pull Request #19660 · python/cpython · GitHub

/ cpython Public

bpo-40366: Remove support for passing obsolete flags into compile - #19660

Closed
isidentical wants to merge 2 commits into
python:mainfrom
isidentical:bpo-40366
Closed

bpo-40366: Remove support for passing obsolete flags into compile#19660
isidentical wants to merge 2 commits into
python:mainfrom
isidentical:bpo-40366

Conversation

isidentical commented Apr 22, 2020
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

This PR also removes a case related CO_GENERATOR_ALLOWED (which was also unusable, and totally purged in #19230)

https://bugs.python.org/issue40366

vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

If CO_NESTED is no longer useful, why not removing the flag rather than adding a complicated deprecated code path? Passing flags to compile() is uncommon.

@serhiy-storchaka: Do you think that a deprecation period is needed?

Since how long CO_NESTED does nothing?

Copy link
Copy Markdown
Member Author

Since how long CO_NESTED does nothing?

2.2

Copy link
Copy Markdown
Member

Oh. If CO_NESTED is useless since Python 2.2 which was released 19 years ago, it's maybe time to remove it.

Copy link
Copy Markdown
Member Author

Does this removal will cover disallowing from __future__ import nested_functions (and probably generators, which was from 2.1)? I can convert this patch to that way

Copy link
Copy Markdown
Member

Does this removal will cover disallowing from future import nested_functions

I don't see any benefit from removing this import: it doesn't reduce the Python maintenance burden, it just breaks existing applications for free.

Most __future__ imports simply do nothing. Extract of Python/future.c:

        } else if (strcmp(feature, FUTURE_DIVISION) == 0) {
            continue;
        } else if (strcmp(feature, FUTURE_ABSOLUTE_IMPORT) == 0) {
            continue;
        } else if (strcmp(feature, FUTURE_WITH_STATEMENT) == 0) {
            continue;
        } else if (strcmp(feature, FUTURE_PRINT_FUNCTION) == 0) {
            continue;
        } else if (strcmp(feature, FUTURE_UNICODE_LITERALS) == 0) {
            continue;

isidentical changed the title bpo-40366: Deprecate passing obsoleted flags to compile bpo-40366: Remove support for passing obsolete flags into compile Apr 22, 2020

Copy link
Copy Markdown
Contributor

@isidentical Could you resolve the conflicts?

carljm commented May 10, 2023

Copy link
Copy Markdown
Member

FWIW, removal of CO_NESTED was discussed in #96811 and rejected, since it is still useful (to detect nested functions) and used in third-party code, and setting it doesn't cause any problems.

Copy link
Copy Markdown
Contributor

FWIW, removal of CO_NESTED was discussed in #96811 and rejected, since it is still useful (to detect nested functions) and used in third-party code, and setting it doesn't cause any problems.

In that case, I think we can close the PR. @isidentical What are your thoughts on this?

Comment thread Lib/test/test_builtin.py
compile('print("\xe5")\n', '', 'exec')
self.assertRaises(ValueError, compile, chr(0), 'f', 'exec')
self.assertRaises(ValueError, compile, str('a = 1'), 'f', 'bad')
self.assertRaises(ValueError, compile, 'obsolote_flag', 'f', 'exec', CO_NESTED)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
self.assertRaises(ValueError, compile, 'obsolote_flag', 'f', 'exec', CO_NESTED)
self.assertRaises(ValueError, compile, 'obsolete_flag', 'f', 'exec', CO_NESTED)

vstinner commented Sep 1, 2025

Copy link
Copy Markdown
Member

FWIW, removal of CO_NESTED was discussed in #96811 and rejected, since it is still useful (to detect nested functions) and used in third-party code, and setting it doesn't cause any problems.

Let met close this old inactive PR.

vstinner closed this Sep 1, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants


Back | FazBrowse Home | New Git URL