diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2015-06-18 03:38:14 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2015-06-18 03:38:14 +0200 |
commit | b2a447dbb1f886343c20263829659f29354ec123 (patch) | |
tree | 77bb40aeb523c025b6e927bd7d8b3b2d034c01ee | |
parent | 2006f27b6fa19a82bf2538ad90813d93708f7da2 (diff) | |
download | psutil-b2a447dbb1f886343c20263829659f29354ec123.tar.gz |
fix #635: [UNIX] crash on module import if 'enum' package is installed on python < 3.4
-rw-r--r-- | HISTORY.rst | 2 | ||||
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | psutil/_common.py | 12 |
3 files changed, 11 insertions, 9 deletions
diff --git a/HISTORY.rst b/HISTORY.rst index 4793d3d3..bf694ca4 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -6,6 +6,8 @@ Bug tracker at https://github.com/giampaolo/psutil/issues **Bug fixes** - #632: [Linux] better error message if cannot parse process UNIX connections. +- #635: [UNIX] crash on module import if 'enum' package is installed on python + < 3.4. 3.0.0 - 2015-06-13 @@ -52,6 +52,7 @@ install-dev-deps: mock \ nose \ pep8 \ + pyflakes \ sphinx \ sphinx-pypi-upload \ unittest2 \ @@ -80,7 +81,7 @@ test-memleaks: install test-by-name: install @$(PYTHON) -m nose test/test_psutil.py --nocapture -v -m $(filter-out $@,$(MAKECMDGOALS)) -# same as above but for test_memory_leaks.py script +# Same as above but for test_memory_leaks.py script. test-memleaks-by-name: install @$(PYTHON) -m nose test/test_memory_leaks.py --nocapture -v -m $(filter-out $@,$(MAKECMDGOALS)) @@ -92,16 +93,13 @@ coverage: install $(PYTHON) -m coverage html $(COVERAGE_OPTS) $(PYTHON) -m webbrowser -t htmlcov/index.html -# requires "pip install pep8" pep8: @git ls-files | grep \\.py$ | xargs $(PYTHON) -m pep8 -# requires "pip install pyflakes" pyflakes: @export PYFLAKES_NODOCTEST=1 && \ git ls-files | grep \\.py$ | xargs $(PYTHON) -m pyflakes -# requires "pip install flake8" flake8: @git ls-files | grep \\.py$ | xargs $(PYTHON) -m flake8 diff --git a/psutil/_common.py b/psutil/_common.py index 132d9d59..e9acf595 100644 --- a/psutil/_common.py +++ b/psutil/_common.py @@ -12,17 +12,19 @@ import functools import os import socket import stat +import sys +from collections import namedtuple +from socket import AF_INET, SOCK_STREAM, SOCK_DGRAM try: import threading except ImportError: import dummy_threading as threading -try: - import enum # py >= 3.4 -except ImportError: + +if sys.version_info >= (3, 4): + import enum +else: enum = None -from collections import namedtuple -from socket import AF_INET, SOCK_STREAM, SOCK_DGRAM # --- constants |