Edgewall Software

Opened 7 years ago

Closed 3 years ago

#209 closed enhancement (fixed)

python 3 support

Reported by: tomspur@… Owned by: fschwarz
Priority: major Milestone: 1.0
Component: General Version: devel
Keywords: python3 Cc: felix.schwarz@…



I couldn't find something about python3 support.

Do you have plans in supporting that?

It would be really nice, to have the next version working with python2 and python3. You probably don't need to do that much, if you want to support both versions from one tarball and let the packagers run 2to3 on the source, to make it working for python3.

Or do you want to release 2 different tarballs for each python version?

Attachments (1)

babel_py3k_v1.tar.gz (41.5 KB) - added by Felix Schwarz <felix.schwarz@…> 6 years ago.
first quick&dirty port of Babel to Python 3

Download all attachments as: .zip

Change History (20)

comment:1 Changed 7 years ago by jruigrok

  • Milestone changed from 0.9.6 to 1.0
  • Owner changed from cmlenz to jruigrok
  • Status changed from new to assigned

Change miletstone to 1.0 as this is definitely not a 0.9.6 milestone target.

Yes, support for Python 3 is forthcoming, but it cannot be done simply by using 2to3 due to a few reasons. I am thinking of committing to the experimental branch for this. So yes, it's coming, but I am afraid it will need to be 2 different tarballs for now.

comment:2 Changed 7 years ago by jruigrok

  • Keywords python3 added

Add python3 keyword.

comment:3 Changed 7 years ago by jruigrok

comment:4 Changed 7 years ago by Felix Schwarz <felix.schwarz@…>

  • Cc felix.schwarz@… added

comment:5 Changed 7 years ago by Felix Schwarz <felix.schwarz@…>

Just want to mention that a full port of Babel to Python 3 requires also a port of pytz which is required by the tests. I have a preliminary port of pytz for Python 3.

comment:6 Changed 6 years ago by Felix Schwarz <felix.schwarz@…>

I'm in the process of fixing some Python 3 issues (e.g. #250). The biggest problem with the port I can see so far is the Catalog when it comes to bytes vs. strings in Python 3. To me it's not really clear if the catalog should operate on bytes or strings. To me it looks like a lot of code relies on byte-strings being implicitly US-ASCII.

Changed 6 years ago by Felix Schwarz <felix.schwarz@…>

first quick&dirty port of Babel to Python 3

comment:7 Changed 6 years ago by Felix Schwarz <felix.schwarz@…>

I was able to port babel to Python 3.1. All tests pass for me on a Fedora 14 machine. Currently this is just a 'separate branch' style port where I actually prefer 'single source' ports. To get this to a commitable state, some more work is needed:

  • apply patch for #250
  • change some code – which is handled correctly by 2to3 – slightly (e.g. babel.messages.extract, don't check for type str before decoding, actually we should just use hasattr(value, 'decode')).
  • write custom doctest fixer for exception names, unicode strings and set representations
  • write custom fixer (+ probably code) so unit tests actually use BytesIO instead of StringIO

Btw: To run the tests, you need to get a pytz for Python 3 first, I submitted a patch set in the linked bug.

Currently this quick&dirty port satisfies my immediate needs (building a maintainable Python 3 port of my pycerberus validation library) but I'm interested in getting this fixed properly.

comment:8 Changed 6 years ago by anonymous

I cant claim babel on python 3 actually works, but after checking out svn trunk, the following patch allowed it to install without error or warning:

Index: setup.py
--- setup.py	(revision 604)
+++ setup.py	(working copy)
@@ -79,5 +79,7 @@
     javascript = babel.messages.extract:extract_javascript
-    cmdclass = {'build_doc': build_doc, 'test_doc': test_doc}
+    cmdclass = {'build_doc': build_doc, 'test_doc': test_doc},
+    use_2to3 = True,

comment:9 Changed 6 years ago by anonymous

This diff is then needed to prevent an error when importing babel in your app:

Index: babel/localedata.py
--- babel/localedata.py	(revision 604)
+++ babel/localedata.py	(working copy)
@@ -23,8 +23,12 @@
     import threading
 except ImportError:
     import dummy_threading as threading
-from UserDict import DictMixin
+    from UserDict import DictMixin
+except ImportError:    
+    from collections import MutableMapping as DictMixin
 __all__ = ['exists', 'locale_identifiers', 'load']
 __docformat__ = 'restructuredtext en'

comment:10 Changed 6 years ago by fschwarz

Hey, thank you very much for your work. However the python3 branch is really out of date. There are a lot more items you need to fix before Babel really works with Python 3. Please use my patches which deal with all of that (even if you need to re-diff them).

Also I already started re-doing the patches and have some local state on my hard drive. So if you can wait for 1-2 weeks, these things will be sorted out…

comment:11 Changed 6 years ago by fschwarz

Actually my last comment sounded a bit harsh: I really like to see others working on Python 3 support too (I just feared you waste time by duplicating stuff I already did in my patches attached to this ticket). If you're interested in getting Python 3 supported, please just send me an email (check Babel's mailing list for example) and we can find a way to share our progress.

