Re: Py_IS_TYPE(op, &PyDict_Type) does not work on MacOS

2021-11-10 Thread Marco Sulla
Indeed now I use PyDict_Check, but anyway it's very strange that
Py_IS_TYPE(op, &PyDict_Type) does not work only on MacOS.

On Mon, 8 Nov 2021 at 19:30, Barry  wrote:
>
>
>
> On 8 Nov 2021, at 07:45, Marco Sulla  wrote:
>
> As you can read here:
>
> https://github.com/Marco-Sulla/python-frozendict/issues/37
>
> Py_IS_TYPE(op, &PyDict_Type) did not work on MacOS. I had to use PyDict_Check.
>
> Why don't I have this problem with Linux?
>
> PS: since I'm creating a modified version of dict, I copied the dict
> internal source and I link against them. Maybe the problem is
> correlated.
>
>
> You can see what I did for PyCXX at 
> https://sourceforge.net/p/cxx/code/HEAD/tree/trunk/CXX/Src/IndirectPythonInterface.cxx
>
> See the _DictCheck and ends up using PyObject_IsInstance.
>
> My guess is that use PyDict_Check is a good and better for the future.
>
> Barry
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Vnev issue - AttributeError: module 'sysconfig' has no attribute '_get_default_scheme'. Did you mean: 'get_default_scheme'?

2021-11-10 Thread pranesh kumar
   Hi

   Shared a google sheet with details

   
[1]https://docs.google.com/presentation/d/1W9wH08dfzA1XP5sqBBNj0bk0YPPGVG1z0-WQ3yt1NUU/edit?usp=sharing



   after importing OpenCV

   When typing "cv2." All functions related to the OpenCV module should show
   up which is not happening

   How to fix this issue.



   Thanks in advance

   Regards

   Pranesh Kumar

   9789411538



   Sent from [2]Mail for Windows



   From: [3]OmPs
   Sent: 06 November 2021 00:01
   To: [4]pranesh kumar
   Cc: [5]python-list@python.org
   Subject: Re: Vnev issue - AttributeError: module 'sysconfig' has no
   attribute '_get_default_scheme'. Did you mean: 'get_default_scheme'?



   How are you creating the virtualenv. Creating virtualenv is pretty
   straightforward. Please share what you are doing?



   On Fri, 5 Nov 2021 at 10:15 PM, pranesh kumar
   <[6]praneshkuma...@gmail.com> wrote:

  Hi

  Facing problem in creating virtual environment and in importing modules
   in
  pycharm community version 2021.2.2.

  Trying to import Open CV in pycharm but not able to complete

  When creating new virtual environment error I got is "AttributeError:
  module 'sysconfig' has no attribute '_get_default_scheme'. Did you
   mean:
  'get_default_scheme'?"

  Pranesh Kumar

  9789411538

  Your inputs could be so grateful on this issue

  Sent from [1]Mail for Windows

   References

  Visible links
  1. [7]https://go.microsoft.com/fwlink/?LinkId=550986
   --
   [8]https://mail.python.org/mailman/listinfo/python-list



References

   Visible links
   1. 
https://docs.google.com/presentation/d/1W9wH08dfzA1XP5sqBBNj0bk0YPPGVG1z0-WQ3yt1NUU/edit?usp=sharing
   2. https://go.microsoft.com/fwlink/?LinkId=550986
   3. mailto:torque.in...@gmail.com
   4. mailto:praneshkuma...@gmail.com
   5. mailto:python-list@python.org
   6. mailto:praneshkuma...@gmail.com
   7. https://go.microsoft.com/fwlink/?LinkId=550986
   8. https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Breaking new relic format on a new line character in FileHandler appender

2021-11-10 Thread Vijay Karavadra via Python-list
Hello Team,

I'm trying to add logs in the new relic platform from a python application.
For that, I've to add logs in a local file in a specific format which is

'{"log.level":"%(levelname)s", "log.entity.name":"my-service-name",
"message":"%(message)s"}'


This works fine in normal scenario and generates the below type of
line in log file and logs are added to new relic with expected
properties set like log level, entity name, message etc.

{"log.level":"INFO", "log.entity.name":"my-service-name", "message":"test"}


This issue occurs when a new line is present in the message property of the
log i.e. on any error we have a message like "Traceback (most recent call
last):" which represents an error traceback after this line with a new line
character. In this case, multiple logs are added instead of a single log,
my expected formatting breaks and logging properties are not set in the new
relic.

Sample breaking log:

{"log.level":"ERROR", "log.entity.name":"my-service-name",
"message":"[Errno 2] No such file or directory:
'E:\\comms-nlp-service\\src\\GoogleAuthentication\\xyz.json' -> Traceback
(most recent call last):
  File "E:\comms-nlp-service\src\app\nlp\carrier_cancel_apiai.py", line 31,
in query
credentials =
service_account.Credentials.from_service_account_file(filename, scopes
=(scope,))
  File "C:\Python34\lib\site-packages\google\oauth2\service_account.py",
line 209, in from_service_account_file
filename, require=['client_email', 'token_uri'])
  File
"C:\Python34\lib\site-packages\google\auth\_service_account_info.py", line
71, in from_filename
with io.open(filename, 'r', encoding='utf-8') as json_file:
FileNotFoundError: [Errno 2] No such file or directory:
'E:\\comms-nlp-service\\src\\GoogleAuthentication\\ xyz  .json'
"}

Any suggestions on this would be a great help.

-- 
Thanks,
Vijay Karavadra
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Avoid nested SIGINT handling

2021-11-10 Thread Jon Ribbens via Python-list
On 2021-11-10, Paulo da Silva  wrote:
> Hi!
>
> How do I handle a SIGINT (or any other signal) avoid nesting?

I don't think you need to. Python will only call signal handlers in
the main thread, so a handler can't be executed while another handler
is running anyway.
-- 
https://mail.python.org/mailman/listinfo/python-list


Avoid nested SIGINT handling

2021-11-10 Thread Paulo da Silva
Hi!

How do I handle a SIGINT (or any other signal) avoid nesting?

Does this work?

class STATUS:
InInt=False

def SIGINT_handler(sn,f):
if STATUS.InInt: return
STATUS.InInt=True
process_int()
STATUS.InInt=False

Thanks for any suggestions.
Paulo
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Avoid nested SIGINT handling

2021-11-10 Thread Paulo da Silva
Às 21:55 de 10/11/21, Jon Ribbens escreveu:
> On 2021-11-10, Paulo da Silva  wrote:
>> Hi!
>>
>> How do I handle a SIGINT (or any other signal) avoid nesting?
> 
> I don't think you need to. Python will only call signal handlers in
> the main thread, so a handler can't be executed while another handler
> is running anyway.
> 

Do you mean that if I issue a ctrl+c while the previous one is
"processing" it is held until, at least, the "processing" returns?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Breaking new relic format on a new line character in FileHandler appender

2021-11-10 Thread Chris Angelico
On Thu, Nov 11, 2021 at 5:00 PM Vijay Karavadra via Python-list
 wrote:
>
> Hello Team,
>
> I'm trying to add logs in the new relic platform from a python application.
> For that, I've to add logs in a local file in a specific format which is
>
> '{"log.level":"%(levelname)s", "log.entity.name":"my-service-name",
> "message":"%(message)s"}'
>

Looks like JSON to me. Have you considered using the json module to format it?

json.dumps({"log.level":levelname, "log.entity.name":"my-service-name",
"message":message})

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Avoid nested SIGINT handling

2021-11-10 Thread Chris Angelico
On Thu, Nov 11, 2021 at 5:01 PM Jon Ribbens via Python-list
 wrote:
>
> On 2021-11-10, Paulo da Silva  wrote:
> > Hi!
> >
> > How do I handle a SIGINT (or any other signal) avoid nesting?
>
> I don't think you need to. Python will only call signal handlers in
> the main thread, so a handler can't be executed while another handler
> is running anyway.

Threads aren't the point here - signals happen immediately.

Would it be easier to catch KeyboardInterrupt and do your processing
there, rather than actually catching SIGINT?

I'd recommend just trying what you have, and seeing if it's reentrant.
My suspicion is that it isn't, on a technical level (the Python
function will be queued for when it's safe to call it - probably after
the next bytecode instruction), but that your own code will still need
to worry about reentrancy.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list