Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Latest commit

 

History

History
461 lines (361 loc) · 18.3 KB

20765.md

File metadata and controls

461 lines (361 loc) · 18.3 KB

Issue 20765: load not working via http

archive/issues_020528.json:

{
    "assignees": [],
    "body": "<div id=\"comment:0\"></div>\n\nIn the file `src/sage/structure/sage_object` there is the following doctest\n\n```\nsage: u = 'http://sage.math.washington.edu/home/was/db/test.sobj'\nsage: s = load(u)\n```\nThe doctest passes without problems when executed by `sage -t`, but executing the doctest manually in a sage session fails, probably because of circular imports\n\n```\nlll:sage4 maarten$ ./sage -t --warn-long 34.5 src/sage/structure/sage_object.pyx\nRunning doctests with ID 2016-06-03-00-49-24-4048fd29.\nGit branch: master\nUsing --optional=mpir,python2,sage\nDoctesting 1 file.\nsage -t --warn-long 34.5 src/sage/structure/sage_object.pyx\n    [204 tests, 8.22 s]\n----------------------------------------------------------------------\nAll tests passed!\n----------------------------------------------------------------------\nTotal time for all tests: 8.8 seconds\n    cpu time: 5.3 seconds\n    cumulative wall time: 8.2 seconds\nlll:sage4 maarten$ ./sage\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 SageMath version 7.2, Release Date: 2016-05-15                     \u2502\n\u2502 Type \"notebook()\" for the browser-based notebook interface.        \u2502\n\u2502 Type \"help()\" for help.                                            \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\nsage: u = 'http://sage.math.washington.edu/home/was/db/test.sobj'\nsage: s = load(u)\nAttempting to load remote file: http://sage.math.washington.edu/home/was/db/test.sobj\n---------------------------------------------------------------------------\nImportError                               Traceback (most recent call last)\n<ipython-input-2-3316b4211d6a> in <module>()\n----> 1 s = load(u)\n\n/Applications/sage4/src/sage/structure/sage_object.pyx in sage.structure.sage_object.load (/Applications/sage4/src/build/cythonized/sage/structure/sage_object.c:11530)()\n   1023     if lower.startswith(\"http://\") or lower.startswith(\"https://\"):\n   1024         from sage.misc.remote_file import get_remote_file\n-> 1025         filename = get_remote_file(filename, verbose=verbose)\n   1026         tmpfile_flag = True\n   1027     else:\n\n/Applications/sage4/local/lib/python2.7/site-packages/sage/misc/remote_file.pyc in get_remote_file(filename, verbose)\n     34 \n     35     # import compatible with py2 and py3\n---> 36     from six.moves.urllib.request import urlretrieve\n     37 \n     38     global cur\n\nImportError: No module named moves.urllib.request\n```\n\nThis was on a machine running OS X 10.10\n\nCC:  @mstreng\n\nComponent: **misc**\n\nReviewer: **Travis Scrimshaw**\n\n_Issue created by migration from https://trac.sagemath.org/ticket/20765_\n\n",
    "closed_at": "2017-01-21T18:03:11Z",
    "created_at": "2016-06-02T23:01:01Z",
    "labels": [
        "https://github.com/sagemath/sage/labels/bug",
        "https://github.com/sagemath/sage/labels/invalid"
    ],
    "reactions": [],
    "repository": "https://github.com/sagemath/sage",
    "title": "load not working via http",
    "type": "issue",
    "updated_at": "2017-01-21T18:03:11Z",
    "url": "https://github.com/sagemath/sage/issues/20765",
    "user": "https://github.com/koffie"
}

In the file src/sage/structure/sage_object there is the following doctest

sage: u = 'http://sage.math.washington.edu/home/was/db/test.sobj'
sage: s = load(u)

The doctest passes without problems when executed by sage -t, but executing the doctest manually in a sage session fails, probably because of circular imports

lll:sage4 maarten$ ./sage -t --warn-long 34.5 src/sage/structure/sage_object.pyx
Running doctests with ID 2016-06-03-00-49-24-4048fd29.
Git branch: master
Using --optional=mpir,python2,sage
Doctesting 1 file.
sage -t --warn-long 34.5 src/sage/structure/sage_object.pyx
    [204 tests, 8.22 s]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Total time for all tests: 8.8 seconds
    cpu time: 5.3 seconds
    cumulative wall time: 8.2 seconds
lll:sage4 maarten$ ./sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 7.2, Release Date: 2016-05-15                     │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
sage: u = 'http://sage.math.washington.edu/home/was/db/test.sobj'
sage: s = load(u)
Attempting to load remote file: http://sage.math.washington.edu/home/was/db/test.sobj
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-3316b4211d6a> in <module>()
----> 1 s = load(u)

/Applications/sage4/src/sage/structure/sage_object.pyx in sage.structure.sage_object.load (/Applications/sage4/src/build/cythonized/sage/structure/sage_object.c:11530)()
   1023     if lower.startswith("http://") or lower.startswith("https://"):
   1024         from sage.misc.remote_file import get_remote_file
-> 1025         filename = get_remote_file(filename, verbose=verbose)
   1026         tmpfile_flag = True
   1027     else:

/Applications/sage4/local/lib/python2.7/site-packages/sage/misc/remote_file.pyc in get_remote_file(filename, verbose)
     34 
     35     # import compatible with py2 and py3
---> 36     from six.moves.urllib.request import urlretrieve
     37 
     38     global cur

ImportError: No module named moves.urllib.request

This was on a machine running OS X 10.10

CC: @mstreng

Component: misc

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/20765


archive/issue_events_289756.json:

{
    "actor": "https://github.com/koffie",
    "created_at": "2016-06-02T23:01:01Z",
    "event": "milestoned",
    "issue": "https://github.com/sagemath/sage/issues/20765",
    "milestone_number": null,
    "milestone_title": "sage-7.3",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20765#event-289756"
}

archive/issue_events_289757.json:

{
    "actor": "https://github.com/koffie",
    "created_at": "2016-06-02T23:01:01Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20765",
    "label": "https://github.com/sagemath/sage/labels/p%3A%20major%20/%203",
    "label_color": "ffbb00",
    "label_name": "p: major / 3",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20765#event-289757"
}

archive/issue_events_289758.json:

{
    "actor": "https://github.com/koffie",
    "created_at": "2016-06-02T23:01:01Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20765",
    "label": "https://github.com/sagemath/sage/labels/bug",
    "label_color": "d73a4a",
    "label_name": "bug",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20765#event-289758"
}

archive/issue_events_289759.json:

{
    "actor": "https://github.com/koffie",
    "created_at": "2016-06-02T23:08:49Z",
    "event": "renamed",
    "issue": "https://github.com/sagemath/sage/issues/20765",
    "title_is": "load not working via http",
    "title_was": "load not working via https",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20765#event-289759"
}

archive/issue_comments_301044.json:

{
    "body": "Description changed:\n``````diff\n--- \n+++ \n@@ -50,3 +50,5 @@\n \n ImportError: No module named moves.urllib.request\n ```\n+\n+This was on a machine running OS X 10.10\n``````\n",
    "created_at": "2016-06-02T23:08:49Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20765",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20765#issuecomment-301044",
    "user": "https://github.com/koffie"
}

Description changed:

--- 
+++ 
@@ -50,3 +50,5 @@
 
 ImportError: No module named moves.urllib.request
 ```
+
+This was on a machine running OS X 10.10

archive/issue_comments_301045.json:

{
    "body": "Description changed:\n``````diff\n--- \n+++ \n@@ -4,7 +4,7 @@\n sage: u = 'http://sage.math.washington.edu/home/was/db/test.sobj'\n sage: s = load(u)\n ```\n-The doctest passes without problems, but executing the doctest manually fails, probably because of circular imports\n+The doctest passes without problems when executed by `sage -t`, but executing the doctest manually in a sage session fails, probably because of circular imports\n \n ```\n lll:sage4 maarten$ ./sage -t --warn-long 34.5 src/sage/structure/sage_object.pyx\n``````\n",
    "created_at": "2016-06-02T23:12:08Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20765",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20765#issuecomment-301045",
    "user": "https://github.com/koffie"
}

Description changed:

--- 
+++ 
@@ -4,7 +4,7 @@
 sage: u = 'http://sage.math.washington.edu/home/was/db/test.sobj'
 sage: s = load(u)
 ```
-The doctest passes without problems, but executing the doctest manually fails, probably because of circular imports
+The doctest passes without problems when executed by `sage -t`, but executing the doctest manually in a sage session fails, probably because of circular imports
 
 ```
 lll:sage4 maarten$ ./sage -t --warn-long 34.5 src/sage/structure/sage_object.pyx

archive/issue_comments_301046.json:

{
    "body": "<div id=\"comment:3\" align=\"right\">comment:3</div>\n\nActually the problem is already in `get_remote_file` which is called by `load`\n\n```\nsage: get_remote_file(\"http://sagemath.org/ack.html\", verbose=False)\n---------------------------------------------------------------------------\nImportError                               Traceback (most recent call last)\n<ipython-input-2-ea188b81d472> in <module>()\n----> 1 get_remote_file(\"http://sagemath.org/ack.html\", verbose=False)\n\n/Applications/sage/local/lib/python2.7/site-packages/sage/misc/remote_file.pyc in get_remote_file(filename, verbose)\n     34 \n     35     # import compatible with py2 and py3\n---> 36     from six.moves.urllib.request import urlretrieve\n     37 \n     38     global cur\n\nImportError: No module named moves.urllib.request\n```",
    "created_at": "2016-08-04T21:13:30Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20765",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20765#issuecomment-301046",
    "user": "https://github.com/koffie"
}
comment:3