comment:12 Changed 6 years ago by anonymous

A Python3 port of babel which passes all unittest is available from here: https://bitbucket.org/felixschwarz/babel-py3k/overview

comment:13 Changed 5 years ago by fschwarz

  • Owner changed from jruigrok to fschwarz
  • Status changed from assigned to new
  • Type changed from task to enhancement

comment:14 Changed 4 years ago by wosc@…

I'd be very interested in getting the Python-3 port off the ground. So I'd like to ask, what's the status here?

Also, has a decision been made which porting strategy to use? (Please see https://groups.google.com/forum/?fromgroups=#!msg/python-babel/WS7bakYSdnE/BTlP6mAiIVoJ for details)

Is there anything I can do to help?

Thanks, Wolfgang

(Now I just have to convince the SpamBayes? thingy here that this comment is not spam, major sigh.)

comment:15 Changed 4 years ago by thomas.j.waldmann@…

Hi, I am also interested in getting this out of the state of staleness.

I recently ported / helped to port a lot of moin2's dependencies to python3 (using same source code method). The only stuff left is babel (and flask-babel).

Armin made a nice summary about the effort of the last weeks:


I've seen that multiple people have worked on Babel and Python3 in the past, but somehow nothing happened upstream (AFAICS):

Felix Schwarz https://bitbucket.org/felixschwarz/babel-py3k Uses 2to3 approach + custom_fixers. No commits since 2011-04.

Vinay.Sajip https://bitbucket.org/vinay.sajip/babel3 Uses same-source approach with a "compat" module. No commits since 2012-06.

So, how can we work on the future of Babel, having ONE babel package developed in one main repo (preferably bitbucket or github, not svn), released on pypi, supporting 2.6, 2.7 and 3.3 (see blog post about "why these versions")?

I would like to help, but I would also like to hear about upstream acceptance / plans first.

If some other interested people are also attending the europython 2013 sprints, we could even have a sprint there. :)

comment:16 Changed 4 years ago by anonymous

Would really appreciate a Babel for Python3.

comment:17 Changed 4 years ago by Nikita

在archlinux终端下使用需要什么额外的设置吗?我在arch使用 (process:1432): WARNING : Trying to reesgtir gtype GMountMountFlags' as enum when in fact it is of type GFlags' (process:1432): WARNING : Trying to reesgtir gtype GDriveStartFlags' as enum when in fact it is of type GFlags' (process:1432): WARNING : Trying to reesgtir gtype GSocketMsgFlags' as enum when in fact it is of type GFlags'/usr/lib/python2.7/site-packages/gtk-2.0/gtk/init__.py:57: GtkWarning?: could not open display warnings.warn(str(e), _gtk.Warning)/usr/share/deepin-scrot/src/window.py:27: GtkWarning?: IAgdk_screen_get_root_window: assertion `GDK_IS_SCREEN (screen)' failed (screenWidth, screenHeight) = gtk.gdk.get_default_root_window().get_size()Traceback (most recent call last): File ./deepinScrot.py , line 25, in from mainscrot import MainScrot? File /usr/share/deepin-scrot/src/mainscrot.py , line 28, in from action import * File /usr/share/deepin-scrot/src/action.py , line 25, in from draw import * File /usr/share/deepin-scrot/src/draw.py , line 32, in from window import screenWidth, screenHeight File /usr/share/deepin-scrot/src/window.py , line 27, in (screenWidth, screenHeight) = gtk.gdk.get_default_root_window().get_size()AttributeError?: NoneType?' object has no attribute get_size'

comment:18 Changed 3 years ago by anonymous

Me too, I would really appreciate a Babel for Python3.

comment:19 Changed 3 years ago by fschwarz

  • Resolution set to fixed
  • Status changed from new to closed

Babel development was moved to http://babel.pocoo.org/ this site only serves as a historical archive. Babel is available for Python 3 since Babel 1.0 or.

Note: See TracTickets for help on using tickets.