Skip to content

bpo-45434: Mark the PyTokenizer C API as private #28924

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 1 commit into from
Oct 13, 2021
Merged

bpo-45434: Mark the PyTokenizer C API as private #28924

merged 1 commit into from
Oct 13, 2021

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Oct 13, 2021

Rename PyTokenize functions to mark them as private:

  • PyTokenizer_FindEncodingFilename() => _PyTokenizer_FindEncodingFilename()
  • PyTokenizer_FromString() => _PyTokenizer_FromString()
  • PyTokenizer_FromFile() => _PyTokenizer_FromFile()
  • PyTokenizer_FromUTF8() => _PyTokenizer_FromUTF8()
  • PyTokenizer_Free() => _PyTokenizer_Free()
  • PyTokenizer_Get() => _PyTokenizer_Get()

Remove the unused PyTokenizer_FindEncoding() function.

import.c: remove unused #include "errcode.h".

https://bugs.python.org/issue45434

Rename PyTokenize functions to mark them as private:

* PyTokenizer_FindEncodingFilename() => _PyTokenizer_FindEncodingFilename()
* PyTokenizer_FromString() => _PyTokenizer_FromString()
* PyTokenizer_FromFile() => _PyTokenizer_FromFile()
* PyTokenizer_FromUTF8() => _PyTokenizer_FromUTF8()
* PyTokenizer_Free() => _PyTokenizer_Free()
* PyTokenizer_Get() => _PyTokenizer_Get()

Remove the unused PyTokenizer_FindEncoding() function.

import.c: remove unused #include "errcode.h".
@vstinner
Copy link
Member Author

@pablogsal @isidentical @lysnikolaou: Do you see any reason to keep the PyTokenizer as public?

My plan is to move E_xxx constants from Include/errcode.h to Include/internal/pycore_parser.h, and then remove the Include/errcode.h header filer.

@isidentical
Copy link
Member

Do you see any reason to keep the PyTokenizer as public?

I don't see any reason for external apps to depend on these methods, especially when we already have a pure Python version.

@vstinner vstinner merged commit 713bb19 into python:main Oct 13, 2021
@vstinner vstinner deleted the private_tokenize branch October 13, 2021 15:22
@vstinner
Copy link
Member Author

My plan is to move E_xxx constants from Include/errcode.h to Include/internal/pycore_parser.h, and then remove the Include/errcode.h header filer.

In fact, it's not possible without breaking the backward compatibility: https://bugs.python.org/issue45434#msg403841

@vstinner
Copy link
Member Author

vstinner commented Oct 13, 2021

But marking the tokenizer C API as private is still worth it ;-)

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.

5 participants