-
Notifications
You must be signed in to change notification settings - Fork 901
fix: Replace macro use in ordered_float tests #5602
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
Conversation
The tests make use of the py_run macro which is only available with the macros feature enabled.
2804c4b to
662018b
Compare
|
Probably too late, I just read through the related comments on #5344 and I still think this is ok as a stand-alone change. The tests rely on the macro so requiring it makes some sense. Would it be better to replace the macro uses so the tests run with no other features enabled or is it still clearer to use the shorthand version? |
Replace the py_run macro with a local function offering a simplified but sufficient functionality
|
Replacing the macro didn't look too bad so is possibly the better approach so the tests aren't skipped unexpectedly. |
|
Thanks very much for this! Doing this got me experimenting, IIRC we gated Maybe we can simplify and do something like #5608, and then always allow |
davidhewitt
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.
On balance I decided it might not be a bad thing to keep py_run! gated behind the macros feature in case we do crazy stuff in the future like move it to be a proc macro; nobody has asked for that change.
So let's merge this; thanks!
src/conversions/ordered_float.rs
Outdated
| fn py_run<'py>(py: Python<'py>, script: String, locals: impl IntoPyDict<'py>) { | ||
| py.run( | ||
| &CString::new(script).unwrap(), | ||
| None, | ||
| Some(&locals.into_py_dict(py).unwrap()), | ||
| ) | ||
| .unwrap() | ||
| } |
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.
| fn py_run<'py>(py: Python<'py>, script: String, locals: impl IntoPyDict<'py>) { | |
| py.run( | |
| &CString::new(script).unwrap(), | |
| None, | |
| Some(&locals.into_py_dict(py).unwrap()), | |
| ) | |
| .unwrap() | |
| } | |
| fn py_run<'py>(py: Python<'py>, script: &CStr, locals: impl IntoPyDict<'py>) { | |
| py.run( | |
| script, | |
| None, | |
| Some(&locals.into_py_dict(py).unwrap()), | |
| ) | |
| .unwrap() | |
| } |
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.
I'll have a look at fixing the calls to work with this
davidhewitt
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.
I think we can avoid introducing format! and use c"" literals with &Cstr instead.
|
I think we still need |
davidhewitt
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.
Perfect, many thanks!
The tests make use of the py_run macro which is only available with the
macros feature enabled.
While the py_run macro supports a wider range of requirements, the way
it is used in these tests is straightforward enough that it can be
replaced with a local function to prevent the macros feature needing to
be enabled.
Closes #5345