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

[SofaPython] Fix python live coding that is broken #414

Merged
merged 2 commits into from
Oct 12, 2017

Conversation

damienmarchal
Copy link
Contributor

@damienmarchal damienmarchal commented Sep 20, 2017

Hi,

This PR fix the live coding of python component. I found two problems.

One is a bug in the FileMonitor which prevent to monitor several files located in the same directory but given in a different manner as in:

"./examples/Afile.txt"
"/this/is/absolute/examples/Afile2.txt"

The second problem is a missing PythonEnvironement::gil before calling python code.

This PR fix the two.
@guparan and @hugtalbot Could this PR be treated in fast-path please ?

@maxime-tournier I took me a while to understand that

PythonEnvironment::gil lock(); 

Is not doing anything useful. The problem is well known but in general it is quickly catched but here, as lock is a RAII, everything compile but just crash when calling python code. I'm quite sure this will happen to a lot of people so I wonder if we can make something more elegant that removing the default constructor and forcing to provide the *trace pointer (possibly nullptr). Any idea ?


This PR:

  • builds with SUCCESS for all platforms on the CI.
  • does not generate new warnings.
  • does not generate new unit test failures.
  • does not generate new scene test failures.
  • does not break API compatibility.
  • is more than 1 week old (or has fast-merge label).

Reviewers will merge only if all these checks are true.

I took me a while to understand that writing
PythonEnvironement::gil lock();

While perfectly compiling is not doing what I expect.

I wonder how to help developpers no to make this mistake.
When the same path is added two time one its is absolute forme one in relative.
The FileMonitor does not work on the absolute one. This Commit fix that.
@damienmarchal damienmarchal added pr: fast merge Minor change that can be merged without waiting for the 7 review days pr: fix Fix a bug pr: status to review To notify reviewers to review this pull-request labels Sep 20, 2017
@maxime-tournier
Copy link
Contributor

@damienmarchal
This is yet another instance of the "most vexing parse", which I assume most c++ programmers are familiar with (c++ really is a terrible language). However, clang issues a warning and I suspect gcc does too, so this is not really an issue to me. An elegant fix is to turn this warning into an error :-)

I understand the problem can go unnoticed since the value is never used elsewhere and won't get to trigger a type error down the road, so removing the default value for the constructor argument seems like a reasonable (and portable) fix.

@guparan guparan added pr: status ready Approved a pull-request, ready to be squashed and removed pr: status to review To notify reviewers to review this pull-request labels Oct 10, 2017
@damienmarchal
Copy link
Contributor Author

@hugtalbot, @guparan This one should be merged.

@damienmarchal
Copy link
Contributor Author

[ci-build]

@damienmarchal
Copy link
Contributor Author

This one seems ready.

@damienmarchal damienmarchal merged commit 4dcf1c2 into sofa-framework:master Oct 12, 2017
@guparan guparan added this to the v17.12 milestone Dec 14, 2017
@damienmarchal damienmarchal deleted the fixPythonLiveCoding branch February 12, 2018 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: fast merge Minor change that can be merged without waiting for the 7 review days pr: fix Fix a bug pr: status ready Approved a pull-request, ready to be squashed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants