All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: liezhi.yang@windriver.com
Cc: bitbake-devel@lists.openembedded.org
Subject: Re: [bitbake-devel] [PATCH v3 1/1] bitbake: event: Inject empty lines to make code match lineno in filename
Date: Sun, 31 Dec 2023 21:28:07 +0100	[thread overview]
Message-ID: <202312312028077ba80d35@mail.local> (raw)
In-Reply-To: <b64c2496383eb263e6fd2d636ec7a2d88b424db6.1703829627.git.liezhi.yang@windriver.com>

This causes bitbake-selftest failures:

======================================================================
ERROR: test_register_from_string (bb.tests.event.EventHandlingTest)
Test register method receiving code in string
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/tests/event.py", line 121, in test_register_from_string
    result = bb.event.register("string_handler", "    return True")
  File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/event.py", line 261, in register
    tmp = "\n" * (lineno-1) + tmp
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'

https://autobuilder.yoctoproject.org/typhoon/#/builders/80/builds/6202/steps/11/logs/stdio

On 28/12/2023 22:06:42-0800, Robert Yang via lists.openembedded.org wrote:
> From: Robert Yang <liezhi.yang@windriver.com>
> 
> So that we can get the correct error messages.
> 
> * In python 3.10.9, the error message was:
>   ERROR: Unable to register event handler 'defaultbase_eventhandler':
>     File "/path/to/poky/meta/classes-global/base.bbclass", line 4
>       # SPDX-License-Identifier: MIT
>              ^^^^^
>   SyntaxError: invalid syntax
> 
>   This is hard to debug since the error line number 4 is incorrect, but nothing
>   is wrong with the code in line 4.
> 
> * Now the error message and lineno is correct:
>   ERROR: Unable to register event handler 'defaultbase_eventhandler':
>     File "/path/to/poky/meta/classes-global/base.bbclass", line 256
>       an error line
>          ^^^^^
>   SyntaxError: invalid syntax
> 
> And no impact on parsing time:
> * Before:
> $ rm -fr cache tmp; time bitbake -p
> real    0m27.254s
> 
> * Now:
> $ rm -fr cache tmp; time bitbake -p
> real    0m27.200s
> 
> Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
> ---
>  bitbake/lib/bb/event.py | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
> index f8acacd80d1..7722258b7e8 100644
> --- a/bitbake/lib/bb/event.py
> +++ b/bitbake/lib/bb/event.py
> @@ -257,6 +257,8 @@ def register(name, handler, mask=None, filename=None, lineno=None, data=None):
>          # handle string containing python code
>          if isinstance(handler, str):
>              tmp = "def %s(e, d):\n%s" % (name, handler)
> +            # Inject empty lines to make code match lineno in filename
> +            tmp = "\n" * (lineno-1) + tmp
>              try:
>                  code = bb.methodpool.compile_cache(tmp)
>                  if not code:
> -- 
> 2.42.0
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#15717): https://lists.openembedded.org/g/bitbake-devel/message/15717
> Mute This Topic: https://lists.openembedded.org/mt/103413642/3617179
> Group Owner: bitbake-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
> 


-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


      parent reply	other threads:[~2023-12-31 20:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-29  6:06 [PATCH v3 0/1] bitbake: event: Inject empty lines to make code match lineno in filename liezhi.yang
2023-12-29  6:06 ` [PATCH v3 1/1] " liezhi.yang
2023-12-29 11:16   ` [bitbake-devel] " Richard Purdie
2024-01-08 10:23     ` Robert Yang
2023-12-31 20:28   ` Alexandre Belloni [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202312312028077ba80d35@mail.local \
    --to=alexandre.belloni@bootlin.com \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=liezhi.yang@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.