Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong "Monkeypatch" in warnings.showwarning #662

Silmathoron opened this issue Feb 14, 2017 · 2 comments

Wrong "Monkeypatch" in warnings.showwarning #662

Silmathoron opened this issue Feb 14, 2017 · 2 comments


Copy link

@Silmathoron Silmathoron commented Feb 14, 2017

In, a python builtin function has been replaced with a custom one which has:

  • a wrong number of arguments
  • wrong argument names

This causes crash in scripts using both nest and the warnings module.

I'm not sure replacing builtin functions is a good idea, so the question is: Is this really necessary?
If so, I can make a PR to replace it (it is really easy); otherwise I would be in favor of suppressing lines 37 to 41 (for which I can also make a PR, which will be even easier ^^).

Copy link

@physicalist physicalist commented Mar 31, 2017

I've run into the same issue when testing my NEST installation with Interestingly, only with Python3. Here's one of the error messages for reference:

ERROR: test_FindElements (nest.topology.tests.test_basics.BasicsTestCase)
Interface and result check for finding nearest element.
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/nest/topology/tests/", line 219, in test_FindElements
    n = topo.FindNearestElement(l, (0., 0.))
  File "/usr/local/lib/python3.6/site-packages/nest/topology/", line 1122, in FindNearestElement
    els = nest.GetChildren((lyr, ))[0]
  File "/usr/local/lib/python3.6/site-packages/nest/lib/", line 230, in stack_checker_func
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/nest/lib/", line 120, in new_func
    show_deprecation_warning(func.__name__, alt_func_name, text=text)
  File "/usr/local/lib/python3.6/site-packages/nest/lib/", line 91, in show_deprecation_warning
    warnings.warn('\n' + text)   # add LF so text starts on new line
  File "/usr/local/Cellar/python3/3.6.0_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/", line 99, in _showwarnmsg
    msg.file, msg.line)
TypeError: _warning() takes from 1 to 4 positional arguments but 6 were given


The code section with the Monkey patch stems from 8d8b19c and even contains a comment that the functions would be removed in 2.6 - I guess that didn't happen?

Copy link

@wmayner wmayner commented Jun 20, 2017

I've had the same issue—so far, it seems that this is the only incompatibility with Python 3. Suppressing those lines solves the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.