← Winnitude! Search  ·  Reader Mode (953 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 68 LINKS

allow .NET classes to override __getattr__ and __setattr__ by lostmsu · Pull Request #901 · pythonnet/pythonnet

Repository navigation

allow .NET classes to override __getattr__ and __setattr__ - #901


Closed
lostmsu wants to merge 3 commits into pythonnet:master from losttech:PR/GetSetAttr
Closed

allow .NET classes to override __getattr__ and __setattr__ #901 lostmsu wants to merge 3 commits into pythonnet:master from losttech:PR/GetSetAttr

Conversation

lostmsu commented Jun 26, 2019 · edited Loading



Copy link Copy Markdown
Member

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 force-pushed the PR/GetSetAttr branch from aba6217 to 4730c05
Compare
June 26, 2019 20:51

lostmsu commented Jun 26, 2019



Copy link Copy Markdown
Member

Author

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

lostmsu marked this pull request as ready for review June 26, 2019 21:01 lostmsu force-pushed the PR/GetSetAttr branch from 4730c05 to eb6577f
Compare
June 26, 2019 22:04

lostmsu commented Jun 28, 2019



Copy link Copy Markdown
Member

Author

@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?)?

lostmsu force-pushed the PR/GetSetAttr branch from b3fc2a1 to 41dbcb7
Compare
June 28, 2019 06:50

filmor commented Jun 28, 2019 · edited Loading



Copy link Copy Markdown
Member

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 commented Jun 28, 2019



Copy link Copy Markdown
Member

Author

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

lostmsu commented Jun 28, 2019



Copy link Copy Markdown
Member

Author

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

allow .NET classes to override __getattr__ and __setattr__ 1b17743 lostmsu force-pushed the PR/GetSetAttr branch from 85025f8 to 1b17743
Compare
August 23, 2019 19:28 lostmsu mentioned this pull request Aug 23, 2019 New test class causes crash on x86 with PythonEngine.Initialize #946 Closed lostmsu and others added 2 commits August 23, 2019 13:26 removed initialization from TestInstanceWrapping, as it partaken in t... 5e276d9
...ests crashing under x86 (opened bug pythonnet#946)
Merge branch 'master' into PR/GetSetAttr 4f9e29e

lostmsu commented Oct 21, 2019



Copy link Copy Markdown
Member

Author

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

2 participants