[Python-Dev] Re: C- Python on Windows

2023-01-18 Thread Steve Dower

On 15Jan2023 0922, Guenther Sohler wrote:

Now when i want to get my project compiled in windows, whats the easiest
development chain ?
Is there something like a python.dll which i can link to my project and
having an embedded python interpreter ?

Maybe the question is too simple, but i could not yet find the right place
to read docs.
Thank you for your hints!


There's an overview of our embeddable package and some discussion of how 
to use it at https://docs.python.org/3/using/windows.html#windows-embeddable


You'll likely also need a full install to get all the developer kit 
pieces (such as the headers and libs files), but the embeddable package 
is one you can include straight into your project and redistribute. The 
binaries are the same, it's just laid out differently.


And yes, discuss.python.org is the best place to ask these days.

Cheers,
Steve
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/DHEON2LAXFWRH5NUYAOJSYVTDRH4EL4N/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Exception compatibility with aliens

2023-01-18 Thread Frederick Virchanza Gotham
I have sent this email to two mailing lists for programming language
proposals, the one for C++ and the one for Python. If you reply to
this email, please make sure you reply to both. You can see the
mailing list archives for this month for each list here:

C++  :  https://lists.isocpp.org/std-proposals/2023/01/date.php
Python  :  https://mail.python.org/archives/list/python-dev@python.org/2023/1/

Both C++ and Python have exception handling, however a C++ program
which links with a Python library is unable to handle an exception
thrown from Python.

Is it conceivable in the future that the C++ Standards Committee and
the Python Steering Council could cooperate and furnish each other
with an exhaustive list of exceptions thrown from their respective
standard libraries, so that both languages can implement compatibility
with each other's exceptions?

If such a list were to accompany each C++ standard and each Python
Language Reference, then for example the C++ standard library could
provide classes for handling Python exceptions:

namespace std {

struct alien_exception /* does not inherit from std::exception */ {
enum class language : unsigned int { java=1u, csharp, python };
virtual language lang(void) const noexcept = 0;
virtual char const *what(void) const noexcept = 0;
};

namespace aliens {

  namespace java {
struct exception : alien_exception {
char const *getLocalizedMessage(void) const noexcept;
char const *getMessage(void) const noexcept;
std::stacktrace getStackTrace(void) const noexcept;
char const *what(void) const noexcept override { return
this->getMessage(); }
language lang(void) const noexcept override { return language::java; }
};
  }

  namespace python {
struct exception : alien_exception {
char const *const *notes(void) const noexcept; /* null terminated */
std::stacktrace traceback() const noexcept;
char const *what(void) const noexcept override { return
this->notes()[0u]; }
language lang(void) const noexcept override { return language::python; }
};
  }

