-
Notifications
You must be signed in to change notification settings - Fork 163
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
Conversation
…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.
|
||
version_path = join(dirname(__file__), '../happybase/_version.py') | ||
with open(version_path) as fp: | ||
version = imp.load_source("_version", version_path, fp).__version__ |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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())
There was a problem hiding this comment.
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.
note for readers: #108 contains an earlier stab at this, and also has some interesting comments and observations. |
also, the python switching to |
porting to |
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. :) |
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 ? |
in case you're interested, i've published a to be continued. |
thanks @surfacepatterns for your hard work on this. your contributions helped a lot to get python 3 support in. 👍 |
These commits introduce Python 3 compatibility into
happybase
.