Skip to content

Commit

Permalink
Drop python-2.5 and remove 2.4,2.5 support codes
Browse files Browse the repository at this point in the history
  • Loading branch information
shimizukawa committed Dec 15, 2013
1 parent 95a07fe commit a8fc938
Show file tree
Hide file tree
Showing 26 changed files with 55 additions and 377 deletions.
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Release 1.3 (in development)
============================

Change support versions
-----------------------

* Drop Python-2.5. (support code was completely removed)



Release 1.2 (released Dec 10, 2013)
===================================
Expand Down
6 changes: 3 additions & 3 deletions doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Installing Sphinx
=================

Since Sphinx is written in the Python language, you need to install Python
(the required version is at least 2.5) and Sphinx.
(the required version is at least 2.6) and Sphinx.

Sphinx packages are available on the `Python Package Index
<http://pypi.python.org/pypi/Sphinx>`_.
Expand Down Expand Up @@ -79,8 +79,8 @@ sidebar and under "Quick Links", click "Windows Installer" to download.
.. note::
Currently, Python offers two major versions, 2.x and 3.x. Sphinx 1.2 can run
under Python 2.5 to 2.7 and 3.1 to 3.3, with the recommended version being
Currently, Python offers two major versions, 2.x and 3.x. Sphinx 1.3 can run
under Python 2.6, 2.7 and 3.1 to 3.3, with the recommended version being
2.7. This chapter assumes you have installed Python 2.7.
Follow the Windows installer for Python.
Expand Down
2 changes: 1 addition & 1 deletion doc/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ See the :ref:`pertinent section in the FAQ list <usingwith>`.
Prerequisites
-------------

Sphinx needs at least **Python 2.5** or **Python 3.1** to run, as well as the
Sphinx needs at least **Python 2.6** or **Python 3.1** to run, as well as the
docutils_ and Jinja2_ libraries. Sphinx should work with docutils version 0.7
or some (not broken) SVN trunk snapshot. If you like to have source code
highlighting support, you must also install the Pygments_ library.
Expand Down
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@
<http://bitbucket.org/birkenfeld/sphinx/get/tip.gz#egg=Sphinx-dev>`_.
'''

if sys.version_info < (2, 6):
print('ERROR: Sphinx requires at least Python 2.6 to run.')
sys.exit(1)

requires = ['Pygments>=1.2', 'docutils>=0.7']

if sys.version_info[:3] >= (3, 3, 0):
requires[1] = 'docutils>=0.10'

if sys.version_info < (2, 6) or (3, 0) <= sys.version_info < (3, 3):
if (3, 0) <= sys.version_info < (3, 3):
requires.append('Jinja2>=2.3,<2.7')
else:
else: # 2.6, 2.7, 3.3 or later
requires.append('Jinja2>=2.3')

if sys.version_info < (2, 5):
print('ERROR: Sphinx requires at least Python 2.5 to run.')
sys.exit(1)

# tell distribute to use 2to3 with our own fixers
extra = {}
if sys.version_info >= (3, 0):
Expand Down
4 changes: 2 additions & 2 deletions sphinx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

def main(argv=sys.argv):
"""Sphinx build "main" command-line entry."""
if sys.version_info[:3] < (2, 5, 0):
sys.stderr.write('Error: Sphinx requires at least Python 2.5 to run.\n')
if sys.version_info[:3] < (2, 6, 0):
sys.stderr.write('Error: Sphinx requires at least Python 2.6 to run.\n')
return 1
try:
from sphinx import cmdline
Expand Down
8 changes: 0 additions & 8 deletions sphinx/builders/epub.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import os
import re
import sys
import time
import codecs
import zipfile
Expand Down Expand Up @@ -750,12 +749,5 @@ def build_epub(self, outdir, outname):
zipfile.ZIP_STORED)
for file in projectfiles:
fp = path.join(outdir, file)
if sys.version_info < (2, 6):
# When zipile.ZipFile.write call with unicode filename, ZipFile
# encode filename to 'utf-8' (only after Python-2.6).
if isinstance(file, unicode):
# OEBPS Container Format (OCF) 2.0.1 specification require
# "File Names MUST be UTF-8 encoded".
file = file.encode('utf-8')
epub.write(fp, file, zipfile.ZIP_DEFLATED)
epub.close()
12 changes: 2 additions & 10 deletions sphinx/builders/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
import posixpath
import cPickle as pickle
from os import path
try:
from hashlib import md5
except ImportError:
# 2.4 compatibility
from md5 import md5
from hashlib import md5

from docutils import nodes
from docutils.io import DocTreeInput, StringOutput
Expand All @@ -35,7 +31,7 @@
movefile, ustrftime, copyfile
from sphinx.util.nodes import inline_all_toctrees
from sphinx.util.matching import patmatch, compile_matchers
from sphinx.util.pycompat import any, b
from sphinx.util.pycompat import b
from sphinx.errors import SphinxError
from sphinx.locale import _
from sphinx.search import js_index
Expand Down Expand Up @@ -1095,8 +1091,4 @@ class JSONHTMLBuilder(SerializingHTMLBuilder):
searchindex_filename = 'searchindex.json'

def init(self):
if jsonimpl.json is None:
raise SphinxError(
'The module simplejson (or json in Python >= 2.6) '
'is not available. The JSONHTMLBuilder builder will not work.')
SerializingHTMLBuilder.init(self)
3 changes: 1 addition & 2 deletions sphinx/builders/linkcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"""

import re
import sys
import Queue
import socket
import threading
Expand Down Expand Up @@ -97,7 +96,7 @@ def init(self):

def check_thread(self):
kwargs = {}
if sys.version_info > (2, 5) and self.app.config.linkcheck_timeout:
if self.app.config.linkcheck_timeout:
kwargs['timeout'] = self.app.config.linkcheck_timeout

def check():
Expand Down
4 changes: 2 additions & 2 deletions sphinx/ext/autodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from sphinx.util.compat import Directive
from sphinx.util.inspect import getargspec, isdescriptor, safe_getmembers, \
safe_getattr, safe_repr, is_builtin_class_method
from sphinx.util.pycompat import base_exception, class_types
from sphinx.util.pycompat import class_types
from sphinx.util.docstrings import prepare_docstring


Expand Down Expand Up @@ -1128,7 +1128,7 @@ class ExceptionDocumenter(ClassDocumenter):
@classmethod
def can_document_member(cls, member, membername, isattr, parent):
return isinstance(member, class_types) and \
issubclass(member, base_exception)
issubclass(member, BaseException)


class DataDocumenter(ModuleLevelDocumenter):
Expand Down
12 changes: 1 addition & 11 deletions sphinx/highlighting.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@
\newcommand\PYGZcb{\char`\}}
'''

