All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] gitkpkgv: Ensure files are closed
@ 2016-06-02  9:34 Richard Purdie
  2016-06-02  9:34 ` [PATCH 2/3] netmap-modules: Avoid type warning with python v3 Richard Purdie
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Richard Purdie @ 2016-06-02  9:34 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Richard Purdie

This avoids warnings with python 3.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta-oe/classes/gitpkgv.bbclass | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/meta-oe/classes/gitpkgv.bbclass b/meta-oe/classes/gitpkgv.bbclass
index 1cba00c..4866fac 100644
--- a/meta-oe/classes/gitpkgv.bbclass
+++ b/meta-oe/classes/gitpkgv.bbclass
@@ -87,11 +87,13 @@ def get_git_pkgv(d, use_tags):
 
                     if commits != "":
                         oe.path.remove(rev_file, recurse=False)
-                        open(rev_file, "w").write("%d\n" % int(commits))
+                        with open(rev_file, "w") as f:
+                            f.write("%d\n" % int(commits))
                     else:
                         commits = "0"
                 else:
-                    commits = open(rev_file, "r").readline(128).strip()
+                    with open(rev_file, "r") as f:
+                        commits = f.readline(128).strip()
 
                 if use_tags:
                     try:
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] netmap-modules: Avoid type warning with python v3
  2016-06-02  9:34 [PATCH 1/3] gitkpkgv: Ensure files are closed Richard Purdie
@ 2016-06-02  9:34 ` Richard Purdie
  2016-06-02  9:34 ` [PATCH 3/3] abiword/gnone-vfs: Use print as a function Richard Purdie
  2016-06-07  9:02 ` [PATCH 1/3] gitkpkgv: Ensure files are closed Mike Looijmans
  2 siblings, 0 replies; 6+ messages in thread
From: Richard Purdie @ 2016-06-02  9:34 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Richard Purdie

Python 3 is stricter about type comparisions, this avoids warnings.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta-networking/recipes-kernel/netmap/netmap-modules_git.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta-networking/recipes-kernel/netmap/netmap-modules_git.bb b/meta-networking/recipes-kernel/netmap/netmap-modules_git.bb
index 406a4f3..6544bb5 100644
--- a/meta-networking/recipes-kernel/netmap/netmap-modules_git.bb
+++ b/meta-networking/recipes-kernel/netmap/netmap-modules_git.bb
@@ -70,7 +70,7 @@ do_configure_append () {
 #define NETMAP_LINUX_HAVE_E1000E_DOWN2
 EOF
 
-if ${@ 'false' if (bb.utils.vercmp_string(d.getVar('KERNEL_VERSION', True), '3.17') < 0) else 'true' } ; then
+if ${@ 'false' if (bb.utils.vercmp_string(d.getVar('KERNEL_VERSION', True) or "0", '3.17') < 0) else 'true' } ; then
     echo OK
     cat >>  ${S}/LINUX/netmap_linux_config.h <<EOF
 #define NETMAP_LINUX_ALLOC_NETDEV_4ARGS
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] abiword/gnone-vfs: Use print as a function
  2016-06-02  9:34 [PATCH 1/3] gitkpkgv: Ensure files are closed Richard Purdie
  2016-06-02  9:34 ` [PATCH 2/3] netmap-modules: Avoid type warning with python v3 Richard Purdie
@ 2016-06-02  9:34 ` Richard Purdie
  2016-06-07  9:02 ` [PATCH 1/3] gitkpkgv: Ensure files are closed Mike Looijmans
  2 siblings, 0 replies; 6+ messages in thread
From: Richard Purdie @ 2016-06-02  9:34 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Richard Purdie

In python 3, print is a function. Disable some pointless debug output
whilst here.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta-gnome/recipes-gnome/abiword/abiword_3.0.1.bb      | 2 +-
 meta-gnome/recipes-gnome/gnome-vfs/gnome-vfs_2.24.4.bb | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta-gnome/recipes-gnome/abiword/abiword_3.0.1.bb b/meta-gnome/recipes-gnome/abiword/abiword_3.0.1.bb
index 962a56c..e0888c1 100644
--- a/meta-gnome/recipes-gnome/abiword/abiword_3.0.1.bb
+++ b/meta-gnome/recipes-gnome/abiword/abiword_3.0.1.bb
@@ -113,7 +113,7 @@ python populate_packages_prepend () {
     packages = d.getVar('PACKAGES', 1).split()
     for pkg in packages[1:]:
         if not pkg in blacklist and not pkg in metapkg_rdepends and not pkg.count("-dev") and not pkg.count("-dbg") and not pkg.count("static") and not pkg.count("locale") and not pkg.count("abiword-doc"):
-            print "Modifying ", pkg
+            print("Modifying %s" % pkg)
             metapkg_rdepends.append(pkg)
     d.setVar('RDEPENDS_' + metapkg, ' '.join(metapkg_rdepends))
     d.setVar('DESCRIPTION_' + metapkg, 'abiword-plugin meta package')
diff --git a/meta-gnome/recipes-gnome/gnome-vfs/gnome-vfs_2.24.4.bb b/meta-gnome/recipes-gnome/gnome-vfs/gnome-vfs_2.24.4.bb
index f9b02b1..d311338 100644
--- a/meta-gnome/recipes-gnome/gnome-vfs/gnome-vfs_2.24.4.bb
+++ b/meta-gnome/recipes-gnome/gnome-vfs/gnome-vfs_2.24.4.bb
@@ -53,7 +53,7 @@ FILES_${PN}-doc += "${datadir}/gtk-doc"
 PACKAGES_DYNAMIC += "^gnome-vfs-plugin-.*"
 
 python populate_packages_prepend () {
-    print d.getVar('FILES_gnome-vfs', 1)
+    #print(d.getVar('FILES_gnome-vfs', True))
 
     plugindir = d.expand('${libdir}/gnome-vfs-2.0/modules/')
     do_split_packages(d, plugindir, '^lib(.*)\.so$', 'gnome-vfs-plugin-%s', 'GNOME VFS plugin for %s')
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] gitkpkgv: Ensure files are closed
  2016-06-02  9:34 [PATCH 1/3] gitkpkgv: Ensure files are closed Richard Purdie
  2016-06-02  9:34 ` [PATCH 2/3] netmap-modules: Avoid type warning with python v3 Richard Purdie
  2016-06-02  9:34 ` [PATCH 3/3] abiword/gnone-vfs: Use print as a function Richard Purdie
@ 2016-06-07  9:02 ` Mike Looijmans
  2016-06-07 13:49   ` Richard Purdie
  2 siblings, 1 reply; 6+ messages in thread
From: Mike Looijmans @ 2016-06-07  9:02 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Richard Purdie

Looks like regression in Python itself?

In both Python 2 and 3, the file is closed properly if the file object is not 
being stored:

 >>> import os
 >>> os.listdir('/proc/self/fd')
['0', '1', '2', '3']
 >>> l=open('/proc/self/stat').readline()
 >>> os.listdir('/proc/self/fd')
['0', '1', '2', '3']
 >>> f=open('/proc/self/stat')
 >>> os.listdir('/proc/self/fd')
['0', '1', '2', '3', '4']
 >>>


(file descriptor "3" is the one being used to read the /proc/self/fd 
directory, "4" is the one used for reading the stat file)

The "with" construction should not be needed here. Something else is causing 
this (e.g. nested function definition or exception handler?).

Mike.


On 02-06-16 11:34, Richard Purdie wrote:
> This avoids warnings with python 3.
>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>   meta-oe/classes/gitpkgv.bbclass | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/meta-oe/classes/gitpkgv.bbclass b/meta-oe/classes/gitpkgv.bbclass
> index 1cba00c..4866fac 100644
> --- a/meta-oe/classes/gitpkgv.bbclass
> +++ b/meta-oe/classes/gitpkgv.bbclass
> @@ -87,11 +87,13 @@ def get_git_pkgv(d, use_tags):
>
>                       if commits != "":
>                           oe.path.remove(rev_file, recurse=False)
> -                        open(rev_file, "w").write("%d\n" % int(commits))
> +                        with open(rev_file, "w") as f:
> +                            f.write("%d\n" % int(commits))
>                       else:
>                           commits = "0"
>                   else:
> -                    commits = open(rev_file, "r").readline(128).strip()
> +                    with open(rev_file, "r") as f:
> +                        commits = f.readline(128).strip()
>
>                   if use_tags:
>                       try:
>



Kind regards,

Mike Looijmans
System Expert

TOPIC Embedded Products
Eindhovenseweg 32-C, NL-5683 KH Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: mike.looijmans@topicproducts.com
Website: www.topicproducts.com

Please consider the environment before printing this e-mail







^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] gitkpkgv: Ensure files are closed
  2016-06-07  9:02 ` [PATCH 1/3] gitkpkgv: Ensure files are closed Mike Looijmans
@ 2016-06-07 13:49   ` Richard Purdie
  2016-06-10  6:06     ` Mike Looijmans
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Purdie @ 2016-06-07 13:49 UTC (permalink / raw)
  To: Mike Looijmans, openembedded-devel

On Tue, 2016-06-07 at 11:02 +0200, Mike Looijmans wrote:
> Looks like regression in Python itself?
> 
> In both Python 2 and 3, the file is closed properly if the file
> object is not 
> being stored:
> 
>  >>> import os
>  >>> os.listdir('/proc/self/fd')
> ['0', '1', '2', '3']
>  >>> l=open('/proc/self/stat').readline()
>  >>> os.listdir('/proc/self/fd')
> ['0', '1', '2', '3']
>  >>> f=open('/proc/self/stat')
>  >>> os.listdir('/proc/self/fd')
> ['0', '1', '2', '3', '4']
>  >>>
> 
> 
> (file descriptor "3" is the one being used to read the /proc/self/fd 
> directory, "4" is the one used for reading the stat file)
> 
> The "with" construction should not be needed here. Something else is
> causing 
> this (e.g. nested function definition or exception handler?).

$ python2 -Wdefault -c "open('/bin/bash')"
$ python3 -Wdefault -c "open('/bin/bash')"
-c:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='/bin/bash' mode='r' encoding='UTF-8'>

Admittedly its not an out the box warning but it is one that seems to
be enabled under bitbake. Details in:

https://bugs.python.org/issue10093

but the gist of the issue is that relying on the garbage collector to
close files is a cpython'ism and other implementations of python may
not do this.

So whilst "with" might not be strictly required, it is recommended.

Cheers,

Richard






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] gitkpkgv: Ensure files are closed
  2016-06-07 13:49   ` Richard Purdie
@ 2016-06-10  6:06     ` Mike Looijmans
  0 siblings, 0 replies; 6+ messages in thread
From: Mike Looijmans @ 2016-06-10  6:06 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Richard Purdie

On 07-06-16 15:49, Richard Purdie wrote:
> On Tue, 2016-06-07 at 11:02 +0200, Mike Looijmans wrote:
>> Looks like regression in Python itself?
>>
>> In both Python 2 and 3, the file is closed properly if the file
>> object is not
>> being stored:
>>
>>   >>> import os
>>   >>> os.listdir('/proc/self/fd')
>> ['0', '1', '2', '3']
>>   >>> l=open('/proc/self/stat').readline()
>>   >>> os.listdir('/proc/self/fd')
>> ['0', '1', '2', '3']
>>   >>> f=open('/proc/self/stat')
>>   >>> os.listdir('/proc/self/fd')
>> ['0', '1', '2', '3', '4']
>>   >>>
>>
>>
>> (file descriptor "3" is the one being used to read the /proc/self/fd
>> directory, "4" is the one used for reading the stat file)
>>
>> The "with" construction should not be needed here. Something else is
>> causing
>> this (e.g. nested function definition or exception handler?).
>
> $ python2 -Wdefault -c "open('/bin/bash')"
> $ python3 -Wdefault -c "open('/bin/bash')"
> -c:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='/bin/bash' mode='r' encoding='UTF-8'>
>
> Admittedly its not an out the box warning but it is one that seems to
> be enabled under bitbake. Details in:
>
> https://bugs.python.org/issue10093
>
> but the gist of the issue is that relying on the garbage collector to
> close files is a cpython'ism and other implementations of python may
> not do this.
>
> So whilst "with" might not be strictly required, it is recommended.

Oh dear, looks like's there's been a change of sorts in the Python community 
and they're now adopting the Java stupidity of "the garbage collector doesn't 
actually work so you'll have to do all your own resource management".

These are reasons why projects are so reluctant to move from Python 2 to 3. 
Python 3 is just a different language.

Ah well, guess we'll have to live with that. I'm already getting used to 
embedded devices running 30MB of software to enable the flashlight...


Kind regards,

Mike Looijmans
System Expert

TOPIC Embedded Products
Eindhovenseweg 32-C, NL-5683 KH Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: mike.looijmans@topicproducts.com
Website: www.topicproducts.com

Please consider the environment before printing this e-mail







^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-06-10  6:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-02  9:34 [PATCH 1/3] gitkpkgv: Ensure files are closed Richard Purdie
2016-06-02  9:34 ` [PATCH 2/3] netmap-modules: Avoid type warning with python v3 Richard Purdie
2016-06-02  9:34 ` [PATCH 3/3] abiword/gnone-vfs: Use print as a function Richard Purdie
2016-06-07  9:02 ` [PATCH 1/3] gitkpkgv: Ensure files are closed Mike Looijmans
2016-06-07 13:49   ` Richard Purdie
2016-06-10  6:06     ` Mike Looijmans

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.