From 42ef08935c9dc5cbedc7455a4963a3df924cb52b Mon Sep 17 00:00:00 2001 From: Nikolas Nyby Date: Mon, 17 Dec 2018 15:21:36 -0500 Subject: [PATCH] Add python 3 support - closes #9 --- .gitignore | 118 ++++++++++++++++++++++++++++++++-- .travis.yml | 1 + docs/index.rst | 2 +- mechanize/__init__.py | 2 +- mechanize/_auth.py | 2 +- mechanize/_clientcookie.py | 6 +- mechanize/_debug.py | 2 +- mechanize/_entities.py | 58 ++++++++--------- mechanize/_equiv.py | 6 +- mechanize/_form.py | 6 +- mechanize/_form_controls.py | 6 +- mechanize/_gzip.py | 8 +-- mechanize/_headersutil.py | 8 +-- mechanize/_html.py | 14 ++-- mechanize/_http.py | 7 +- mechanize/_mechanize.py | 2 +- mechanize/_opener.py | 2 +- mechanize/_request.py | 2 +- mechanize/_response.py | 14 ++-- mechanize/_rfc3986.py | 8 +-- mechanize/_sockettimeout.py | 2 +- mechanize/_testcase.py | 2 +- mechanize/_urllib2.py | 2 +- mechanize/_urllib2_fork.py | 39 +++++++---- mechanize/_useragent.py | 2 +- mechanize/_util.py | 2 +- mechanize/polyglot.py | 29 ++++----- publish.py | 2 +- run_tests.py | 2 +- setup.cfg | 2 + setup.py | 7 +- test-tools/testprogram.py | 3 + test/test_api.py | 2 +- test/test_browser.doctest | 14 ++-- test/test_browser.py | 39 ++++++----- test/test_cookies.py | 8 ++- test/test_functional.py | 6 +- test/test_opener.doctest | 20 +++--- test/test_request.doctest | 2 +- test/test_urllib2.py | 12 ++-- test/test_urllib2_localnet.py | 6 +- 41 files changed, 311 insertions(+), 166 deletions(-) create mode 100644 setup.cfg diff --git a/.gitignore b/.gitignore index 55683e9..11614af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,115 @@ -/build/ -/dist/ -/docs/_* +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ *.egg-info/ -*.py[co] +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ diff --git a/.travis.yml b/.travis.yml index 3d3f7ae..1987055 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ language: python python: # - 2.6 disabled as the TestLoader.discover() method is not available on python < 2.7 - 2.7 + - 3.6 - pypy matrix: diff --git a/docs/index.rst b/docs/index.rst index 63e73f9..0ff804a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -109,7 +109,7 @@ You may control the browser's policy by using the methods of # Sometimes it's useful to process bad headers or bad HTML: response = br.response() # this is a copy of response - headers = response.info() # currently, this is a mimetools.Message + headers = response.info() # currently, this is a email.mime.message.MIMEMessage headers["Content-type"] = "text/html; charset=utf-8" response.set_data(response.get_data().replace("