Skip to content
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

Python 3 Compatibility (Part 2) #111

Closed
wants to merge 10 commits into from
Closed

Python 3 Compatibility (Part 2) #111

wants to merge 10 commits into from

Conversation

surfacepatterns
Copy link

These commits introduce Python 3 compatibility into happybase.

Devin Anderson added 10 commits March 8, 2016 10:44
…ate Hbase bindings using new definitions file.
…g and decoding of strings and bytes respectively, but also meant correcting imports and, in a couple cases, explicitly doing something different for Python 2 vs. Python 3.
…lueError instead of TypeError when passing None where an integral type is expected.
…ncode() and bytes.decode() operations don't take place, as, despite what the Hbase.thrift file might tell you, Hbase expects binary data, not UTF-8.

This reverts commit cc6790b.
…d for ValueError instead of TypeError when passing None where an integral type is expected."

This reverts commit bdb0a05.
  * Replacing dict.iteritems() calls with dict.items().
  * Making functions check for `bytes` instead of `str`.
  * Replacing `str` literals with `bytes` literals where appropriate.
  * Changing imports when Python 2 modules aren't available in Python 3.
  * Surrounding map() calls with list() where sequences are expected.
  * Creating an `xrange` alias for Python 3.
  * Replacing `str` literals with `bytes` literals where appropriate.
  * Changing one test to expect `TypeError` instead of `ValueError`.
  * Using the `codecs` module for decoding/encoding hex.
This was referenced Mar 11, 2016

version_path = join(dirname(__file__), '../happybase/_version.py')
with open(version_path) as fp:
version = imp.load_source("_version", version_path, fp).__version__
Copy link
Member

Choose a reason for hiding this comment

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

imp.load_source() is not public api in python 3, and the imp module is deprecated and pending removal...

Copy link
Member

Choose a reason for hiding this comment

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

fwiw, the setup.py has this:

__version__ = None
exec(open('happybase/_version.py', 'r').read())

Copy link
Author

Choose a reason for hiding this comment

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

exec() seems like overkill. If I had my way, I would likely put the version (and any other metadata about the module) into a separate file (json, ini, etc.), and read the data from there.

@wbolster
Copy link
Member

note for readers: #108 contains an earlier stab at this, and also has some interesting comments and observations.

@wbolster
Copy link
Member

also, the python thrift project is a bit of a pain.

switching to thriftpy may be a wise choice. https://thriftpy.readthedocs.org/en/latest/

@wbolster
Copy link
Member

porting to thriftpy was easier than it seemed: see #114 . feedback more than welcome!

@surfacepatterns
Copy link
Author

The thrift python bindings are disgustingly un-pythonic.

I'll take a look at #114 later. It's nearly 5:00 AM my time. I should be sleeping. :)

@wbolster
Copy link
Member

status update: i have some local unfinished work wrt thriftpy and python 3 support, heavily based on this pr but not exactly the same.

i think it makes sense for me to continue that work instead of polishing this branch/pr since i already cherry-picked all the good work done by you. :)

are there any issues or further thoughts in addition to what's already covered in this pr (both code and discussions), and the info captured in the discussion about the previous attempt in #108 ?

@wbolster
Copy link
Member

in case you're interested, i've published a dev and a python3 branch which are both unfinished wip branches which i'll rebase to pieces at some point anyway.

to be continued.

@wbolster
Copy link
Member

wbolster commented Aug 1, 2016

thanks @surfacepatterns for your hard work on this. your contributions helped a lot to get python 3 support in. 👍

i'm closing this since i merged #116 which closes #40.

@wbolster wbolster closed this Aug 1, 2016
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.

None yet

2 participants