parsing_exceptions = (SyntaxError, UnicodeEncodeError)
if sys.version_info < (2, 5):
# Python <= 2.4 raises MemoryError when parsing an
# invalid encoding cookie
parsing_exceptions += MemoryError,


class PygmentsBridge(object):
# Set these attributes if you want to have different Pygments formatters
Expand Down Expand Up @@ -131,10 +125,6 @@ def try_parse(self, src):
# lines beginning with "..." are probably placeholders for suite
src = re.sub(r"(?m)^(\s*)" + mark + "(.)", r"\1"+ mark + r"# \2", src)

# if we're using 2.5, use the with statement
if sys.version_info >= (2, 5):
src = 'from __future__ import with_statement\n' + src

if sys.version_info < (3, 0) and isinstance(src, unicode):
# Non-ASCII chars will only occur in string literals
# and comments. If we wanted to give them to the parser
Expand All @@ -154,7 +144,7 @@ def try_parse(self, src):

try:
parser.suite(src)
except parsing_exceptions:
except (SyntaxError, UnicodeEncodeError):
return False
else:
return True
Expand Down
2 changes: 1 addition & 1 deletion sphinx/pycode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from sphinx.pycode import nodes
from sphinx.pycode.pgen2 import driver, token, tokenize, parse, literals
from sphinx.util import get_module_source, detect_encoding
from sphinx.util.pycompat import next, StringIO, BytesIO, TextIOWrapper
from sphinx.util.pycompat import StringIO, BytesIO, TextIOWrapper
from sphinx.util.docstrings import prepare_docstring, prepare_commentdoc


Expand Down
89 changes: 0 additions & 89 deletions sphinx/pycode/pgen2/parse.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sphinx/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import sys, os, time, re
from os import path
from io import open

TERM_ENCODING = getattr(sys.stdin, 'encoding', None)

Expand All @@ -21,7 +22,6 @@
from sphinx.util.console import purple, bold, red, turquoise, \
nocolor, color_terminal
from sphinx.util import texescape
from sphinx.util.pycompat import open

# function to get input from terminal -- overridden by the test suite
try:
Expand Down
1 change: 0 additions & 1 deletion sphinx/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from sphinx.util.nodes import traverse_translatable_index, extract_messages
from sphinx.util.osutil import ustrftime, find_catalog
from sphinx.util.compat import docutils_version
from sphinx.util.pycompat import all
from sphinx.domains.std import (
make_term_from_paragraph_node,
make_termnodes_from_paragraph_node,
Expand Down
9 changes: 2 additions & 7 deletions sphinx/util/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def getargspec(func):
raise TypeError('%r is not a Python function' % func)
return inspect.getfullargspec(func)

elif sys.version_info >= (2, 5):
else: # 2.6, 2.7
from functools import partial
def getargspec(func):
"""Like inspect.getargspec but supports functools.partial as well."""
Expand Down Expand Up @@ -86,12 +86,7 @@ def getargspec(func):
del func_defaults[i]
except IndexError:
pass
if sys.version_info >= (2, 6):
return inspect.ArgSpec(args, varargs, varkw, func_defaults)
else:
return (args, varargs, varkw, func_defaults)
else:
getargspec = inspect.getargspec
return inspect.ArgSpec(args, varargs, varkw, func_defaults)


def isdescriptor(x):
Expand Down
20 changes: 4 additions & 16 deletions sphinx/util/jsonimpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,15 @@
"""

import UserString
import json

try:
import json
# json-py's json module has no JSONEncoder; this will raise AttributeError
# if json-py is imported instead of the built-in json module
JSONEncoder = json.JSONEncoder
except (ImportError, AttributeError):
try:
import simplejson as json
JSONEncoder = json.JSONEncoder
except ImportError:
json = None
JSONEncoder = object


class SphinxJSONEncoder(JSONEncoder):

class SphinxJSONEncoder(json.JSONEncoder):
"""JSONEncoder subclass that forces translation proxies."""
def default(self, obj):
if isinstance(obj, UserString.UserString):
return unicode(obj)
return JSONEncoder.default(self, obj)
return json.JSONEncoder.default(self, obj)


def dump(obj, fp, *args, **kwds):
Expand Down
Loading

0 comments on commit a8fc938

Please sign in to comment.