Xqt has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/801716 )

Change subject: [bugfix] Solve "using variable 'infile' before assignment"
......................................................................

[bugfix] Solve "using variable 'infile' before assignment"

Change-Id: Ib144e7ccd0021d5519442dfa0c6b40c03b0d998c
---
M scripts/reflinks.py
1 file changed, 4 insertions(+), 3 deletions(-)

Approvals:
  DannyS712: Looks good to me, but someone else must approve
  Xqt: Verified; Looks good to me, approved



diff --git a/scripts/reflinks.py b/scripts/reflinks.py
index aa3de1a..377b456 100755
--- a/scripts/reflinks.py
+++ b/scripts/reflinks.py
@@ -496,7 +496,7 @@
         """Use pdfinfo to retrieve title from a PDF."""
         # pdfinfo is Unix-only
         pywikibot.output('Reading PDF file...')
-
+        infile = None
         try:
             fd, infile = tempfile.mkstemp()
             urlobj = os.fdopen(fd, 'w+')
@@ -524,8 +524,9 @@
                         break
             pywikibot.output('PDF done.')
         finally:
-            urlobj.close()
-            os.unlink(infile)
+            if infile is not None:
+                urlobj.close()
+                os.unlink(infile)

     def setup(self):
         """Read dead links from file."""

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/801716
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ib144e7ccd0021d5519442dfa0c6b40c03b0d998c
Gerrit-Change-Number: 801716
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: DannyS712 <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to