Skip to content

Commit bb77769

Browse files
committed
Move location of monkey patch
1 parent 1fecadb commit bb77769

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

astroquery/__init__.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,3 @@
1515
# For egg_info test builds to pass, put package imports here.
1616
#if not _ASTROPY_SETUP_:
1717
# from astroquery import *
18-
19-
20-
# This is to monkey-patch around a config system bug in astropy 1.0.1.
21-
# REMOVEME: when astropy 1.0.1 support is no longer needed
22-
if not _ASTROPY_SETUP_:
23-
import astropy
24-
if astropy.__version__ == '1.0.1':
25-
from astropy.config import configuration
26-
27-
_existing_ConfigItem__init__ = configuration.ConfigItem.__init__
28-
29-
def _monkey_patch_1_0_1_ConfigItem__init__(
30-
self, defaultvalue='', description=None, cfgtype=None,
31-
module=None, aliases=None):
32-
if module is None:
33-
from astropy.utils import find_current_module
34-
module = find_current_module(2)
35-
if module is None:
36-
msg1 = 'Cannot automatically determine get_config module, '
37-
msg2 = 'because it is not called from inside a valid module'
38-
raise RuntimeError(msg1 + msg2)
39-
else:
40-
module = module.__name__
41-
42-
return _existing_ConfigItem__init__(
43-
self,
44-
defaultvalue=defaultvalue,
45-
description=description,
46-
cfgtype=cfgtype,
47-
module=module,
48-
aliases=aliases)
49-
50-
# Don't apply the same monkey patch twice
51-
if (configuration.ConfigItem.__init__.__name__ !=
52-
'_monkey_patch_1_0_1_ConfigItem__init__'):
53-
configuration.ConfigItem.__init__ = _monkey_patch_1_0_1_ConfigItem__init__

astroquery/_astropy_init.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,39 @@ def test(package=None, test_path=None, args=None, plugins=None,
136136
del e
137137
except:
138138
raise orig_error
139+
140+
141+
# This is to monkey-patch around a config system bug in astropy 1.0.1.
142+
# REMOVEME: when astropy 1.0.1 support is no longer needed
143+
if not _ASTROPY_SETUP_:
144+
import astropy
145+
if astropy.__version__ == '1.0.1':
146+
from astropy.config import configuration
147+
148+
_existing_ConfigItem__init__ = configuration.ConfigItem.__init__
149+
150+
def _monkey_patch_1_0_1_ConfigItem__init__(
151+
self, defaultvalue='', description=None, cfgtype=None,
152+
module=None, aliases=None):
153+
if module is None:
154+
from astropy.utils import find_current_module
155+
module = find_current_module(2)
156+
if module is None:
157+
msg1 = 'Cannot automatically determine get_config module, '
158+
msg2 = 'because it is not called from inside a valid module'
159+
raise RuntimeError(msg1 + msg2)
160+
else:
161+
module = module.__name__
162+
163+
return _existing_ConfigItem__init__(
164+
self,
165+
defaultvalue=defaultvalue,
166+
description=description,
167+
cfgtype=cfgtype,
168+
module=module,
169+
aliases=aliases)
170+
171+
# Don't apply the same monkey patch twice
172+
if (configuration.ConfigItem.__init__.__name__ !=
173+
'_monkey_patch_1_0_1_ConfigItem__init__'):
174+
configuration.ConfigItem.__init__ = _monkey_patch_1_0_1_ConfigItem__init__

0 commit comments

Comments
 (0)