  namespace python {
 struct BaseException : exception {};
   struct BaseExceptionGroup : BaseException {};
   struct GeneratorExit : BaseException {};
   struct KeyboardInterrupt : BaseException {};
   struct SystemExit : BaseException {};
   struct Exception : BaseException {};
struct ArithmeticError : Exception {};
  struct FloatingPointError : ArithmeticError {};
  struct OverflowError : ArithmeticError {};
  struct ZeroDivisionError : ArithmeticError {};
struct AssertionError : Exception {};
struct AttributeError : Exception {};
struct BufferError : Exception {};
struct EOFError : Exception {};
struct ExceptionGroupBaseExceptionGroup : Exception {};
struct ImportError : Exception {};
  struct ModuleNotFoundError : ImportError {};
struct LookupError : Exception {};
  struct IndexError : LookupError {};
  struct KeyError : LookupError {};
struct MemoryError : Exception {};
struct NameError : Exception {};
  struct UnboundLocalError : NameError {};
struct OSError : Exception {};
  struct BlockingIOError : OSError {};
  struct ChildProcessError : OSError {};
  struct ConnectionError : OSError {};
struct BrokenPipeError : ConnectionError {};
struct ConnectionAbortedError : ConnectionError {};
struct ConnectionRefusedError : ConnectionError {};
struct ConnectionResetError : ConnectionError {};
  struct FileExistsError : OSError {};
  struct FileNotFoundError : OSError {};
  struct InterruptedError : OSError {};
  struct IsADirectoryError : OSError {};
  struct NotADirectoryError : OSError {};
  struct PermissionError : OSError {};
  struct ProcessLookupError : OSError {};
  struct TimeoutError : OSError {};
struct ReferenceError : Exception {};
struct RuntimeError : Exception {};
  struct NotImplementedError : RuntimeError {};
  struct RecursionError : RuntimeError {};
struct StopAsyncIteration : Exception {};
struct StopIteration : Exception {};
struct SyntaxError : Exception {};
  struct IndentationError : SyntaxError {};
 struct TabError : IndentationError {};
struct SystemError : Exception {};
struct TypeError : Exception {};
struct ValueError : Exception {};
  struct UnicodeError : ValueError {};
 struct UnicodeDecodeError : UnicodeError {};
 struct UnicodeEncodeError : UnicodeError {};
 struct UnicodeTranslateError : UnicodeError {};
struct Warning : Exception {};
   struct BytesWarning : Warning {};
   struct DeprecationWarning : Warning {};
   struct Enco

[Python-Dev] Re: [std-proposals] Exception compatibility with aliens

2023-01-18 Thread Ville Voutilainen
On Wed, 18 Jan 2023 at 11:45, Frederick Virchanza Gotham via
Std-Proposals  wrote:
>
> I have sent this email to two mailing lists for programming language
> proposals, the one for C++ and the one for Python. If you reply to
> this email, please make sure you reply to both. You can see the
> mailing list archives for this month for each list here:
>
> C++  :  https://lists.isocpp.org/std-proposals/2023/01/date.php
> Python  :  https://mail.python.org/archives/list/python-dev@python.org/2023/1/
>
> Both C++ and Python have exception handling, however a C++ program
> which links with a Python library is unable to handle an exception
> thrown from Python.

Perhaps you should just use
https://www.boost.org/doc/libs/1_81_0/libs/python/doc/html/index.html

See also https://realpython.com/python-bindings-overview/

In both C++ and Python, exceptions can contain anything as their
payload. The problem becomes a problem of
mapping one language to the other, not just mapping exceptions. That
makes it a general cross-language binding generation problem,
so the forthcoming reflection/injection in C++ can certainly help, but
just having a 'list' of exceptions isn't going to
cut it either way.
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/XWENS3AO6PYAHGQL6S64NDXUT45PMEYP/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: [std-proposals] Exception compatibility with aliens

2023-01-18 Thread Frederick Virchanza Gotham
On Wed, Jan 18, 2023 at 3:07 PM Jason McKesson wrote:
>
> Also, this proposal seems to be missing the biggest issue with
> cross-language exception handling: the fact that you can't throw
> exceptions across languages. The only thing you *can* do is catch
> exceptions on the source language end, convert them into some data
> packet, and throw a different exception on the destination language
> side.


Yes this is what I had in mind. Behind the scenes, the C++ compiler
would catch the Python exception and then throw something that C++ can
deal with "such as std::aliens::python::exception".
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/5OARJXOXYFXHTO2OBHUGFVFSQHOVPVPO/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: [std-proposals] Exception compatibility with aliens

2023-01-18 Thread Barry Scott


> On 18 Jan 2023, at 15:35, Frederick Virchanza Gotham 
>  wrote:
> 
> On Wed, Jan 18, 2023 at 3:07 PM Jason McKesson wrote:
>> 
>> Also, this proposal seems to be missing the biggest issue with
>> cross-language exception handling: the fact that you can't throw
>> exceptions across languages. The only thing you *can* do is catch
>> exceptions on the source language end, convert them into some data
>> packet, and throw a different exception on the destination language
>> side.
> 
> 
> Yes this is what I had in mind. Behind the scenes, the C++ compiler
> would catch the Python exception and then throw something that C++ can
> deal with "such as std::aliens::python::exception".

In PyCXX I allows exceptions to go into and out of python and C++.
https://cxx.sourceforge.net/

You can raise in C++ go into python and back into C++ and the exception arrives 
as expected.
You can riase in Python fo into C++ and back to Python and again the exception 
arrives as expected.
 That is as long as its a python exception.

Barry

> ___
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-le...@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-dev@python.org/message/5OARJXOXYFXHTO2OBHUGFVFSQHOVPVPO/
> Code of Conduct: http://python.org/psf/codeofconduct/
> 

___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/NFUSVJB2N6FZVU23L2IVSCG3SN6DMINO/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: [std-proposals] Exception compatibility with aliens

2023-01-18 Thread Josh Engroff
Table this, perhaps? 


> On Jan 18, 2023, at 5:04 PM, Barry Scott  wrote:
> 
> 
> 
>> On 18 Jan 2023, at 15:35, Frederick Virchanza Gotham 
>>  wrote:
>> 
>>> On Wed, Jan 18, 2023 at 3:07 PM Jason McKesson wrote:
>>> 
>>> Also, this proposal seems to be missing the biggest issue with
>>> cross-language exception handling: the fact that you can't throw
>>> exceptions across languages. The only thing you *can* do is catch
>>> exceptions on the source language end, convert them into some data
>>> packet, and throw a different exception on the destination language
>>> side.
>> 
>> 
>> Yes this is what I had in mind. Behind the scenes, the C++ compiler
>> would catch the Python exception and then throw something that C++ can
>> deal with "such as std::aliens::python::exception".
> 
> In PyCXX I allows exceptions to go into and out of python and C++.
> https://cxx.sourceforge.net/
> 
> You can raise in C++ go into python and back into C++ and the exception 
> arrives as expected.
> You can riase in Python fo into C++ and back to Python and again the 
> exception arrives as expected.
>  That is as long as its a python exception.
> 
> Barry
> 
>> ___
>> Python-Dev mailing list -- python-dev@python.org
>> To unsubscribe send an email to python-dev-le...@python.org
>> https://mail.python.org/mailman3/lists/python-dev.python.org/
>> Message archived at 
>> https://mail.python.org/archives/list/python-dev@python.org/message/5OARJXOXYFXHTO2OBHUGFVFSQHOVPVPO/
>> Code of Conduct: http://python.org/psf/codeofconduct/
>> 
> 
> ___
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-le...@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-dev@python.org/message/NFUSVJB2N6FZVU23L2IVSCG3SN6DMINO/
> Code of Conduct: http://python.org/psf/codeofconduct/
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/7JQHGK6F2FI526XG7J77NPGOUC3LUWZ3/
Code of Conduct: http://python.org/psf/codeofconduct/