Bug 1365568 - On repository error: UnboundLocalError: local variable 'yum' referenced before assignment
Summary: On repository error: UnboundLocalError: local variable 'yum' referenced befor...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: livecd-tools
Version: 24
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Brian Lane
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-08-09 14:50 UTC by Sandro Bonazzola
Modified: 2019-09-05 14:31 UTC (History)
8 users (show)

Fixed In Version: livecd-tools-23.4-1 livecd-tools-23.4-1.fc24
Clone Of:
Environment:
Last Closed: 2016-09-13 22:25:48 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Sandro Bonazzola 2016-08-09 14:50:06 UTC
Got a repository error while composing a livecd:

00:02:22.248 Traceback (most recent call last):
00:02:22.248   File "/bin/livecd-creator", line 242, in <module>
00:02:22.249     sys.exit(main())
00:02:22.249   File "/bin/livecd-creator", line 218, in main
00:02:22.249     creator.install()
00:02:22.249   File "/usr/lib/python2.7/site-packages/imgcreate/creator.py", line 675, in install
00:02:22.251     ayum.runInstall()
00:02:22.251   File "/usr/lib/python2.7/site-packages/imgcreate/yuminst.py", line 203, in runInstall
00:02:22.251     except yum.Errors.RepoError, e:
00:02:22.251 UnboundLocalError: local variable 'yum' referenced before assignment

Looks like an "import yum" is missing.

python-imgcreate-23.3-1.fc24.x86_64

Comment 1 Brian Lane 2016-08-09 17:51:18 UTC
How were you calling livecd-creator? yum gets imported at the top of yuminst.py so there should be no way for yum to be undefined.

Comment 2 Sandro Bonazzola 2016-08-23 14:08:17 UTC
(In reply to Brian Lane from comment #1)
> How were you calling livecd-creator? yum gets imported at the top of
> yuminst.py so there should be no way for yum to be undefined.

Looks like you need to explicitly import yum.Errors.

I reached that condition trying to add to a livecd a package with rich boolean dependencies (https://fedoraproject.org/wiki/Packaging:Guidelines#Rich.2FBoolean_dependencies)

The triggering package for me is ovirt-engine from http://resources.ovirt.org/pub/ovirt-master-snapshot/rpm/fc24/ which includes the following require:

Requires:	(yum-plugin-versionlock if yum)

Comment 3 Sandro Bonazzola 2016-08-23 14:09:02 UTC
(opened a separate bug about it)

Comment 4 Brian Lane 2016-08-23 17:26:21 UTC
Does adding that help? Can you post a patch or a PR on https://github.com/rhinstaller/livecd-tools

I can't see how this is happening. Both creator.py and yuminst.py import yum and when I try this manually I get this, which is what I'd expect:

>>> from yum.Errors import YumBaseError
>>> yum
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'yum' is not defined
>>> yum.Errors
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'yum' is not defined
>>> import yum
>>> yum.Errors
<module 'yum.Errors' from '/usr/lib/python2.7/site-packages/yum/Errors.pyc'>


Obviously you're seeing it :) But I just can't figure out how it's possible for it to happen.

Comment 5 Sandro Bonazzola 2016-08-26 13:17:28 UTC
(In reply to Brian Lane from comment #4)
> Does adding that help? Can you post a patch or a PR on
> https://github.com/rhinstaller/livecd-tools

https://github.com/rhinstaller/livecd-tools/pull/35


> I can't see how this is happening. Both creator.py and yuminst.py import yum
> and when I try this manually I get this, which is what I'd expect:
> 
> >>> from yum.Errors import YumBaseError
> >>> yum
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> NameError: name 'yum' is not defined
> >>> yum.Errors
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> NameError: name 'yum' is not defined
> >>> import yum
> >>> yum.Errors
> <module 'yum.Errors' from '/usr/lib/python2.7/site-packages/yum/Errors.pyc'>
> 
> 
> Obviously you're seeing it :) But I just can't figure out how it's possible
> for it to happen.

That would be nice to understand. Also importing yum.Errors at top level doesn't solve, in the PR I sent I had to import just before using it to have it working.

Comment 6 Fedora Update System 2016-08-26 23:01:40 UTC
livecd-tools-23.4-1.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-0edc0e1794

Comment 7 Fedora Update System 2016-08-27 21:49:29 UTC
livecd-tools-23.4-1.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-0edc0e1794

Comment 8 Fedora Update System 2016-09-13 22:25:45 UTC
livecd-tools-23.4-1.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.

Comment 9 Michael Watters 2019-09-05 14:31:15 UTC
For what it's worth this issue also affects livecd-tools in CentOS 7.  The patch provided at https://github.com/livecd-tools/livecd-tools/pull/35 appears to fix the problem.


Note You need to log in before you can comment on or make changes to this bug.