From b3affd57dce5a736b58ece0127efdeb9b4a4c80a Mon Sep 17 00:00:00 2001 From: Thomas Ingvarsson Date: Tue, 18 Sep 2018 21:52:08 +0200 Subject: [PATCH] Correct usage of toString on Uint8Array According to warning given today with gnome 3.30: "Some code called array.toString() on a Uint8Array instance. Previously this would have interpreted the bytes of the array as a string, but that is nonstandard. In the future this will return the bytes as comma-separated digits. For the time being, the old behavior has been preserved, but please fix your code anyway to explicitly call ByteArray.toString(array)." --- freon@UshakovVasilii_Github.yahoo.com/commandLineUtil.js | 5 +++-- freon@UshakovVasilii_Github.yahoo.com/nvidiaUtil.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/freon@UshakovVasilii_Github.yahoo.com/commandLineUtil.js b/freon@UshakovVasilii_Github.yahoo.com/commandLineUtil.js index 8635de0..db401c8 100644 --- a/freon@UshakovVasilii_Github.yahoo.com/commandLineUtil.js +++ b/freon@UshakovVasilii_Github.yahoo.com/commandLineUtil.js @@ -1,3 +1,4 @@ +const ByteArray = imports.byteArray; const Lang = imports.lang; const GLib = imports.gi.GLib; const Gio = imports.gi.Gio; @@ -33,13 +34,13 @@ var CommandLineUtil = new Lang.Class({ while (([line, size] = outReader.read_line(null)) != null && line != null) { if(line) - output.push(line.toString()); + output.push(ByteArray.toString(line)); } stdout.close(null); while (([line, size] = errReader.read_line(null)) != null && line != null) { if(line) - output.push(line.toString()); + output.push(ByteArray.toString(line)); } stderr.close(null); diff --git a/freon@UshakovVasilii_Github.yahoo.com/nvidiaUtil.js b/freon@UshakovVasilii_Github.yahoo.com/nvidiaUtil.js index 985d1ee..c9520dd 100644 --- a/freon@UshakovVasilii_Github.yahoo.com/nvidiaUtil.js +++ b/freon@UshakovVasilii_Github.yahoo.com/nvidiaUtil.js @@ -1,3 +1,4 @@ +const ByteArray = imports.byteArray; const Lang = imports.lang; const GLib = imports.gi.GLib; const Gio = imports.gi.Gio; @@ -33,7 +34,7 @@ var NvidiaUtil = new Lang.Class({ let [line, size] = [null, 0]; while (([line, size] = outReader.read_line(null)) != null && line != null) { - let match = /.*\[gpu:[\d]\].*\(([\w\d\ ]+)\).*/.exec(line.toString()); + let match = /.*\[gpu:[\d]\].*\(([\w\d\ ]+)\).*/.exec(ByteArray.toString(line)); if(match){ this._labels.push(match[1]); }