Actually the problem is already in get_remote_file which is called by load

sage: get_remote_file("http://sagemath.org/ack.html", verbose=False)
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-ea188b81d472> in <module>()
----> 1 get_remote_file("http://sagemath.org/ack.html", verbose=False)

/Applications/sage/local/lib/python2.7/site-packages/sage/misc/remote_file.pyc in get_remote_file(filename, verbose)
     34 
     35     # import compatible with py2 and py3
---> 36     from six.moves.urllib.request import urlretrieve
     37 
     38     global cur

ImportError: No module named moves.urllib.request

archive/issue_comments_301047.json:

{
    "body": "<div id=\"comment:5\" align=\"right\">comment:5</div>\n\nIt seems like the culprit is that someone added a six.py file in misc so that the import is now importing from the local six.py file instead of the actual six file!",
    "created_at": "2016-12-16T21:03:36Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20765",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20765#issuecomment-301047",
    "user": "https://github.com/koffie"
}
comment:5

It seems like the culprit is that someone added a six.py file in misc so that the import is now importing from the local six.py file instead of the actual six file!


archive/issue_comments_301048.json:

{
    "body": "<div id=\"comment:6\" align=\"right\">comment:6</div>\n\nI found the solution. There is a [stackoverflow question](http://stackoverflow.com/questions/6031584/importing-from-builtin-library-when-module-with-same-name-exists) which answers how to get the system module. This is done by adding: `from `__future__` import absolute_import` at the top of `remote_file.py`. I tested this and this indeed solves the problem. The thing I don't get though is how the doctest passes even before fixing this bug.",
    "created_at": "2016-12-16T21:08:42Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20765",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20765#issuecomment-301048",
    "user": "https://github.com/koffie"
}
comment:6

I found the solution. There is a stackoverflow question which answers how to get the system module. This is done by adding: from future import absolute_import at the top of remote_file.py. I tested this and this indeed solves the problem. The thing I don't get though is how the doctest passes even before fixing this bug.


archive/issue_comments_301049.json:

{
    "body": "<div id=\"comment:7\" align=\"right\">comment:7</div>\n\nSeems like it is already fixed in #20797 so this ticket can be closed.",
    "created_at": "2016-12-17T16:13:42Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20765",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20765#issuecomment-301049",
    "user": "https://github.com/koffie"
}
comment:7

Seems like it is already fixed in #20797 so this ticket can be closed.


archive/issue_events_289760.json:

{
    "actor": "https://github.com/koffie",
    "created_at": "2016-12-17T16:13:42Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20765",
    "label": "https://github.com/sagemath/sage/labels/needs%20review",
    "label_color": "7fff00",
    "label_name": "needs review",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20765#event-289760"
}

archive/issue_events_289761.json:

{
    "actor": "https://github.com/tscrim",
    "created_at": "2016-12-17T17:22:38Z",
    "event": "unlabeled",
    "issue": "https://github.com/sagemath/sage/issues/20765",
    "label": "https://github.com/sagemath/sage/labels/needs%20review",
    "label_color": "7fff00",
    "label_name": "needs review",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20765#event-289761"
}

archive/issue_events_289762.json:

{
    "actor": "https://github.com/tscrim",
    "created_at": "2016-12-17T17:22:38Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20765",
    "label": "https://github.com/sagemath/sage/labels/positive%20review",
    "label_color": "dfffc0",
    "label_name": "positive review",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20765#event-289762"
}

archive/issue_comments_301050.json:

{
    "body": "Reviewer: **Travis Scrimshaw**",
    "created_at": "2016-12-17T17:22:38Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20765",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20765#issuecomment-301050",
    "user": "https://github.com/tscrim"
}

Reviewer: Travis Scrimshaw


archive/issue_events_289763.json:

{
    "actor": "https://github.com/tscrim",
    "created_at": "2016-12-17T17:22:38Z",
    "event": "demilestoned",
    "issue": "https://github.com/sagemath/sage/issues/20765",
    "milestone_number": null,
    "milestone_title": "sage-7.3",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20765#event-289763"
}

archive/issue_events_289764.json:

{
    "actor": "https://github.com/vbraun",
    "created_at": "2017-01-21T18:03:11Z",
    "event": "unlabeled",
    "issue": "https://github.com/sagemath/sage/issues/20765",
    "label": "https://github.com/sagemath/sage/labels/positive%20review",
    "label_color": "dfffc0",
    "label_name": "positive review",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20765#event-289764"
}

archive/issue_events_289765.json:

{
    "actor": "https://github.com/vbraun",
    "created_at": "2017-01-21T18:03:11Z",
    "event": "closed",
    "issue": "https://github.com/sagemath/sage/issues/20765",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20765#event-289765"
}