Skip to content

Add warning for 5 features.#46

Open
Eddy114514 wants to merge 3 commits intosoftdevteam:migrationfrom
Eddy114514:imporve
Open

Add warning for 5 features.#46
Eddy114514 wants to merge 3 commits intosoftdevteam:migrationfrom
Eddy114514:imporve

Conversation

@Eddy114514
Copy link
Collaborator

This PR adds 5 new Python 2 -> Python 3 compatibility warnings on the pygrate2 side.

  • iterator.next() warning
    Added a warning in wrap_next() for iterator-style .next() calls. In Python 2, iterators commonly use it.next(), while the supported form in python3 is next(it)

  • intern() warning
    Added a warning in builtin_intern() for builtin intern() calls. In Python 2, intern() is a builtin, while in Python 3 the supported form is sys.intern().

  • range() materialization warning
    Added a warning in builtin_range() for range() results used in list-like contexts that may require materialization. In Python 2, range() returns a list, while in Python 3 it returns a lazy range object, so code such as range(5) + [5] may need to become list(range(5)) + [5].

  • xrange() materialization warning
    Refined the warning in range_new() for xrange() calls to distinguish plain iteration from list-like use. In Python 2, xrange() exists as a lazy iterator-like object, while in Python 3 it is removed and range() is the replacement; in some non-iteration contexts, the result may additionally need list materialization.

  • dict list-like consumer warning
    Added warnings in dict_keys(), dict_values(), and dict_items() when d.keys(), d.values(), or d.items() are used in list-like contexts. In Python 2, these APIs return lists, while in Python 3 they return view objects, so operations such as indexing or list concatenation may require wrapping them with list(...).

Also add corresponding test in the test_py3kwarn.py

Eddy Xu added 2 commits March 18, 2026 17:23
fix some design issues.
@Eddy114514
Copy link
Collaborator Author

@ltratt Thanks for pointing out, I have resolved the above suggestions and questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants