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)."
This commit is contained in:
Thomas Ingvarsson
2018-09-18 21:52:08 +02:00
parent 5f2569c186
commit b3affd57dc
2 changed files with 5 additions and 3 deletions

View File

@@ -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);

View File

@@ -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]);
}