Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix issue 447 #503

Merged
merged 1 commit into from

2 participants

@manisandro

Apparently some drivers only emit SANE_STATUS_EOF once, and SANE_STATUS_IO_ERROR after that. The code however assumed that the driver keeps emitting SANE_STATUS_EOF. This commit fixes this.

@manisandro manisandro Fix issue 447: Apparently some drivers only emit SANE_STATUS_EOF once…
…, and SANE_STATUS_IO_ERROR after that. The code however assumed that the driver keeps emitting SANE_STATUS_EOF. This commit fixes this.
8324a9a
@aclark4life
Owner

Sorry, can you update this PR? Getting a CI build failure: https://travis-ci.org/python-imaging/Pillow/builds/17621210

@manisandro

The travis failure is not related to my change, the commit does not change anything related to eps files (which is where travis is stumbling). Do you need me to resubmit the PR to trigger a travis re-run or what should I do?

@aclark4life
Owner

I'll test local

@aclark4life aclark4life merged commit 8324a9a into from
@aclark4life
Owner

And… we don't have any SANE tests anyway :smile:. I'm going to merge this, but please consider writing a test or two or several to cover the SANE functionality.

@aclark4life
Owner

Fixes #447

@manisandro

Doesn't look like a sane dummy backend exists, so tests would be kinda hard to implement without requiring the system to have a scanner attached :S

@aclark4life
Owner

Can you mock one?

@manisandro

Uh, unfortunately I'm not really a sane expert, I've just used it in a project of mine and kinda know how to use it. But I found http://www.sane-project.org/man/sane-pnm.5.html which looks interesting, might give it a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 25, 2014
  1. @manisandro

    Fix issue 447: Apparently some drivers only emit SANE_STATUS_EOF once…

    manisandro authored
    …, and SANE_STATUS_IO_ERROR after that. The code however assumed that the driver keeps emitting SANE_STATUS_EOF. This commit fixes this.
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 8 deletions.
  1. +14 −8 Sane/_sane.c
View
22 Sane/_sane.c
@@ -916,10 +916,13 @@ SaneDev_snap(SaneDevObject *self, PyObject *args)
call which returns SANE_STATUS_EOF in order to start
a new frame.
*/
- do {
- st = sane_read(self->h, buffer, READSIZE, &len);
- }
- while (st == SANE_STATUS_GOOD);
+ if (st != SANE_STATUS_EOF)
+ {
+ do {
+ st = sane_read(self->h, buffer, READSIZE, &len);
+ }
+ while (st == SANE_STATUS_GOOD);
+ }
if (st != SANE_STATUS_EOF)
{
Py_BLOCK_THREADS
@@ -937,10 +940,13 @@ SaneDev_snap(SaneDevObject *self, PyObject *args)
}
}
/* enforce SANE_STATUS_EOF. Can be necessary for ADF scans for some backends */
- do {
- st = sane_read(self->h, buffer, READSIZE, &len);
- }
- while (st == SANE_STATUS_GOOD);
+ if (st != SANE_STATUS_EOF)
+ {
+ do {
+ st = sane_read(self->h, buffer, READSIZE, &len);
+ }
+ while (st == SANE_STATUS_GOOD);
+ }
if (st != SANE_STATUS_EOF)
{
sane_cancel(self->h);
Something went wrong with that request. Please try again.