Skip to content

Update _dill.py to use co_linetable for Python 3.10+ in place of co_lnotab #7609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 16, 2025

Conversation

qgallouedec
Copy link
Member

@qgallouedec qgallouedec commented Jun 12, 2025

Not 100% about this one, but it seems to be recommended.

/fsx/qgallouedec/miniconda3/envs/trl/lib/python3.12/site-packages/datasets/utils/_dill.py:385: DeprecationWarning: co_lnotab is deprecated, use co_lines instead.

Tests pass locally. And the warning is gone with this change.

https://peps.python.org/pep-0626/#backwards-compatibility

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@qgallouedec qgallouedec marked this pull request as ready for review June 12, 2025 14:20
@qgallouedec qgallouedec requested review from Copilot and lhoestq June 12, 2025 14:20
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the handling of code object line information to address the deprecation of co_lnotab in Python 3.10+ by conditionally using an alternative attribute.

  • Replace co_lnotab with co_linetable in multiple functions.
  • Remove deprecation warnings in Python 3.12 by conditionally checking sys.version_info.
Comments suppressed due to low confidence (1)

src/datasets/utils/_dill.py:272

  • The PR title mentions using 'co_lines' instead of 'co_lnotab', but the changes use 'co_linetable'. Please verify that 'co_linetable' is the intended attribute for Python 3.10+ to ensure consistency with the proposed update.
obj.co_linetable if sys.version_info >= (3, 10) else obj.co_lnotab,

@lhoestq
Copy link
Member

lhoestq commented Jun 12, 2025

not 100% sure either, I tried removing unnecessary checks - let me know if they sound good to you otherwise I'll revert

@lhoestq lhoestq changed the title Update _dill.py to use co_lines for Python 3.10+ in place of co_lnotab Update _dill.py to use co_linetable for Python 3.10+ in place of co_lnotab Jun 12, 2025
@qgallouedec
Copy link
Member Author

I can't reproduce the warning anymore... 🤦🏻‍♂️

@qgallouedec
Copy link
Member Author

Ah now I can reproduce!, and I can confirm that the warning is gone when you apply the change in this PR

Copy link
Member

@lhoestq lhoestq left a comment

Choose a reason for hiding this comment

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

thanks !

@lhoestq lhoestq merged commit 3573d75 into main Jun 16, 2025
9 of 15 checks passed
@lhoestq lhoestq deleted the qgallouedec-patch-1 branch June 16, 2025 12:14
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.

3 participants