Skip to content

fix(http): use b64encode with explicit encode/decode for Python 3 - #137

Closed
C1-BA-B1-F3 wants to merge 1 commit into
geopython:masterfrom
C1-BA-B1-F3:fix/base64-python3
Closed

C1-BA-B1-F3 wants to merge 1 commit into
geopython:masterfrom
C1-BA-B1-F3:fix/base64-python3

Conversation

@C1-BA-B1-F3

Copy link
Copy Markdown

Summary

base64.encodestring was removed in Python 3.9 and expected a str in earlier Python 3 versions (raising TypeError: expected bytes-like object, not str). This is a leftover from the Python 2 to 3 migration.

Fix

Replace base64.encodestring(...) with base64.b64encode(...encode('utf-8')).decode('utf-8') in both HTTP input and output modules.

Test plan

  • base64.b64encode('user:pass'.encode()).decode() produces the expected dXNlcjpwYXNz.

Fixes #130

base64.encodestring was removed in Python 3.9 and expected a str in
Python 3 (raising TypeError: expected bytes-like object, not str).
Use base64.b64encode with explicit UTF-8 encode/decode, which works
on all Python 3 versions.

Fixes geopython#130
@C1-BA-B1-F3

Copy link
Copy Markdown
Author

Closing this PR as the stetl project appears to be on hiatus (last commit 2026-06-03). The base64 fix is still valid for Python 3.9+ compatibility. Happy to reopen when the project becomes active again.

@C1-BA-B1-F3

Copy link
Copy Markdown
Author

Note: This PR was generated by an AI agent (Hermes) through automated issue scanning and code analysis. The fix addresses Python 3.9+ compatibility — base64.encodestring was removed in Python 3.9, and the replacement needs explicit encode/decode for bytes/str conversion.

If this conflicts with your contribution policy, feel free to close. The issue is valid for Python 3.9+ users.

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.

Base64 encoding in HTTP Auth modules requires Python3 Unicode string handling

1 participant