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

Closed
Silmathoron opened this Issue Feb 14, 2017 · 2 comments

Comments

Projects
None yet
5 participants
@Silmathoron
Contributor

Silmathoron commented Feb 14, 2017

In hl_api_helper.py, 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 ^^).

@physicalist

This comment has been minimized.

Show comment
Hide comment
@physicalist

physicalist Mar 31, 2017

I've run into the same issue when testing my NEST installation with do_python.py. 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/test_basics.py", line 219, in test_FindElements
    n = topo.FindNearestElement(l, (0., 0.))
  File "/usr/local/lib/python3.6/site-packages/nest/topology/hl_api.py", line 1122, in FindNearestElement
    els = nest.GetChildren((lyr, ))[0]
  File "/usr/local/lib/python3.6/site-packages/nest/lib/hl_api_helper.py", line 230, in stack_checker_func
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/nest/lib/hl_api_helper.py", 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/hl_api_helper.py", 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/warnings.py", 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?

physicalist commented Mar 31, 2017

I've run into the same issue when testing my NEST installation with do_python.py. 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/test_basics.py", line 219, in test_FindElements
    n = topo.FindNearestElement(l, (0., 0.))
  File "/usr/local/lib/python3.6/site-packages/nest/topology/hl_api.py", line 1122, in FindNearestElement
    els = nest.GetChildren((lyr, ))[0]
  File "/usr/local/lib/python3.6/site-packages/nest/lib/hl_api_helper.py", line 230, in stack_checker_func
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/nest/lib/hl_api_helper.py", 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/hl_api_helper.py", 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/warnings.py", 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?

@wmayner

This comment has been minimized.

Show comment
Hide comment
@wmayner

wmayner 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.

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