-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix "Could not find builtin symbol 'NoneType'" in the ctypes plugin #6097
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
Merged
ilevkivskyi
merged 1 commit into
python:master
from
jstasiak:fix-ctypes-could-not-find-nonetype
Dec 21, 2018
Merged
Fix "Could not find builtin symbol 'NoneType'" in the ctypes plugin #6097
ilevkivskyi
merged 1 commit into
python:master
from
jstasiak:fix-ctypes-could-not-find-nonetype
Dec 21, 2018
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ilevkivskyi
approved these changes
Dec 21, 2018
Member
ilevkivskyi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch! I wonder how no one caught this before :-) Thanks for the fix!
Member
|
Could you please fix the lint failure (long line), so that I can merge this? |
Contributor
Author
|
No worries. Yeah, just doing that, will be up in few minutes. |
The error was triggered by creating an array of pointers. The stack
trace:
$ pytest -n0 -k testCtypesCharPArrayDoesNotCrash
(...)
data: /Users/kuba/projects/mypy/test-data/unit/check-ctypes.test:83:
SystemExit: 2
---------------------------------------------------------------------------------------------------------- Captured stdout call -----------------------------------------------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/kuba/.ve37/bin/pytest", line 11, in <module>
sys.exit(main())
File "/Users/kuba/.ve37/lib/python3.7/site-packages/_pytest/config/__init__.py", line 77, in main
return config.hook.pytest_cmdline_main(config=config)
File "/Users/kuba/.ve37/lib/python3.7/site-packages/pluggy/hooks.py", line 284, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/Users/kuba/.ve37/lib/python3.7/site-packages/pluggy/manager.py", line 67, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/Users/kuba/.ve37/lib/python3.7/site-packages/pluggy/manager.py", line 61, in <lambda>
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
File "/Users/kuba/.ve37/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/Users/kuba/.ve37/lib/python3.7/site-packages/_pytest/main.py", line 218, in pytest_cmdline_main
return wrap_session(config, _main)
File "/Users/kuba/.ve37/lib/python3.7/site-packages/_pytest/main.py", line 185, in wrap_session
session.exitstatus = doit(config, session) or 0
File "/Users/kuba/.ve37/lib/python3.7/site-packages/_pytest/main.py", line 225, in _main
config.hook.pytest_runtestloop(session=session)
File "/Users/kuba/.ve37/lib/python3.7/site-packages/pluggy/hooks.py", line 284, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/Users/kuba/.ve37/lib/python3.7/site-packages/pluggy/manager.py", line 67, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/Users/kuba/.ve37/lib/python3.7/site-packages/pluggy/manager.py", line 61, in <lambda>
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
File "/Users/kuba/.ve37/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/Users/kuba/.ve37/lib/python3.7/site-packages/_pytest/main.py", line 246, in pytest_runtestloop
item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
File "/Users/kuba/.ve37/lib/python3.7/site-packages/pluggy/hooks.py", line 284, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/Users/kuba/.ve37/lib/python3.7/site-packages/pluggy/manager.py", line 67, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/Users/kuba/.ve37/lib/python3.7/site-packages/pluggy/manager.py", line 61, in <lambda>
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
File "/Users/kuba/.ve37/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/Users/kuba/.ve37/lib/python3.7/site-packages/_pytest/runner.py", line 76, in pytest_runtest_protocol
runtestprotocol(item, nextitem=nextitem)
File "/Users/kuba/.ve37/lib/python3.7/site-packages/_pytest/runner.py", line 91, in runtestprotocol
reports.append(call_and_report(item, "call", log))
File "/Users/kuba/.ve37/lib/python3.7/site-packages/_pytest/runner.py", line 171, in call_and_report
call = call_runtest_hook(item, when, **kwds)
File "/Users/kuba/.ve37/lib/python3.7/site-packages/_pytest/runner.py", line 195, in call_runtest_hook
treat_keyboard_interrupt_as_exception=item.config.getvalue("usepdb"),
File "/Users/kuba/.ve37/lib/python3.7/site-packages/_pytest/runner.py", line 211, in __init__
self.result = func()
File "/Users/kuba/.ve37/lib/python3.7/site-packages/_pytest/runner.py", line 193, in <lambda>
lambda: ihook(item=item, **kwds),
File "/Users/kuba/.ve37/lib/python3.7/site-packages/pluggy/hooks.py", line 284, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/Users/kuba/.ve37/lib/python3.7/site-packages/pluggy/manager.py", line 67, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/Users/kuba/.ve37/lib/python3.7/site-packages/pluggy/manager.py", line 61, in <lambda>
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
File "/Users/kuba/.ve37/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/Users/kuba/.ve37/lib/python3.7/site-packages/_pytest/runner.py", line 121, in pytest_runtest_call
item.runtest()
File "/Users/kuba/projects/mypy/mypy/test/data.py", line 212, in runtest
suite.run_case(self)
File "/Users/kuba/projects/mypy/mypy/test/testcheck.py", line 113, in run_case
self.run_case_once(testcase)
File "/Users/kuba/projects/mypy/mypy/test/testcheck.py", line 173, in run_case_once
alt_lib_path=test_temp_dir)
File "/Users/kuba/projects/mypy/mypy/build.py", line 157, in build
result = _build(sources, options, alt_lib_path, flush_errors, fscache)
File "/Users/kuba/projects/mypy/mypy/build.py", line 207, in _build
graph = dispatch(sources, manager)
File "/Users/kuba/projects/mypy/mypy/build.py", line 2216, in dispatch
process_graph(graph, manager)
File "/Users/kuba/projects/mypy/mypy/build.py", line 2514, in process_graph
process_stale_scc(graph, scc, manager)
File "/Users/kuba/projects/mypy/mypy/build.py", line 2623, in process_stale_scc
graph[id].type_check_first_pass()
File "/Users/kuba/projects/mypy/mypy/build.py", line 1778, in type_check_first_pass
self.type_checker().check_first_pass()
File "/Users/kuba/projects/mypy/mypy/checker.py", line 282, in check_first_pass
self.accept(d)
File "/Users/kuba/projects/mypy/mypy/checker.py", line 393, in accept
stmt.accept(self)
File "/Users/kuba/projects/mypy/mypy/nodes.py", line 968, in accept
return visitor.visit_assignment_stmt(self)
File "/Users/kuba/projects/mypy/mypy/checker.py", line 1696, in visit_assignment_stmt
self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax)
File "/Users/kuba/projects/mypy/mypy/checker.py", line 1813, in check_assignment
self.infer_variable_type(inferred, lvalue, self.expr_checker.accept(rvalue),
File "/Users/kuba/projects/mypy/mypy/checkexpr.py", line 3123, in accept
typ = node.accept(self)
File "/Users/kuba/projects/mypy/mypy/nodes.py", line 1421, in accept
return visitor.visit_call_expr(self)
File "/Users/kuba/projects/mypy/mypy/checkexpr.py", line 232, in visit_call_expr
return self.visit_call_expr_inner(e, allow_none_return=allow_none_return)
File "/Users/kuba/projects/mypy/mypy/checkexpr.py", line 302, in visit_call_expr_inner
ret_type = self.check_call_expr_with_callee_type(callee_type, e, fullname, object_type)
File "/Users/kuba/projects/mypy/mypy/checkexpr.py", line 647, in check_call_expr_with_callee_type
object_type=object_type)[0]
File "/Users/kuba/projects/mypy/mypy/checkexpr.py", line 705, in check_call
callable_node, arg_messages)
File "/Users/kuba/projects/mypy/mypy/checkexpr.py", line 684, in check_call
object_type)
File "/Users/kuba/projects/mypy/mypy/checkexpr.py", line 786, in check_callable_call
callable_name, object_type, context)
File "/Users/kuba/projects/mypy/mypy/checkexpr.py", line 563, in apply_function_plugin
callee.ret_type, formal_arg_exprs, context, self.chk))
File "/Users/kuba/projects/mypy/mypy/plugins/ctypes.py", line 114, in array_constructor_callback
allowed = _autoconvertible_to_cdata(et, ctx.api)
File "/Users/kuba/projects/mypy/mypy/plugins/ctypes.py", line 73, in _autoconvertible_to_cdata
allowed_types.append(api.named_generic_type('builtins.NoneType', []))
File "/Users/kuba/projects/mypy/mypy/checker.py", line 3501, in named_generic_type
info = self.lookup_typeinfo(name)
File "/Users/kuba/projects/mypy/mypy/checker.py", line 3507, in lookup_typeinfo
sym = self.lookup_qualified(fullname)
File "/Users/kuba/projects/mypy/mypy/checker.py", line 3566, in lookup_qualified
"defines this symbol.)".format(last))
KeyError: "Could not find builtin symbol 'NoneType'. (Are you running a test case? If so, make sure to include a fixture that defines this symbol.)"
b4a2066 to
f44b8fb
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The error was triggered by creating an array of pointers. The stack
trace: