Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

gh-145980: Add support for alternative alphabets in the binascii module#145981

Open
serhiy-storchaka wants to merge 11 commits intopython:mainfrom
serhiy-storchaka:binascii-alphabet
Open

gh-145980: Add support for alternative alphabets in the binascii module#145981
serhiy-storchaka wants to merge 11 commits intopython:mainfrom
serhiy-storchaka:binascii-alphabet

Conversation

@serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Mar 15, 2026

  • Add the alphabet parameter in functions b2a_base64(), a2b_base64(), b2a_base85() and a2b_base85().
  • And a number of "*_ALPHABET" constants.
  • Remove b2a_z85() and a2b_z85().

📚 Documentation preview 📚: https://cpython-previews--145981.org.readthedocs.build/

…i module

* Add the alphabet parameter in functions b2a_base64(), a2b_base64(),
  b2a_base85() and a2b_base85().
* And a number of "*_ALPHABET" constants.
* Remove b2a_z85() and a2b_z85().

.. data:: UU_ALPHABET

The Uuencoding alphabet.
Copy link
Member

Choose a reason for hiding this comment

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

I think it's uuencoding for Unix-to-Unix instead of Uuencoding. I would suggest that you also link the Wikipedia page maybe?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wrote "Uuencoding" because this is how it is written in https://en.wikipedia.org/wiki/Base64.

There are no any links for a2b_uu() and b2a_uu(). There were no links in the old uu module.

Copy link
Member

Choose a reason for hiding this comment

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

The page seems to use a capital letter (https://en.wikipedia.org/wiki/Uuencoding) but not the sentence in the introduction:

uuencoding is a form of binary-to-text encoding that originated in the Unix

So up to you!

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed it to lower case. It is in lower case in other parts of the documentation and on other Wikipedia pages.


.. data:: XX_ALPHABET

The Xxencoding alphabet.
Copy link
Member

Choose a reason for hiding this comment

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

Ditto. xxencoding

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure that it is worth to add this alphabet. Uuencoding, binhex and crypt were supported in Python earlier.

static PyObject *
get_reverse_table(binascii_state *state, PyObject *alphabet, int size, int padchar)
{
PyObject *reverse_table;
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest having a goto error for cleanup in case this function grows.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is preliminary.

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.

2 participants