We return plain strings everywhere so we should encode the unicode object with utf-8 and store it as a plain string.
Signed-off-by: Vratislav Podzimek vpodzime@redhat.com --- blivet/devices.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/blivet/devices.py b/blivet/devices.py index 4877a39..6aa6c26 100644 --- a/blivet/devices.py +++ b/blivet/devices.py @@ -1374,8 +1374,8 @@ class PartitionDevice(StorageDevice): if self.partedPartition is None: self._name = self.req_name else: - self._name = \ - devicePathToName(self.partedPartition.getDeviceNodeName()) + dev_node_name = self.partedPartition.getDeviceNodeName() + self._name = devicePathToName(dev_node_name.encode("utf-8"))
def dependsOn(self, dep): """ Return True if this device depends on dep. """
On Wed, Jun 19, 2013 at 01:57:12PM +0200, Vratislav Podzimek wrote:
We return plain strings everywhere so we should encode the unicode object with utf-8 and store it as a plain string.
Signed-off-by: Vratislav Podzimek vpodzime@redhat.com
blivet/devices.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/blivet/devices.py b/blivet/devices.py index 4877a39..6aa6c26 100644 --- a/blivet/devices.py +++ b/blivet/devices.py @@ -1374,8 +1374,8 @@ class PartitionDevice(StorageDevice): if self.partedPartition is None: self._name = self.req_name else:
self._name = \
devicePathToName(self.partedPartition.getDeviceNodeName())
dev_node_name = self.partedPartition.getDeviceNodeName()
self._name = devicePathToName(dev_node_name.encode("utf-8"))
def dependsOn(self, dep): """ Return True if this device depends on dep. """
-- 1.7.11.7
Have you tested this? I'm worried about what happens when the ascii self._name gets used. Are there places where it has to match what parted returned? eg. looking up the device using the name.
On Thu, 2013-06-20 at 09:25 -0700, Brian C. Lane wrote:
On Wed, Jun 19, 2013 at 01:57:12PM +0200, Vratislav Podzimek wrote:
We return plain strings everywhere so we should encode the unicode object with utf-8 and store it as a plain string.
Signed-off-by: Vratislav Podzimek vpodzime@redhat.com
blivet/devices.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/blivet/devices.py b/blivet/devices.py index 4877a39..6aa6c26 100644 --- a/blivet/devices.py +++ b/blivet/devices.py @@ -1374,8 +1374,8 @@ class PartitionDevice(StorageDevice): if self.partedPartition is None: self._name = self.req_name else:
self._name = \
devicePathToName(self.partedPartition.getDeviceNodeName())
dev_node_name = self.partedPartition.getDeviceNodeName()
self._name = devicePathToName(dev_node_name.encode("utf-8"))
def dependsOn(self, dep): """ Return True if this device depends on dep. """
-- 1.7.11.7
Have you tested this? I'm worried about what happens when the ascii self._name gets used. Are there places where it has to match what parted returned? eg. looking up the device using the name.
I've tested that it really fixes the issue reported in the bug. However, I'll give it some more testing to find out if it doesn't break something else. Generally it should be okay, because "ascii_str".encode("utf-8") just returns the same string and u"ascii_str" == "ascii_str" returns True. But looking at the code I see more places where the getDeviceNodeName is called, so I'll send a new patch adding the encoding to them as well.
We return plain strings everywhere so we should encode the unicode object with utf-8 and store it as a plain string.
Signed-off-by: Vratislav Podzimek vpodzime@redhat.com --- blivet/__init__.py | 9 ++++++--- blivet/devices.py | 4 ++-- blivet/partitioning.py | 6 +++--- 3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/blivet/__init__.py b/blivet/__init__.py index ec828a6..78a0745 100644 --- a/blivet/__init__.py +++ b/blivet/__init__.py @@ -771,7 +771,8 @@ class Blivet(object): continue
self.recursiveRemove(part) - log.debug("partitions: %s" % [p.getDeviceNodeName() for p in part.partedPartition.disk.partitions]) + log.debug("partitions: %s" % (p.getDeviceNodeName().encode("utf-8") + for p in part.partedPartition.disk.partitions))
# now remove any empty extended partitions self.removeEmptyExtendedPartitions() @@ -826,10 +827,12 @@ class Blivet(object): log.debug("checking whether disk %s has an empty extended" % disk.name) extended = disk.format.extendedPartition logical_parts = disk.format.logicalPartitions - log.debug("extended is %s ; logicals is %s" % (extended, [p.getDeviceNodeName() for p in logical_parts])) + log.debug("extended is %s ; logicals is %s" % (extended, + (p.getDeviceNodeName().encode("utf-8") + for p in logical_parts))) if extended and not logical_parts: log.debug("removing empty extended partition from %s" % disk.name) - extended_name = devicePathToName(extended.getDeviceNodeName()) + extended_name = devicePathToName(extended.getDeviceNodeName().encode("utf-8")) extended = self.devicetree.getDeviceByName(extended_name) self.destroyDevice(extended)
diff --git a/blivet/devices.py b/blivet/devices.py index 4877a39..6aa6c26 100644 --- a/blivet/devices.py +++ b/blivet/devices.py @@ -1374,8 +1374,8 @@ class PartitionDevice(StorageDevice): if self.partedPartition is None: self._name = self.req_name else: - self._name = \ - devicePathToName(self.partedPartition.getDeviceNodeName()) + dev_node_name = self.partedPartition.getDeviceNodeName() + self._name = devicePathToName(dev_node_name.encode("utf-8"))
def dependsOn(self, dep): """ Return True if this device depends on dep. """ diff --git a/blivet/partitioning.py b/blivet/partitioning.py index 8660969..cc96228 100644 --- a/blivet/partitioning.py +++ b/blivet/partitioning.py @@ -675,7 +675,7 @@ def updateExtendedPartitions(storage, disks): storage.devicetree._removeDevice(part, moddisk=False) continue
- extendedName = devicePathToName(extended.getDeviceNodeName()) + extendedName = devicePathToName(extended.getDeviceNodeName().encode("utf-8")) device = storage.devicetree.getDeviceByName(extendedName) if device: if not device.exists: @@ -1058,7 +1058,7 @@ def allocatePartitions(storage, disks, partitions, freespace):
partition = addPartition(disklabel, free, part_type, _part.req_size) log.debug("created partition %s of %dMB and added it to %s" % - (partition.getDeviceNodeName(), partition.getSize(), + (partition.getDeviceNodeName().encode("utf-8"), partition.getSize(), disklabel.device))
# this one sets the name @@ -1870,7 +1870,7 @@ def growPartitions(disks, partitions, free, size_sets=None): # If there was no extended partition on this disk when # doPartitioning was called we won't have a # PartitionDevice instance for it. - name = partition.getDeviceNodeName() + name = partition.getDeviceNodeName().encode("utf-8")
log.debug("setting %s new geometry: %s" % (name, partition.geometry))
I've tested this patch on live and netinst installations and nothing seemed to be broken by it.
On Mon, Jun 24, 2013 at 04:08:25PM +0200, Vratislav Podzimek wrote:
I've tested this patch on live and netinst installations and nothing seemed to be broken by it.
After actually paying attention I realized these are pyparted objects and was able to reproduce with TC6 live -- pyparted is returning unicode objects and it really shouldn't. This is caused by a py3.x set of patches, so I'm NAK for these patches. We need to fix this in pyparted, there's no reason for it to be returning unicode objects. At the most it should utf-8 encode anything and return a string object.
On Mon, 2013-06-24 at 10:56 -0700, Brian C. Lane wrote:
On Mon, Jun 24, 2013 at 04:08:25PM +0200, Vratislav Podzimek wrote:
I've tested this patch on live and netinst installations and nothing seemed to be broken by it.
After actually paying attention I realized these are pyparted objects and was able to reproduce with TC6 live -- pyparted is returning unicode objects and it really shouldn't. This is caused by a py3.x set of patches, so I'm NAK for these patches. We need to fix this in pyparted, there's no reason for it to be returning unicode objects. At the most it should utf-8 encode anything and return a string object.
Thanks for looking at this, I didn't realize we can fix this on the right side. Returning utf-8-encoded strings should be okay. I believe there could be non-ascii characters in labels, for example.
anaconda-patches@lists.fedorahosted.org