Skip to content

allow .NET classes to override __getattr__ and __setattr__ #901

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

Closed
wants to merge 3 commits into from

Conversation

lostmsu
Copy link
Member

@lostmsu lostmsu commented Jun 26, 2019

What does this implement/fix? Explain your changes.

This enables .NET classes to override __getattr__ and __setattr__ by implementing IGetAttr and ISetAttr interfaces correspondingly.

How does it work

When constructing a Python type, that will represent C# type, if the C# type implements one of the interfaces, fill corresponding slots in the Python type with custom handlers for tp_getattro or tp_setattro with implementations from slots.cs.

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Add yourself to AUTHORS
  • Updated the CHANGELOG

P.S.

This is a single-commit change. Probably could be cherry-picked merged without a merge commit.

@lostmsu
Copy link
Member Author

lostmsu commented Jun 26, 2019

Looks like .csproj files have varying line endings. Do you guys know how to enforce them in the future?

@lostmsu lostmsu marked this pull request as ready for review June 26, 2019 21:01
@lostmsu
Copy link
Member Author

lostmsu commented Jun 28, 2019

@filmor any idea why that change could have broken x86 tests? I just tried to run Python.EmbeddingTest on Windows with x86, and did not get any crashes or issue? Could it be, that a simple rerun needed (then how to do it?)?

@filmor
Copy link
Member

filmor commented Jun 28, 2019

It looks good now. Regarding the line endings: IMO we should always have Unix style line-endings everywhere. We could set up a .gitattributes file for this (like outlined here: https://stackoverflow.com/questions/170961/whats-the-best-crlf-carriage-return-line-feed-handling-strategy-with-git), be my guest :)

I use the setting core.autocrlf = input which does a well enough job.

@lostmsu
Copy link
Member Author

lostmsu commented Jun 28, 2019

@filmor I don't think it does. x86 builds are still failing in appveyor (unlike, for example, trivial C# version change).

@lostmsu
Copy link
Member Author

lostmsu commented Jun 28, 2019

Damn, Hyper-V on Windows 10 does not boot x86 linuxes (tried Ubuntu 16.04, 18.04 and the latest Debian)

@lostmsu
Copy link
Member Author

lostmsu commented Oct 21, 2019

Closing this out, as we decided on ad-hoc approach instead (e.g. one should simply have a __getattr__ method in .NET if he wants to override Python's __getattr__).

@lostmsu lostmsu closed this Oct 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants