libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1490911 - /libcloud/site/trunk/content/contributing.mdtext
Date Sat, 08 Jun 2013 04:25:30 GMT
Author: tomaz
Date: Sat Jun  8 04:25:29 2013
New Revision: 1490911

URL: http://svn.apache.org/r1490911
Log:
Add a section which talks how to handle multiple Python versions.

Modified:
    libcloud/site/trunk/content/contributing.mdtext

Modified: libcloud/site/trunk/content/contributing.mdtext
URL: http://svn.apache.org/viewvc/libcloud/site/trunk/content/contributing.mdtext?rev=1490911&r1=1490910&r2=1490911&view=diff
==============================================================================
--- libcloud/site/trunk/content/contributing.mdtext (original)
+++ libcloud/site/trunk/content/contributing.mdtext Sat Jun  8 04:25:29 2013
@@ -26,6 +26,39 @@ Keep in mind that all kind of contributi
 * Any non-trivial change must contain tests
 * All the functions and methods must contain [pydoc](http://codespeak.net/~mwh/pydoctor/)
docstrings which are used to generate API documentation. You can find a lot of examples of
docstrings in the existing code e.g. - `libcloud/compute/base.py`
 
+<h3 id="multiple_python_version">Supporting Multiple Python Versions</h3>
+
+Libcloud supports a variety of Python versions so your code also needs to work
+with all the supported versions. This means that in some cases you will need to
+include extra code to make sure it works in all the supported versions.
+
+Some examples:
+
+#### Context Managers
+
+Context managers aren't available in Python 2.5 by default. If you want to use
+them make sure to put `from __future__ import with_statement` on top of the file where you
use them.
+
+#### Exception Handling
+
+There is no unified way to handle exceptions and extract the exception object
+in Python 2.5 and Python 3.x. This means you need to use a
+`sys.exc_info()[1]` approach to extract the raised exception object.
+
+For example:
+
+    ::python
+    try:
+        some code
+    except Exception:
+        e = sys.exc_info()[1]
+        print e
+
+#### Python 3
+
+You can find a lot of utility functions which make code easier to work with 2.x
+and 3.x in `libcloud.utils.py3` module.
+
 *Note: If you want you can also use SVN repository, but git and github make branching and
contributing a bit easier.*
 
 <h3 id="style_guide">Style Guide</h3>
@@ -35,4 +68,4 @@ Keep in mind that all kind of contributi
 3. Make sure edited file doesn't contain any trailing whitespace
 4. Docstrings need to follow the conventions described on the [Docstring Convetions](/docstring-conventions.html)
page
 
-You can verify that your modifications don't break any rules by running the `pep8` script
- `pep8 libcloud/edited_file.py`.
\ No newline at end of file
+You can verify that your modifications don't break any rules by running the `pep8` script
- `pep8 libcloud/edited_file.py`.



Mime
View raw message