[issue44539] Imghdr JPG Quantized

2021-06-30 Thread Mohamad Mansour


Change by Mohamad Mansour :


--
keywords: +patch
pull_requests: +25529
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/26964

___
Python tracker 
<https://bugs.python.org/issue44539>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44539] Imghdr JPG Quantized

2021-06-30 Thread Mohamad Mansour


Change by Mohamad Mansour :


--
components: +Library (Lib) -C API

___
Python tracker 
<https://bugs.python.org/issue44539>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44539] Imghdr JPG Quantized

2021-06-30 Thread Mohamad Mansour


New submission from Mohamad Mansour :

Previous method to check JPG images was using the following command (h[6:10] in 
(b'JFIF', b'Exif'))
However, its not always the case as some might start with b'\xff\xd8\xff\xdb' 
header.
Reference:
https://www.digicamsoft.com/itu/itu-t81-36.html
https://web.archive.org/web/20120403212223/http://class.ee.iastate.edu/ee528/Reading%20material/JPEG_File_Format.pdf

--
components: C API
messages: 396771
nosy: m.mansour
priority: normal
severity: normal
status: open
title: Imghdr JPG Quantized
type: enhancement
versions: Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8, Python 
3.9

___
Python tracker 
<https://bugs.python.org/issue44539>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26607] Rename a parameter in the function PyFile_FromFile

2016-03-21 Thread Mansour Moufid

New submission from Mansour Moufid:

Hi,

The last parameter of the function PyFile_FromFile is named 'close', but is a 
pointer to a function with the prototype of the 'fclose' function in libc. The 
mismatch causes confusion for some static analysis tools.

This patch renames the parameter to 'fclose'. Note that everywhere else 
PyFile_FromFile is called, that argument is always named fclose or pclose (or 
NULL), this was the one exception.

Thanks for your time.

--
files: 0001-PyFile_FromFile-Rename-close-parameter-to-fclose.patch
keywords: patch
messages: 262156
nosy: Mansour Moufid
priority: normal
severity: normal
status: open
title: Rename a parameter in the function PyFile_FromFile
type: enhancement
versions: Python 2.7
Added file: 
http://bugs.python.org/file42239/0001-PyFile_FromFile-Rename-close-parameter-to-fclose.patch

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26607>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14046] argparse: assertion failure if optional argument has square/round brackets in metavar

2012-02-17 Thread Mansour

New submission from Mansour mans...@oxplot.com:

I have a web server written in python which takes an optional argument telling 
it what IP and port to bind to. Here's the definition:

parser.add_argument(
  '-b', '--bind',
  metavar=[ip]:port,
  type=unicode,
  help=IP and port to bind to.
)

There are several other arguments as well. When the usage is printed (due to 
parse failures or -h), if the command line is longer than terminal width, it is 
wrapped. Here is the (relevant) code in argparse.py:311 which deals with this 
scenario:

# wrap the usage parts if it's too long
text_width = self._width - self._current_indent 
if len(prefix) + len(usage)  text_width: 
 
  # break usage into wrappable parts 
  part_regexp = r'\(.*?\)+|\[.*?\]+|\S+' 
  opt_usage = format(optionals, groups) 
  pos_usage = format(positionals, groups) 
  opt_parts = _re.findall(part_regexp, opt_usage) 
  pos_parts = _re.findall(part_regexp, pos_usage) 
  assert ' '.join(opt_parts) == opt_usage
  assert ' '.join(pos_parts) == pos_usage

Note how part_regexp extracts words, and text surrounded with round/square 
brackets. Now the argument I defined above, when displayed in usage text, looks 
like this: [-b [ip]:port]

part_regexp however, will cut it into [-b [ip] and :port] and concatenated 
later with  , it will have an extra space which causes the first assertion to 
fail.

I fiddled with part_regexp but that proved unreliable at best. I think the 
opt_parts should be obtained, not from the final formatted text, but from 
actual argument objects.

For a demonstration, see the attachment.

--
components: Library (Lib)
files: argparse_wrap_test.py
messages: 153632
nosy: oxplot
priority: normal
severity: normal
status: open
title: argparse: assertion failure if optional argument has square/round 
brackets in metavar
type: crash
versions: Python 2.7
Added file: http://bugs.python.org/file24554/argparse_wrap_test.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14046
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com