Skip to content

Commit 84fd4b7

Browse files
committed
Merge remote-tracking branch 'upstream/master' into alma_api_update
2 parents 47acc80 + 48bc89c commit 84fd4b7

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

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)