PYTHON-1467 Remove outdated code for old python versions (#395)
This commit is contained in:
parent
c77a0d8e1f
commit
19827c41ec
@ -19,15 +19,6 @@
|
||||
#ifndef _CBSONMODULE_H
|
||||
#define _CBSONMODULE_H
|
||||
|
||||
/* Py_ssize_t was new in python 2.5. See conversion
|
||||
* guidlines in http://www.python.org/dev/peps/pep-0353
|
||||
* */
|
||||
#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
|
||||
typedef int Py_ssize_t;
|
||||
#define PY_SSIZE_T_MAX INT_MAX
|
||||
#define PY_SSIZE_T_MIN INT_MIN
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(_MSC_VER)
|
||||
/*
|
||||
* This macro is basically an implementation of asprintf for win32
|
||||
|
||||
29
setup.py
29
setup.py
@ -4,6 +4,11 @@ import re
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
|
||||
if sys.version_info[:2] < (2, 7):
|
||||
raise RuntimeError("Python version >= 2.7 required.")
|
||||
|
||||
|
||||
# Hack to silence atexit traceback in some Python versions
|
||||
try:
|
||||
import multiprocessing
|
||||
@ -289,23 +294,17 @@ http://api.mongodb.org/python/current/installation.html#osx
|
||||
|
||||
def build_extension(self, ext):
|
||||
name = ext.name
|
||||
if sys.version_info[:3] >= (2, 7, 0):
|
||||
try:
|
||||
build_ext.build_extension(self, ext)
|
||||
except build_errors:
|
||||
e = sys.exc_info()[1]
|
||||
sys.stdout.write('%s\n' % str(e))
|
||||
warnings.warn(self.warning_message % ("The %s extension "
|
||||
"module" % (name,),
|
||||
"The output above "
|
||||
"this warning shows how "
|
||||
"the compilation "
|
||||
"failed."))
|
||||
else:
|
||||
try:
|
||||
build_ext.build_extension(self, ext)
|
||||
except build_errors:
|
||||
e = sys.exc_info()[1]
|
||||
sys.stdout.write('%s\n' % str(e))
|
||||
warnings.warn(self.warning_message % ("The %s extension "
|
||||
"module" % (name,),
|
||||
"PyMongo supports python "
|
||||
">= 2.7."))
|
||||
"The output above "
|
||||
"this warning shows how "
|
||||
"the compilation "
|
||||
"failed."))
|
||||
|
||||
ext_modules = [Extension('bson._cbson',
|
||||
include_dirs=['bson'],
|
||||
|
||||
@ -113,16 +113,10 @@ class TestURI(unittest.TestCase):
|
||||
'connect=foo', warn=True)
|
||||
self.assertRaises(Warning, split_options,
|
||||
'ssl_match_hostname=foo', warn=True)
|
||||
|
||||
# On most platforms float('inf') and float('-inf') represent
|
||||
# +/- infinity, although on Python 2.4 and 2.5 on Windows those
|
||||
# expressions are invalid
|
||||
if not (sys.platform == "win32" and sys.version_info <= (2, 5)):
|
||||
self.assertRaises(Warning, split_options,
|
||||
'connectTimeoutMS=inf', warn=True)
|
||||
self.assertRaises(Warning, split_options,
|
||||
'connectTimeoutMS=-inf', warn=True)
|
||||
|
||||
self.assertRaises(Warning, split_options,
|
||||
'connectTimeoutMS=inf', warn=True)
|
||||
self.assertRaises(Warning, split_options,
|
||||
'connectTimeoutMS=-inf', warn=True)
|
||||
self.assertRaises(Warning, split_options, 'wtimeoutms=foo',
|
||||
warn=True)
|
||||
self.assertRaises(Warning, split_options, 'wtimeoutms=5.5',
|
||||
@ -148,11 +142,8 @@ class TestURI(unittest.TestCase):
|
||||
self.assertRaises(ValueError, split_options, 'ssl=foo')
|
||||
self.assertRaises(ValueError, split_options, 'connect=foo')
|
||||
self.assertRaises(ValueError, split_options, 'ssl_match_hostname=foo')
|
||||
if not (sys.platform == "win32" and sys.version_info <= (2, 5)):
|
||||
self.assertRaises(ValueError, split_options,
|
||||
'connectTimeoutMS=inf')
|
||||
self.assertRaises(ValueError, split_options,
|
||||
'connectTimeoutMS=-inf')
|
||||
self.assertRaises(ValueError, split_options, 'connectTimeoutMS=inf')
|
||||
self.assertRaises(ValueError, split_options, 'connectTimeoutMS=-inf')
|
||||
self.assertRaises(ValueError, split_options, 'wtimeoutms=foo')
|
||||
self.assertRaises(ValueError, split_options, 'wtimeoutms=5.5')
|
||||
self.assertRaises(ValueError, split_options, 'fsync=foo')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user