sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.23k stars 2.04k forks source link

Crash when translating indirect reference #1280

Closed shimizukawa closed 9 years ago

shimizukawa commented 9 years ago

When I ran sphinx-build, I got an exception ValueError: <reference: <#text: 'Layout'>> is not in list. Full traceback is attached.

Here is a patch to reproduce the issue:

#!diff

diff --git a/tests/roots/test-intl/indirect_reference.po b/tests/roots/test-intl/indirect_reference.po
new file mode 100644
--- /dev/null
+++ b/tests/roots/test-intl/indirect_reference.po
@@ -0,0 +1,23 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) 2012, foof
+# This file is distributed under the same license as the foo package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: sphinx 1.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-12-05 08:28\n"
+"PO-Revision-Date: 2013-10-02 17:07+0900\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Title"
+msgstr "Title in foo language"
+
+msgid "This is a `link`_."
+msgstr "THIS IS A `link`_"
diff --git a/tests/roots/test-intl/indirect_reference.txt b/tests/roots/test-intl/indirect_reference.txt
new file mode 100644
--- /dev/null
+++ b/tests/roots/test-intl/indirect_reference.txt
@@ -0,0 +1,11 @@
+:tocdepth: 2
+
+i18n with indirect reference
+============================
+
+Title
+-----
+
+This is a `link`_.
+
+.. _link: `Title`_
diff --git a/tests/test_intl.py b/tests/test_intl.py
--- a/tests/test_intl.py
+++ b/tests/test_intl.py
@@ -640,3 +640,9 @@
     (app.srcdir / 'xx' / 'LC_MESSAGES' / 'bom.mo').write_bytes(mo)
     _, count, _ = app.env.update(app.config, app.srcdir, app.doctreedir, app)
     assert count == 1
+
+
+@with_intl_app(buildername='text')
+def test_i18n_indirect_reference(app):
+    app.builder.build(['indirect_reference'])
+    result = (app.outdir / 'indirect_reference.txt').text(encoding='utf-8')

shimizukawa commented 9 years ago

From Takayuki Shimizukawa on 2013-10-02 14:46:38+00:00

I'm wondering why the sample raises ValueError: <reference: <#text: 'Layout'>> is not in list ... I'll check this soon.

shimizukawa commented 9 years ago

From Takayuki Shimizukawa on 2013-10-03 03:16:59+00:00

Nozomu Kaneko I can't reproduce this. BTW, I think this issue is same as #1265 and the test is already exist at f7b23ef21882. Please join #1265 discussion if my opinion is correct.

shimizukawa commented 9 years ago

From Takayuki Shimizukawa on 2013-10-03 20:20:05+00:00

Duplicate of #1265.

shimizukawa commented 9 years ago

From Nozomu Kaneko on 2013-10-03 21:17:43+00:00

Thank you for comments! I confirmed rev f7b23ef21882 fixes the issue.

shimizukawa commented 9 years ago

From Nozomu Kaneko on 2013-10-03 22:00:01+00:00

However, it seems that cfe9e2d11003 introduces another breakage. I'll report it later.