Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Detects code that is not Python 3 compatible.

Project description

Build status Test coverage status

py3kwarn detects code that is not Python 3 compatible. It provides flake8-style warning messages.

See also:

Pull requests are welcome!


Supports Python 2.6, 2.7, and 3.3+

$ pip install py3kwarn

…or to install from the git repository:

$ pip install -e git+git://

Usage with vim

You can use py3kwarn with syntastic. If you want to use py3kwarn with another syntax checker (like flake8), then you will have to add this to your vim config:

let g:syntastic_python_checkers=['flake8', 'py3kwarn']

Usage from the command line

$ py3kwarn PY3K (FixApply) apply(hello, args, kwargs) -> hello(*args, **kwargs) PY3K (FixBasestring) basestring -> str PY3K (FixDict) d.iteritems(); -> iter(d.items()); PY3K (FixDict) d.viewvalues(); -> d.values(); PY3K (FixExcept) try:import asdf;except E, T:pass; -> try:import asdf;except E as T:pass; PY3K (FixExec) exec code in ns1, ns2; -> exec(code, ns1, ns2); PY3K (FixExecfile) execfile('') -> exec(compile(open('').read(), '', 'exec')) PY3K (FixFilter) filter(lambda x: x, [1, 2, 3]) -> [x for x in [1, 2, 3] if x] PY3K (FixFuncattrs) test.func_name; -> test.__name__; PY3K (FixFuncattrs) test.func_closure; -> test.__closure__; PY3K (FixFuncattrs) test.func_dict; -> test.__dict__; PY3K (FixHasKey) d.has_key('foobar') -> 'foobar' in d PY3K (FixInput) input('FixInput') -> eval(input('FixInput')) PY3K (FixItertoolsImports) from itertools import imap -> PY3K (FixItertoolsImports) from itertools import ifilter; -> PY3K (FixItertoolsImports) from itertools import izip; -> PY3K (FixItertoolsImports) from itertools import ifilterfalse; -> from itertools import filterfalse; PY3K (FixLong) long; -> int; PY3K (FixLong) long -> int PY3K (FixImports) import StringIO -> import io PY3K (FixImports) import cStringIO; -> import io; PY3K (FixImports) import cPickle; -> import pickle; PY3K (FixImports) import __builtin__; -> import builtins; PY3K (FixIsinstance) isinstance(x, (int, int)) -> isinstance(x, int) PY3K (FixIsinstance) isinstance(x, (int, int)); -> isinstance(x, int); PY3K (FixCallable) callable('hello') -> isinstance('hello', collections.Callable) PY3K (FixIntern) intern(s) -> sys.intern(s)

Modifying code automatically

Problems can be fixed via py3kwarn2to3:

$ py3kwarn2to3 --write


Testing can be done with make test. py3kwarn also supports tox. This enables quickly testing changes in many versions of python. Take a look at the tox.ini file for more details.


To contribute, fork the repo and clone to your local machine.

Create a virtual environment and

pip install -r requirements_dev.txt

Then just make a pull request with the issues you’ve fixed!


  • Friendlier messages.
  • A flake8 extension.
  • Flags to ignore certain errors
  • Make it faster. Right now it is quite slow compared to other syntax checkers. Major refactoring may be necessary.

Project details

Release history Release notifications

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
py3kwarn-0.4.4.tar.gz (93.3 kB) Copy SHA256 hash SHA256 Source None Oct 4, 2013

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page